summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-05-30 10:42:19 +0000
committerjilles <jilles@FreeBSD.org>2009-05-30 10:42:19 +0000
commit9e525699071499305398712042b790258045155c (patch)
tree3dfefb2df35d23badced6800689e6082c7652801
parentb0b0c85b53c56817fa1eed3bbb233fe5de5d4759 (diff)
downloadFreeBSD-src-9e525699071499305398712042b790258045155c.zip
FreeBSD-src-9e525699071499305398712042b790258045155c.tar.gz
rm, find -delete: fix removing symlinks with uchg/uappnd set.
Formerly, this tried to clear the flags on the symlink's target instead of the symlink itself. As before, this only happens for root or for the unlink(1) variant of rm. PR: bin/111226 (part of) Submitted by: Martin Kammerhofer Approved by: ed (mentor) MFC after: 3 weeks
-rw-r--r--bin/rm/rm.c6
-rw-r--r--usr.bin/find/function.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index f9316bc..d9bd296 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -234,7 +234,7 @@ rm_tree(char **argv)
else if (!uid &&
(p->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(p->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
- chflags(p->fts_accpath,
+ lchflags(p->fts_accpath,
p->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE)) < 0)
goto err;
continue;
@@ -253,7 +253,7 @@ rm_tree(char **argv)
if (!uid &&
(p->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(p->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)))
- rval = chflags(p->fts_accpath,
+ rval = lchflags(p->fts_accpath,
p->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
if (rval == 0) {
/*
@@ -368,7 +368,7 @@ rm_file(char **argv)
if (!uid && !S_ISWHT(sb.st_mode) &&
(sb.st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(sb.st_flags & (SF_APPEND|SF_IMMUTABLE)))
- rval = chflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE));
+ rval = lchflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE));
if (rval == 0) {
if (S_ISWHT(sb.st_mode))
rval = undelete(f);
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 2641264..bfa0a36 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -443,7 +443,7 @@ f_delete(PLAN *plan __unused, FTSENT *entry)
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,
+ lchflags(entry->fts_accpath,
entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
/* rmdir directories, unlink everything else */
OpenPOWER on IntegriCloud