summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/compare.c
diff options
context:
space:
mode:
authortobez <tobez@FreeBSD.org>2005-03-29 11:44:17 +0000
committertobez <tobez@FreeBSD.org>2005-03-29 11:44:17 +0000
commit33bcab28052aed309c71543e4d9db75259feffda (patch)
tree3649da480656bca08f4c722336ccea910c49eb2f /usr.sbin/mtree/compare.c
parent5f6d29a6e04fc4f90eea3974de0b53b8d24b2e87 (diff)
downloadFreeBSD-src-33bcab28052aed309c71543e4d9db75259feffda.zip
FreeBSD-src-33bcab28052aed309c71543e4d9db75259feffda.tar.gz
Adds sha256 support. While it is a good idea to also add sha384 and
sha512, I did not do that since it is not entirely clear where "the one true place" to hold their implementations is going to be. Sha256 is different since mtree already links against libmd. Make recommended procedure for integrity checking in the manpage consistent. Fix a bug with -f spec1 -f spec2 comparison, which prevented test/tes03.sh from running successfully. Reviewed by: phk, cperciva
Diffstat (limited to 'usr.sbin/mtree/compare.c')
-rw-r--r--usr.sbin/mtree/compare.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c
index bf4353c..44556d6 100644
--- a/usr.sbin/mtree/compare.c
+++ b/usr.sbin/mtree/compare.c
@@ -52,6 +52,9 @@ __FBSDID("$FreeBSD$");
#ifdef SHA1
#include <sha.h>
#endif
+#ifdef SHA256
+#include <sha256.h>
+#endif
#include <stdint.h>
#include <stdio.h>
#include <time.h>
@@ -294,6 +297,24 @@ typeerr: LABEL;
}
}
#endif /* RMD160 */
+#ifdef SHA256
+ if (s->flags & F_SHA256) {
+ char *new_digest, buf[65];
+
+ new_digest = SHA256_File(p->fts_accpath, buf);
+ if (!new_digest) {
+ LABEL;
+ printf("%sSHA-256: %s: %s\n", tab, p->fts_accpath,
+ strerror(errno));
+ tab = "\t";
+ } else if (strcmp(new_digest, s->sha256digest)) {
+ LABEL;
+ printf("%sSHA-256 expected %s found %s\n",
+ tab, s->sha256digest, new_digest);
+ tab = "\t";
+ }
+ }
+#endif /* SHA256 */
if (s->flags & F_SLINK &&
strcmp(cp = rlink(p->fts_accpath), s->slink)) {
OpenPOWER on IntegriCloud