cksum: ensure appropriate "binary" mode with --untagged
[coreutils.git] / tests / rm / inaccessible.sh
blob71db8155a034a8172d492b0e2568e8bcd645a94f
1 #!/bin/sh
2 # Ensure that rm works even when run from a directory
3 # for which the user has no access at all.
5 # Copyright (C) 2004-2024 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
21 print_ver_ rm
23 # Skip this test if your system has neither the openat-style functions
24 # nor /proc/self/fd support with which to emulate them.
25 require_openat_support_
26 skip_if_root_
28 p=$(pwd)
29 mkdir abs1 abs2 no-access || framework_failure_
32 set +x
33 (cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1
34 test -d "$p/abs1" && fail=1
35 test -d "$p/abs2" && fail=1
37 cat <<\EOF > exp || framework_failure_
38 rm: cannot remove 'rel': Permission denied
39 EOF
41 # AIX 4.3.3 fails with a different diagnostic.
42 # Transform their diagnostic
43 # ...: The file access permissions do not allow the specified action.
44 # to the expected one:
45 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
47 compare exp out || fail=1
49 Exit $fail