Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src Apply patch (requested by elad in ticket #755):
details: https://anonhg.NetBSD.org/src/rev/d08779cd68bc
branches: netbsd-3
changeset: 577149:d08779cd68bc
user: tron <tron%NetBSD.org@localhost>
date: Mon Sep 12 12:26:27 2005 +0000
description:
Apply patch (requested by elad in ticket #755):
Add support for SHA2 in mtree(8).
diffstat:
tools/mtree/Makefile | 4 +-
usr.sbin/mtree/compare.c | 59 ++++++++++++++++++++++++++++++++++++++++++++---
usr.sbin/mtree/create.c | 28 +++++++++++++++++++---
usr.sbin/mtree/misc.c | 12 +++++++--
usr.sbin/mtree/mtree.8 | 33 ++++++++++++++++++++++++--
usr.sbin/mtree/mtree.h | 8 +++++-
usr.sbin/mtree/spec.c | 40 ++++++++++++++++++++++++++++++-
7 files changed, 165 insertions(+), 19 deletions(-)
diffs (truncated from 379 to 300 lines):
diff -r 5e540555e006 -r d08779cd68bc tools/mtree/Makefile
--- a/tools/mtree/Makefile Mon Sep 12 12:17:35 2005 +0000
+++ b/tools/mtree/Makefile Mon Sep 12 12:26:27 2005 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2002/12/08 20:20:04 thorpej Exp $
+# $NetBSD: Makefile,v 1.5.6.1 2005/09/12 12:26:27 tron Exp $
HOSTPROGNAME= ${_TOOL_PREFIX}mtree
HOST_SRCDIR= usr.sbin/mtree
-HOST_CPPFLAGS= -DNO_MD5 -DNO_RMD160 -DNO_SHA1
+HOST_CPPFLAGS= -DNO_MD5 -DNO_RMD160 -DNO_SHA1 -DNO_SHA2
.include "${.CURDIR}/../Makefile.host"
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/compare.c
--- a/usr.sbin/mtree/compare.c Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/compare.c Mon Sep 12 12:26:27 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compare.c,v 1.45 2004/07/22 16:51:45 lukem Exp $ */
+/* $NetBSD: compare.c,v 1.45.2.1 2005/09/12 12:26:27 tron Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: compare.c,v 1.45 2004/07/22 16:51:45 lukem Exp $");
+__RCSID("$NetBSD: compare.c,v 1.45.2.1 2005/09/12 12:26:27 tron Exp $");
#endif
#endif /* not lint */
@@ -60,6 +60,9 @@
#ifndef NO_SHA1
#include <sha1.h>
#endif
+#ifndef NO_SHA2
+#include <crypto/sha2.h>
+#endif
#include "extern.h"
@@ -123,8 +126,9 @@
u_int32_t len, val, flags;
int fd, label;
const char *cp, *tab;
-#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1)
- char digestbuf[41]; /* large enough for {MD5,RMD160,SHA1}File() */
+#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
+ /* char digestbuf[MAXHASHLEN + 1]; */
+ char *digestbuf = NULL;
#endif
tab = NULL;
@@ -430,6 +434,53 @@
}
}
#endif /* ! NO_SHA1 */
+#ifndef NO_SHA2
+ if (s->flags & F_SHA256) {
+ if (SHA256_File(p->fts_accpath, digestbuf) == NULL) {
+ LABEL;
+ printf("%ssha256: %s: %s\n",
+ tab, p->fts_accpath, strerror(errno));
+ tab = "\t";
+ } else {
+ if (strcmp(s->sha256digest, digestbuf)) {
+ LABEL;
+ printf("%ssha256 (0x%s, 0x%s)\n",
+ tab, s->sha256digest, digestbuf);
+ }
+ tab = "\t";
+ }
+ }
+ if (s->flags & F_SHA384) {
+ if (SHA384_File(p->fts_accpath, digestbuf) == NULL) {
+ LABEL;
+ printf("%ssha384: %s: %s\n",
+ tab, p->fts_accpath, strerror(errno));
+ tab = "\t";
+ } else {
+ if (strcmp(s->sha384digest, digestbuf)) {
+ LABEL;
+ printf("%ssha384 (0x%s, 0x%s)\n",
+ tab, s->sha384digest, digestbuf);
+ }
+ tab = "\t";
+ }
+ }
+ if (s->flags & F_SHA512) {
+ if (SHA512_File(p->fts_accpath, digestbuf) == NULL) {
+ LABEL;
+ printf("%ssha512: %s: %s\n",
+ tab, p->fts_accpath, strerror(errno));
+ tab = "\t";
+ } else {
+ if (strcmp(s->sha512digest, digestbuf)) {
+ LABEL;
+ printf("%ssha512 (0x%s, 0x%s)\n",
+ tab, s->sha512digest, digestbuf);
+ }
+ tab = "\t";
+ }
+ }
+#endif /* ! NO_SHA2 */
if (s->flags & F_SLINK &&
strcmp(cp = rlink(p->fts_accpath), s->slink)) {
LABEL;
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/create.c
--- a/usr.sbin/mtree/create.c Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/create.c Mon Sep 12 12:26:27 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: create.c,v 1.46 2004/12/01 10:07:56 lukem Exp $ */
+/* $NetBSD: create.c,v 1.46.2.1 2005/09/12 12:26:27 tron Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: create.c,v 1.46 2004/12/01 10:07:56 lukem Exp $");
+__RCSID("$NetBSD: create.c,v 1.46.2.1 2005/09/12 12:26:27 tron Exp $");
#endif
#endif /* not lint */
@@ -69,6 +69,9 @@
#ifndef NO_SHA1
#include <sha1.h>
#endif
+#ifndef NO_SHA2
+#include <crypto/sha2.h>
+#endif
#include "extern.h"
@@ -146,8 +149,8 @@
u_int32_t len, val;
int fd, indent;
const char *name;
-#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1)
- char digestbuf[41]; /* large enough for {MD5,RMD160,SHA1}File() */
+#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
+ char digestbuf[MAXHASHLEN + 1];
#endif
indent = printf("%s%s",
@@ -220,6 +223,23 @@
output(&indent, "sha1=%s", digestbuf);
}
#endif /* ! NO_SHA1 */
+#ifndef NO_SHA2
+ if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) {
+ if (SHA256_File(p->fts_accpath, digestbuf) == NULL)
+ mtree_err("%s: %s", p->fts_accpath, "SHA256_File");
+ output(&indent, "sha256=%s", digestbuf);
+ }
+ if (keys & F_SHA384 && S_ISREG(p->fts_statp->st_mode)) {
+ if (SHA384_File(p->fts_accpath, digestbuf) == NULL)
+ mtree_err("%s: %s", p->fts_accpath, "SHA384_File");
+ output(&indent, "sha384=%s", digestbuf);
+ }
+ if (keys & F_SHA512 && S_ISREG(p->fts_statp->st_mode)) {
+ if (SHA512_File(p->fts_accpath, digestbuf) == NULL)
+ mtree_err("%s: %s", p->fts_accpath, "SHA512_File");
+ output(&indent, "sha512=%s", digestbuf);
+ }
+#endif /* ! NO_SHA2 */
if (keys & F_SLINK &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE))
output(&indent, "link=%s", vispath(rlink(p->fts_accpath)));
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/misc.c
--- a/usr.sbin/mtree/misc.c Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/misc.c Mon Sep 12 12:26:27 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: misc.c,v 1.25 2004/06/20 22:20:18 jmc Exp $ */
+/* $NetBSD: misc.c,v 1.25.2.1 2005/09/12 12:26:27 tron Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: misc.c,v 1.25 2004/06/20 22:20:18 jmc Exp $");
+__RCSID("$NetBSD: misc.c,v 1.25.2.1 2005/09/12 12:26:27 tron Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -81,7 +81,13 @@
{"time", F_TIME, NEEDVALUE},
{"type", F_TYPE, NEEDVALUE},
{"uid", F_UID, NEEDVALUE},
- {"uname", F_UNAME, NEEDVALUE}
+ {"uname", F_UNAME, NEEDVALUE},
+ {"sha256", F_SHA256, NEEDVALUE},
+ {"sha256digest",F_SHA256, NEEDVALUE},
+ {"sha384", F_SHA384, NEEDVALUE},
+ {"sha384digest",F_SHA384, NEEDVALUE},
+ {"sha512", F_SHA512, NEEDVALUE},
+ {"sha512digest",F_SHA512, NEEDVALUE},
};
static KEY typelist[] = {
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/mtree.8
--- a/usr.sbin/mtree/mtree.8 Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/mtree.8 Mon Sep 12 12:26:27 2005 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: mtree.8,v 1.39 2004/07/22 16:51:45 lukem Exp $
+.\" $NetBSD: mtree.8,v 1.39.2.1 2005/09/12 12:26:27 tron Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -63,7 +63,7 @@
.\"
.\" @(#)mtree.8 8.2 (Berkeley) 12/11/93
.\"
-.Dd July 22, 2004
+.Dd August 23, 2005
.Dt MTREE 8
.Os
.Sh NAME
@@ -416,6 +416,27 @@
.It Sy sha1digest
Synonym for
.Sy sha1 .
+.It Sy sha256
+The 256-bits
+.Tn SHA-2
+cryptographic message digest of the file.
+.It Sy sha256digest
+Synonym for
+.Sy sha256 .
+.It Sy sha384
+The 384-bits
+.Tn SHA-2
+cryptographic message digest of the file.
+.It Sy sha384digest
+Synonym for
+.Sy sha384 .
+.It Sy sha512
+The 512-bits
+.Tn SHA-2
+cryptographic message digest of the file.
+.It Sy sha512digest
+Synonym for
+.Sy sha512 .
.It Sy size
The size, in bytes, of the file.
.It Sy tags
@@ -606,7 +627,6 @@
.Xr chgrp 1 ,
.Xr chmod 1 ,
.Xr cksum 1 ,
-.Xr md5 1 ,
.Xr stat 2 ,
.Xr fnmatch 3 ,
.Xr fts 3 ,
@@ -658,3 +678,10 @@
.Fl X
flags, and support for full paths appeared in
.Nx 1.6 .
+The
+.Sy sha256 ,
+.Sy sha384 ,
+and
+.Sy sha512
+keywords appeared in
+.Nx 4.0 .
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/mtree.h
--- a/usr.sbin/mtree/mtree.h Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/mtree.h Mon Sep 12 12:26:27 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mtree.h,v 1.22 2004/07/22 16:51:45 lukem Exp $ */
+/* $NetBSD: mtree.h,v 1.22.2.1 2005/09/12 12:26:27 tron Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -56,6 +56,9 @@
char *md5digest; /* MD5 digest */
char *rmd160digest; /* RMD-160 digest */
char *sha1digest; /* SHA1 digest */
+ char *sha256digest; /* SHA256 digest */
+ char *sha384digest; /* SHA384 digest */
+ char *sha512digest; /* SHA512 digest */
char *tags; /* tags, comma delimited */
size_t lineno; /* line # entry came from */
@@ -81,6 +84,9 @@
#define F_UID 0x00080000 /* uid */
#define F_UNAME 0x00100000 /* user name */
#define F_VISIT 0x00200000 /* file visited */
+#define F_SHA256 0x00800000 /* SHA256 digest */
+#define F_SHA384 0x01000000 /* SHA384 digest */
+#define F_SHA512 0x02000000 /* SHA512 digest */
int flags; /* items set */
diff -r 5e540555e006 -r d08779cd68bc usr.sbin/mtree/spec.c
--- a/usr.sbin/mtree/spec.c Mon Sep 12 12:17:35 2005 +0000
+++ b/usr.sbin/mtree/spec.c Mon Sep 12 12:26:27 2005 +0000
Home |
Main Index |
Thread Index |
Old Index