summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree
diff options
context:
space:
mode:
authorrgrimes <rgrimes@FreeBSD.org>1994-10-09 20:28:31 +0000
committerrgrimes <rgrimes@FreeBSD.org>1994-10-09 20:28:31 +0000
commit162fb0a314dd6710aec3360de1d1b267c23eab9b (patch)
treebe14d95cb56debd28cb3f95b1b3b8997eb516fa8 /usr.sbin/mtree
parent0c0e5e4cbf54b34e02183e61af87b14ca5904e05 (diff)
downloadFreeBSD-src-162fb0a314dd6710aec3360de1d1b267c23eab9b.zip
FreeBSD-src-162fb0a314dd6710aec3360de1d1b267c23eab9b.tar.gz
Add -U option which does the same things as -u except exits with 0
instead of 2 on MISMATCH.
Diffstat (limited to 'usr.sbin/mtree')
-rw-r--r--usr.sbin/mtree/mtree.814
-rw-r--r--usr.sbin/mtree/mtree.c16
2 files changed, 24 insertions, 6 deletions
diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8
index e8a4cb2..92c65a4c 100644
--- a/usr.sbin/mtree/mtree.8
+++ b/usr.sbin/mtree/mtree.8
@@ -39,7 +39,7 @@
.Nd map a directory hierarchy
.Sh SYNOPSIS
.Nm mtree
-.Op Fl cdeinrux
+.Op Fl cdeinrUux
.Op Fl f Ar spec
.Op Fl K Ar keywords
.Op Fl k Ar keywords
@@ -100,11 +100,18 @@ of the files for which the keyword
.Cm cksum
was specified.
The checksum is seeded with the specified value.
-.It Fl u
+.It Fl U
Modify the owner, group, and permissions of existing files to match
the specification and create any missing directories.
User, group, and permissions must all be specified for missing directories
to be created.
+Exit with a status of 0 on success, 1 if any error occurred,
+a mismatch is not considered an error if it was corrected.
+.It Fl u
+Same as
+.Fl U
+except a status of 2 is returned if the file hierarchy did not match
+the specification.
.It Fl x
Don't descend below mount points in the file hierarchy.
.El
@@ -218,6 +225,9 @@ The
.Nm mtree
utility exits with a status of 0 on success, 1 if any error occurred,
and 2 if the file hierarchy did not match the specification.
+A status of 2 is converted to a status of 0 if the
+.Fl U
+option is used.
.Sh EXAMPLES
To detect system binaries that have been ``trojan horsed'', it is recommended
that
diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c
index 9f5aad6..349dbb9 100644
--- a/usr.sbin/mtree/mtree.c
+++ b/usr.sbin/mtree/mtree.c
@@ -53,7 +53,7 @@ static char sccsid[] = "@(#)mtree.c 8.1 (Berkeley) 6/6/93";
extern long int crc_total;
int ftsoptions = FTS_PHYSICAL;
-int cflag, dflag, eflag, iflag, nflag, rflag, sflag, uflag;
+int cflag, dflag, eflag, iflag, nflag, rflag, sflag, uflag, Uflag;
u_short keys;
char fullpath[MAXPATHLEN];
@@ -68,10 +68,11 @@ main(argc, argv)
extern char *optarg;
int ch;
char *dir, *p;
+ int status;
dir = NULL;
keys = KEYDEFAULT;
- while ((ch = getopt(argc, argv, "cdef:iK:k:np:rs:ux")) != EOF)
+ while ((ch = getopt(argc, argv, "cdef:iK:k:np:rs:Uux")) != EOF)
switch((char)ch) {
case 'c':
cflag = 1;
@@ -114,6 +115,10 @@ main(argc, argv)
crc_total = ~strtol(optarg, &p, 0);
if (*p)
err("illegal seed value -- %s", optarg);
+ case 'U':
+ Uflag = 1;
+ uflag = 1;
+ break;
case 'u':
uflag = 1;
break;
@@ -140,13 +145,16 @@ main(argc, argv)
cwalk();
exit(0);
}
- exit(verify());
+ status = verify();
+ if (Uflag & (status == MISMATCHEXIT))
+ status = 0;
+ exit(status);
}
static void
usage()
{
(void)fprintf(stderr,
-"usage: mtree [-cdeinrux] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n");
+"usage: mtree [-cdeinrUux] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n");
exit(1);
}
OpenPOWER on IntegriCloud