Add -U option which does the same things as -u except exits with 0

instead of 2 on MISMATCH.
This commit is contained in:
Rodney W. Grimes 1994-10-09 20:28:31 +00:00
parent 3156bbb2d1
commit 4ac2ef542b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3468
2 changed files with 24 additions and 6 deletions

View File

@ -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

View File

@ -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);
}