summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-10-05 18:21:05 +0000
committerpeter <peter@FreeBSD.org>1996-10-05 18:21:05 +0000
commita066ea980049104c7ff84de7bae68af5416c54ed (patch)
treea47e0a27934bfbdeb76416a5cb27f91137d67683 /usr.bin/find
parent43846dc5784472c87d6462b79859b034b98824fb (diff)
downloadFreeBSD-src-a066ea980049104c7ff84de7bae68af5416c54ed.zip
FreeBSD-src-a066ea980049104c7ff84de7bae68af5416c54ed.tar.gz
For the -delete option, emulate the behavior of "rm -f" when dealing with
user-immutable files. Requested by: ache
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/function.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index d5bd5fa..5120113 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -963,6 +963,13 @@ f_delete(plan, entry)
errx(1, "-delete: %s: relative path potentially not safe",
entry->fts_accpath);
+ /* Turn off user immutable bits if running as root */
+ if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
+ !(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
+ geteuid() == 0)
+ chflags(entry->fts_accpath,
+ entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
+
/* rmdir directories, unlink everything else */
if (S_ISDIR(entry->fts_statp->st_mode)) {
if (rmdir(entry->fts_accpath) < 0)
OpenPOWER on IntegriCloud