]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: skip some parts of 'tests/rmdir/ignore.sh' if run as root
authorBernhard Voelker <mail@bernhard-voelker.de>
Fri, 31 Jul 2020 17:49:35 +0000 (19:49 +0200)
committerBernhard Voelker <mail@bernhard-voelker.de>
Fri, 31 Jul 2020 17:49:35 +0000 (19:49 +0200)
Parts of this test expect that the rmdir syscall returns with EPERM,
but the root user does not see that.

* tests/rmdir/ignore.sh: Add uid_is_privileged_ guards around parts
of the test which expect rmdir() to fail with EPERM.

Reported by Nick Alcock <nix@esperi.org.uk> in
https://bugs.gnu.org/42633

tests/rmdir/ignore.sh

index 65e92d012c21d689d6babbc5f278812a43f2238b..b26ac533ab2d6dba327ecb431dea331703603fc4 100755 (executable)
@@ -33,17 +33,24 @@ test -d "$cwd/a/b/c" && fail=1
 # Between 6.11 and 8.31, the following rmdir would mistakenly succeed.
 mkdir -p x/y || framework_failure_
 chmod a-w x || framework_failure_
-returns_ 1 rmdir --ignore-fail-on-non-empty x/y || fail=1
+
+if ! uid_is_privileged_; then  # root does not get EPERM.
+  returns_ 1 rmdir --ignore-fail-on-non-empty x/y || fail=1
+fi
+
 test -d x/y || fail=1
 # Between 6.11 and 8.31, the following rmdir would mistakenly fail,
 # and also give a non descript error
 touch x/y/z || framework_failure_
 rmdir --ignore-fail-on-non-empty x/y || fail=1
 test -d x/y || fail=1
-# assume empty dir if unreadable entries (so failure to remove diagnosed)
-rm x/y/z || framework_failure_
-chmod a-r x/y || framework_failure_
-returns_ 1 rmdir --ignore-fail-on-non-empty x/y || fail=1
-test -d x/y || fail=1
+
+if ! uid_is_privileged_; then  # root does not get EPERM.
+  # assume empty dir if unreadable entries (so failure to remove diagnosed)
+  rm x/y/z || framework_failure_
+  chmod a-r x/y || framework_failure_
+  returns_ 1 rmdir --ignore-fail-on-non-empty x/y || fail=1
+  test -d x/y || fail=1
+fi
 
 Exit $fail