diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-12 23:05:37 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-07-12 23:05:37 +0000 |
commit | e2cd5478c108af0ca999cf5f4d5058c4d0e23b78 (patch) | |
tree | c75b681961d1e24ee768f371fe3b4931918c40dd /usr.sbin/mtree/compare.c | |
parent | 2e15f8e3051d41c8c12d4f866aba6b95c95d8919 (diff) |
Add sha1 digest support.
Diffstat (limited to 'usr.sbin/mtree/compare.c')
-rw-r--r-- | usr.sbin/mtree/compare.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index 81d6cd5e0ef..accef0a0177 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.6 1997/01/03 21:40:48 millert Exp $ */ +/* $OpenBSD: compare.c,v 1.7 1997/07/12 23:05:34 millert Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: compare.c,v 1.6 1997/01/03 21:40:48 millert Exp $"; +static char rcsid[] = "$OpenBSD: compare.c,v 1.7 1997/07/12 23:05:34 millert Exp $"; #endif #endif /* not lint */ @@ -51,6 +51,7 @@ static char rcsid[] = "$OpenBSD: compare.c,v 1.6 1997/01/03 21:40:48 millert Exp #include <time.h> #include <unistd.h> #include <md5.h> +#include <sha1.h> #include "mtree.h" #include "extern.h" @@ -228,7 +229,7 @@ typeerr: LABEL; if (s->flags & F_MD5) { char *new_digest, buf[33]; - new_digest = MD5File(p->fts_accpath,buf); + new_digest = MD5File(p->fts_accpath, buf); if (!new_digest) { LABEL; printf("%sMD5File: %s: %s\n", tab, p->fts_accpath, @@ -241,7 +242,22 @@ typeerr: LABEL; tab = "\t"; } } + if (s->flags & F_SHA1) { + char *new_digest, buf[41]; + new_digest = SHA1File(p->fts_accpath, buf); + if (!new_digest) { + LABEL; + printf("%sSHA1File: %s: %s\n", tab, p->fts_accpath, + strerror(errno)); + tab = "\t"; + } else if (strcmp(new_digest, s->sha1digest)) { + LABEL; + printf("%sSHA1 (%s, %s)\n", tab, s->sha1digest, + 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); |