2 # Ensure that rm works even when run from a directory
3 # for which the user has no access at all.
5 if test "$VERBOSE" = yes; then
10 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
11 . $srcdir/../lang-default
13 # Skip this test if your system has neither the openat-style functions
14 # nor /proc/self/fd support with which to emulate them.
16 grep '^#define HAVE_OPENAT' $top_srcdir/config.h > /dev/null && skip=no
17 test -d /proc/self/fd && skip=no
18 if test $skip = yes; then
19 echo 1>&2 "$0: no openat support, so skipping this test"
24 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
25 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
26 trap '(exit $?); exit $?' 1 2 13 15
29 mkdir -p $tmp || framework_failure=1
30 cd $tmp || framework_failure=1
31 mkdir abs1 abs2 no-access || framework_failure=1
33 if test $framework_failure = 1; then
34 echo "$0: failure in testing framework" 1>&2
42 (cd no-access; chmod 0 . && rm -r $p/abs1 rel $p/abs2) 2> out && fail=1
43 test -d $p/abs1 && fail=1
44 test -d $p/abs2 && fail=1
46 cat <<\EOF > exp || fail=1
47 rm: cannot remove `rel': Permission denied
50 # AIX 4.3.3 fails with a different diagnostic.
51 # Transform their diagnostic
52 # ...: The file access permissions do not allow the specified action.
53 # to the expected one:
54 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
57 test $fail = 1 && diff out exp 2> /dev/null
59 (exit $fail); exit $fail