From 6e90d4d76c0eae52dae64664e73397a42579741f Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Sun, 24 May 2020 23:39:02 +0100 Subject: [PATCH] tests/path.sh: if root, skip tests involving unreadable scripts These always fail when running as root, as root can access files regardless of permission bits. (cherry picked from commit a821fe13906ac8ef56162bebd7c3e976b973f91c) --- src/cmd/ksh93/tests/path.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmd/ksh93/tests/path.sh b/src/cmd/ksh93/tests/path.sh index 067e5443d..8c37e3a71 100755 --- a/src/cmd/ksh93/tests/path.sh +++ b/src/cmd/ksh93/tests/path.sh @@ -282,6 +282,10 @@ PATH=$path scr=$tmp/script exp=126 +if [[ $(id -u) == '0' ]]; then + print -u2 -r "${Command}[$LINENO]: warning: running as root: skipping tests involving unreadable scripts" +else + : > $scr chmod a=x $scr { got=$($scr; print $?); } 2>/dev/null @@ -309,6 +313,8 @@ got=$($SHELL -c "$scr; print \$?" 2>/dev/null) got=$($SHELL -c "command $scr; print \$?" 2>/dev/null) [[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of command of unreadable non-empty script should fail -- expected $exp, got" $got +fi # if [[ $(id -u) == '0' ]] + # whence -a bug fix cd "$tmp" ifs=$IFS