mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-18 05:53:36 +01:00
For the -delete option, emulate the behavior of "rm -f" when dealing with
user-immutable files. Requested by: ache
This commit is contained in:
parent
afb3e96f8a
commit
242ab807c6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18713
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user