summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-09-22 10:02:09 +0200
committerJim Meyering <jim@meyering.net>2007-09-22 13:27:57 +0200
commita7ec8caffe1a48590f5e3da9400080ab8a6ec303 (patch)
tree2f60406ee7f34139c53def242c7bf89005074761 /tests
parent920b4416c147ecb76731137158da8bcc9041fecd (diff)
downloadcoreutils-a7ec8caffe1a48590f5e3da9400080ab8a6ec303.tar.xz
rm: give a sensible diagnostic when failing to remove a symlink
On some systems (those with openat et al), when rm would fail to remove a symlink, it would fail with the misleading diagnostic, "Too many levels of symbolic links". * NEWS: Mention the bug fix. * src/remove.c (is_nondir_lstat): New function. (remove_entry): Use it to catch failed-to-remove symlink (and any other non-dir) here so that we don't fall through and try to treat it as directory, which -- with a symlink -- would provoke the bogus ELOOP failure. * tests/rm/fail-eacces: Add a test for the above. * src/c99-to-c89.diff: Adjust offsets.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/rm/fail-eacces23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/rm/fail-eacces b/tests/rm/fail-eacces
index b15c2f544..d49764c53 100755
--- a/tests/rm/fail-eacces
+++ b/tests/rm/fail-eacces
@@ -1,5 +1,8 @@
#!/bin/sh
# Ensure that rm -rf unremovable-non-dir gives a diagnostic.
+# Test both a regular file and a symlink -- it makes a difference to rm.
+# With the symlink, rm from coreutils-6.9 would fail with a misleading
+# ELOOP diagnostic.
# Copyright (C) 2006-2007 Free Software Foundation, Inc.
@@ -25,7 +28,19 @@ fi
. $srcdir/../test-lib.sh
skip_if_root_
-mkdir d && touch d/f && chmod a-w d || framework_failure
+ok=0
+mkdir d &&
+ touch d/f &&
+ ln -s f d/slink &&
+ chmod a-w d &&
+ ok=1
+test $ok = 1 || framework_failure
+
+mkdir e &&
+ ln -s f e/slink &&
+ chmod a-w e &&
+ ok=1
+test $ok = 1 || framework_failure
fail=0
@@ -33,7 +48,13 @@ rm -rf d/f 2> out && fail=1
cat <<\EOF > exp
rm: cannot remove `d/f': Permission denied
EOF
+compare out exp || fail=1
+# This used to fail with ELOOP.
+rm -rf e 2> out && fail=1
+cat <<\EOF > exp
+rm: cannot remove `e/slink': Permission denied
+EOF
compare out exp || fail=1
(exit $fail); exit $fail