summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/create.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/create.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/create.c')
-rw-r--r--usr.sbin/mtree/create.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c
index fa902e4..f1b0313 100644
--- a/usr.sbin/mtree/create.c
+++ b/usr.sbin/mtree/create.c
@@ -52,6 +52,9 @@ __FBSDID("$FreeBSD$");
#ifdef RMD160
#include <ripemd.h>
#endif
+#ifdef SHA256
+#include <sha256.h>
+#endif
#include <pwd.h>
#include <stdint.h>
#include <stdio.h>
@@ -249,6 +252,16 @@ statf(int indent, FTSENT *p)
output(indent, &offset, "ripemd160digest=%s", digest);
}
#endif /* RMD160 */
+#ifdef SHA256
+ if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) {
+ char *digest, buf[65];
+
+ digest = SHA256_File(p->fts_accpath, buf);
+ if (!digest)
+ err(1, "%s", p->fts_accpath);
+ output(indent, &offset, "sha256digest=%s", digest);
+ }
+#endif /* SHA256 */
if (keys & F_SLINK &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE))
output(indent, &offset, "link=%s", rlink(p->fts_accpath));
OpenPOWER on IntegriCloud