summaryrefslogtreecommitdiffstats
path: root/file_cmds/mtree
diff options
context:
space:
mode:
Diffstat (limited to 'file_cmds/mtree')
-rw-r--r--file_cmds/mtree/commoncrypto.c3
-rw-r--r--file_cmds/mtree/compare.c17
-rw-r--r--file_cmds/mtree/extern.h2
-rw-r--r--file_cmds/mtree/mtree.83
-rw-r--r--file_cmds/mtree/mtree.c14
-rw-r--r--file_cmds/mtree/spec.c10
-rw-r--r--file_cmds/mtree/verify.c4
7 files changed, 37 insertions, 16 deletions
diff --git a/file_cmds/mtree/commoncrypto.c b/file_cmds/mtree/commoncrypto.c
index 11e97ce..0ac621c 100644
--- a/file_cmds/mtree/commoncrypto.c
+++ b/file_cmds/mtree/commoncrypto.c
@@ -105,7 +105,8 @@ xattr_info *
SHA256_Path_XATTRs(char *path, char *buf) {
xattr_info *ai = NULL;
- if (mflag) {
+ // mflag is passed during manifest comparision while xflag is used to generate the specification
+ if (mflag || xflag) {
ai = get_xdstream_privateid(path, buf);
} else {
ai = calculate_SHA256_XATTRs(path, buf);
diff --git a/file_cmds/mtree/compare.c b/file_cmds/mtree/compare.c
index e585928..366f12f 100644
--- a/file_cmds/mtree/compare.c
+++ b/file_cmds/mtree/compare.c
@@ -534,11 +534,18 @@ typeerr: LABEL;
int supported;
struct timespec ptimespec = ptime(p->fts_accpath, &supported);
if (!supported) {
- LABEL;
- (void)printf("%stime added to parent folder expected %.24s.%09ld found that it is not supported\n",
- tab, ctime(&s->st_ptimespec.tv_sec), s->st_ptimespec.tv_nsec);
- tab = "\t";
- } else if (supported && ((s->st_ptimespec.tv_sec != ptimespec.tv_sec) ||
+ if (mflag) {
+ ptimespec.tv_sec = 0;
+ ptimespec.tv_nsec = 0;
+ supported = 1;
+ } else {
+ LABEL;
+ (void)printf("%stime added to parent folder expected %.24s.%09ld found that it is not supported\n",
+ tab, ctime(&s->st_ptimespec.tv_sec), s->st_ptimespec.tv_nsec);
+ tab = "\t";
+ }
+ }
+ if (supported && ((s->st_ptimespec.tv_sec != ptimespec.tv_sec) ||
(s->st_ptimespec.tv_nsec != ptimespec.tv_nsec))) {
if (!mflag) {
LABEL;
diff --git a/file_cmds/mtree/extern.h b/file_cmds/mtree/extern.h
index 47533c2..fb7ea83 100644
--- a/file_cmds/mtree/extern.h
+++ b/file_cmds/mtree/extern.h
@@ -61,7 +61,7 @@ const char * ftype(u_int type);
extern int ftsoptions;
extern u_int keys;
extern int lineno;
-extern int dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, wflag, mflag, tflag;
+extern int dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, wflag, mflag, tflag, xflag;
extern int insert_mod, insert_birth, insert_access, insert_change, insert_parent;
extern struct timespec ts;
#ifdef MAXPATHLEN
diff --git a/file_cmds/mtree/mtree.8 b/file_cmds/mtree/mtree.8
index 1aa529a..fb7cff8 100644
--- a/file_cmds/mtree/mtree.8
+++ b/file_cmds/mtree/mtree.8
@@ -148,6 +148,9 @@ This occurs when the directory is a symbolic link.
Remove any files in the file hierarchy that are not described in the
specification.
.\" ==========
+.It Fl S
+Skip calculating the digest of the extended attributes of the file.
+.\" ==========
.It Fl s Ar seed
Display a single checksum to the standard error output that represents all
of the files for which the keyword
diff --git a/file_cmds/mtree/mtree.c b/file_cmds/mtree/mtree.c
index edf0cce..46cc2ae 100644
--- a/file_cmds/mtree/mtree.c
+++ b/file_cmds/mtree/mtree.c
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD: src/usr.sbin/mtree/mtree.c,v 1.29 2004/06/04 19:29:28 ru Exp
#define SECONDS_IN_A_DAY (60 * 60 * 24)
int ftsoptions = FTS_PHYSICAL;
-int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag, wflag, mflag, tflag;
+int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag, wflag, mflag, tflag, xflag;
int insert_mod, insert_birth, insert_access, insert_change, insert_parent;
struct timespec ts;
u_int keys;
@@ -101,7 +101,7 @@ main(int argc, char *argv[])
atexit(do_cleanup);
atexit(print_metrics_to_file);
- while ((ch = getopt(argc, argv, "cdef:iK:k:LnPp:qrs:UuwxX:m:F:t:E:")) != -1)
+ while ((ch = getopt(argc, argv, "cdef:iK:k:LnPp:qrs:UuwxX:m:F:t:E:S")) != -1)
switch((char)ch) {
case 'c':
cflag = 1;
@@ -216,8 +216,10 @@ main(int argc, char *argv[])
} else {
set_metrics_file(file);
}
- break;
-
+ break;
+ case 'S':
+ xflag = 1;
+ break;
case '?':
default:
RECORD_FAILURE(92, WARN_USAGE);
@@ -279,7 +281,7 @@ main(int argc, char *argv[])
status = mtree_verifyspec(spec1);
if (Uflag & (status == MISMATCHEXIT)) {
status = 0;
- } else {
+ } else if (status) {
RECORD_FAILURE(100, status);
}
if (mflag && CFDictionaryGetCount(dict)) {
@@ -296,7 +298,7 @@ static void
usage(void)
{
(void)fprintf(stderr,
-"usage: mtree [-LPUcdeinqruxw] [-f spec] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n"
+"usage: mtree [-LPUScdeinqruxw] [-f spec] [-K key] [-k key] [-p path] [-s seed] [-m xml dictionary] [-t timestamp]\n"
"\t[-X excludes]\n");
exit(1);
}
diff --git a/file_cmds/mtree/spec.c b/file_cmds/mtree/spec.c
index f15d857..4119124 100644
--- a/file_cmds/mtree/spec.c
+++ b/file_cmds/mtree/spec.c
@@ -186,6 +186,7 @@ set(char *t, NODE *ip)
mode_t *m;
int value;
char *ep;
+ char *l;
for (; (kw = strtok(t, "= \t\n")); t = NULL) {
ip->flags |= type = parsekey(kw, &value);
@@ -415,14 +416,19 @@ set(char *t, NODE *ip)
}
break;
case F_XATTRS:
- ep = strtok(val,".");
+ /*
+ * Note this is nested inside an strtok loop,
+ * strtok_r must be used to preserve the strtok context
+ * of the loop.
+ */
+ ep = strtok_r(val,".", &l);
ip->xattrsdigest = strdup(ep);
if (!ip->xattrsdigest) {
error = errno;
RECORD_FAILURE(54, error);
errc(1, error, "strdup");
}
- val = strtok(NULL,".");
+ val = strtok_r(NULL,".", &l);
if (val) {
ip->xdstream_priv_id = strtoull(val, &ep, 10);
if (*ep) {
diff --git a/file_cmds/mtree/verify.c b/file_cmds/mtree/verify.c
index 7471652..4978098 100644
--- a/file_cmds/mtree/verify.c
+++ b/file_cmds/mtree/verify.c
@@ -70,7 +70,9 @@ mtree_verifyspec(FILE *fi)
RECORD_FAILURE(60, WARN_MISMATCH);
return rval;
} else {
- RECORD_FAILURE(61, WARN_MISMATCH);
+ if (mval != 0) {
+ RECORD_FAILURE(61, WARN_MISMATCH);
+ }
return mval;
}
}