On some systems (see unlinkdir.m4[1] for the list), GNU rm takes
advantage of "knowing" that unlink ("directory") will always fail,
and thus avoids a race condition.
However, in all post-6.9 snapshots and in coreutils-6.9.90, the uglier code
that is used only on other systems has a bug that made it impossible to
remove a non-directory as root.
[1] If you know of a system not mentioned in this macro and on which
unlink ("directory") is guaranteed to fail, please tell [EMAIL PROTECTED]
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=m4/unlinkdir.m4
Here's the patch:
"rm" as root would fail to unlink a non-directory on OS X 10.4.x
* src/remove.c (remove_entry) ["can unlink directories"]: Fix a
mistakenly reversed condition.
* NEWS: Mention this bug fix.
Reported by Pieter Bowman.
---
ChangeLog | 8 ++++++++
NEWS | 4 ++++
THANKS | 1 +
src/remove.c | 2 +-
4 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9686a6..d2f2f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-12-09 Jim Meyering <[EMAIL PROTECTED]>
+
+ "rm" as root would fail to unlink a non-directory on OS X 10.4.x
+ * src/remove.c (remove_entry) ["can unlink directories"]: Fix a
+ mistakenly reversed condition.
+ * NEWS: Mention this bug fix.
+ Reported by Pieter Bowman.
+
2007-12-08 Jim Meyering <[EMAIL PROTECTED]>
* src/c99-to-c89.diff: Adjust shred.c offsets.
diff --git a/NEWS b/NEWS
index c6a0511..e5e59a6 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ GNU coreutils NEWS -*-
outline -*-
* Noteworthy changes in release 6.9.91 (????-??-??) [beta]
+ "rm" would fail to unlink a non-directory when run in an environment
+ in which the user running rm is capable of unlinking a directory.
+ [bug introduced in coreutils-6.9]
+
* Noteworthy changes in release 6.9.90 (2007-12-01) [beta]
diff --git a/THANKS b/THANKS
index 0b0124b..f91c262 100644
--- a/THANKS
+++ b/THANKS
@@ -424,6 +424,7 @@ Philippe De Muyter [EMAIL PROTECTED]
Philippe Schnoebelen [EMAIL PROTECTED]
Phillip Jones [EMAIL PROTECTED]
Piergiorgio Sartor [EMAIL PROTECTED]
+Pieter Bowman [EMAIL PROTECTED]
Piotr Kwapulinski [EMAIL PROTECTED]
Prashant TR [EMAIL PROTECTED]
Rainer Orth [EMAIL PROTECTED]
diff --git a/src/remove.c b/src/remove.c
index 11e2ccb..de8f5ff 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -1150,7 +1150,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char
const *filename,
dirent_type = DT_DIR;
}
- if (dirent_type == DT_DIR)
+ if (dirent_type != DT_DIR)
{
/* At this point, barring race conditions, FILENAME is known
to be a non-directory, so it's ok to try to unlink it. */
--
1.5.3.7.1116.gae2a9
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils