HardenedBSD/usr.sbin/mtree
Bruce Evans 6f4640cac6 Use p->fts_level instead of unsuccessfully trying to keep track of the
level ourself.  We failed for unreadable directories.  E.g.,
`mtree -d -f /etc/mtree/BSD.usr.dist -p /usr' run by `nobody' was
confused after it couldn't descend into /usr/games/hide.  It looked
for /usr/include and subsequent directories in /usr/games.

Don't search for `extra' files when the spec depth is less than the
fts level.  The spec depth isn't incremented for leaf nodes because
that would give a NULL level pointer and make it inconvenient to go
back to the parent level.  Leaf nodes are built for directories that
are empty in the spec.  Since they are empty in the spec, all files
in them are extra.  The search looked for files one spec level
too high, so for `mtree -d -f /etc/mtree/BSD.usr.dist -p /usr',
obj/sbin matched ./sbin and wasn't considered extra, so it was
descended into and lots of bogus extra things in it were found.
This was harmful for `mtree -U' (as reported in pr623) and worse
for `mtree -r'.

Use rmdir(), not unlink(), to remove `extra' directories.  unlink()
succeeds for root but unlinking directories normally damages the
file system.

Report `fts_errno' instead of `errno' when the former applies.
1995-07-24 02:52:42 +00:00
..
compare.c Fix to match new MD5 api, faster. 1995-07-12 09:15:15 +00:00
create.c Report fts_errno' instead of errno' when the former applies. 1995-07-24 02:50:50 +00:00
extern.h
Makefile
misc.c
mtree.8
mtree.c
mtree.h
spec.c Remove trailing whitespace. 1995-05-30 03:57:47 +00:00
verify.c Use p->fts_level instead of unsuccessfully trying to keep track of the 1995-07-24 02:52:42 +00:00