diff options
author | 2012-07-08 21:19:42 +0000 | |
---|---|---|
committer | 2012-07-08 21:19:42 +0000 | |
commit | 75049d8d5368dca544e20be89825423f8fce6a8c (patch) | |
tree | c8a5af2fc91137f5e0589c4861c72b96fbd9d567 /usr.sbin/mtree/compare.c | |
parent | Quiesce and suspend devices in the resuming kernel for hibernate. (diff) | |
download | wireguard-openbsd-75049d8d5368dca544e20be89825423f8fce6a8c.tar.xz wireguard-openbsd-75049d8d5368dca544e20be89825423f8fce6a8c.zip |
Add support for the "sha256digest" keyword to create/compare
SHA-256 digests of files. In the man page, also replace SHA-1
with SHA-256 in the examples section.
Man page formatting tweak and ok schwarze@
Diffstat (limited to 'usr.sbin/mtree/compare.c')
-rw-r--r-- | usr.sbin/mtree/compare.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index adc121c0088..21c0fca9ba1 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -1,5 +1,5 @@ /* $NetBSD: compare.c,v 1.11 1996/09/05 09:56:48 mycroft Exp $ */ -/* $OpenBSD: compare.c,v 1.22 2009/10/27 23:59:53 deraadt Exp $ */ +/* $OpenBSD: compare.c,v 1.23 2012/07/08 21:19:42 naddy Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -39,8 +39,9 @@ #include <time.h> #include <unistd.h> #include <md5.h> -#include <sha1.h> #include <rmd160.h> +#include <sha1.h> +#include <sha2.h> #include "mtree.h" #include "extern.h" @@ -287,6 +288,22 @@ typeerr: LABEL; tab = "\t"; } } + if (s->flags & F_SHA256) { + char *new_digest, buf[SHA256_DIGEST_STRING_LENGTH]; + + new_digest = SHA256File(p->fts_accpath, buf); + if (!new_digest) { + LABEL; + printf("%sSHA256File: %s: %s\n", tab, p->fts_accpath, + strerror(errno)); + tab = "\t"; + } else if (strcmp(new_digest, s->sha256digest)) { + LABEL; + printf("%sSHA256 (%s, %s)\n", tab, s->sha256digest, + new_digest); + tab = "\t"; + } + } if (s->flags & F_SLINK && strcmp(cp = rlink(name), s->slink)) { LABEL; (void)printf("%slink ref (%s, %s)\n", tab, cp, s->slink); |