1#!/bin/sh 2# Ensure that rm works even when run from a directory 3# for which the user has no access at all. 4 5# Copyright (C) 2004-2023 Free Software Foundation, Inc. 6 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. 11 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. 16 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/>. 19 20. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 21print_ver_ rm 22 23# Skip this test if your system has neither the openat-style functions 24# nor /proc/self/fd support with which to emulate them. 25require_openat_support_ 26skip_if_root_ 27 28p=$(pwd) 29mkdir abs1 abs2 no-access || framework_failure_ 30 31 32set +x 33(cd no-access; chmod 0 . && rm -r "$p/abs1" rel "$p/abs2") 2> out && fail=1 34test -d "$p/abs1" && fail=1 35test -d "$p/abs2" && fail=1 36 37cat <<\EOF > exp || framework_failure_ 38rm: cannot remove 'rel': Permission denied 39EOF 40 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: 45sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out 46 47compare exp out || fail=1 48 49Exit $fail 50