Skip to content

Commit

Permalink
tests/path.sh: if root, skip tests involving unreadable scripts
Browse files Browse the repository at this point in the history
These always fail when running as root, as root can access files
regardless of permission bits.

(cherry picked from commit a821fe13906ac8ef56162bebd7c3e976b973f91c)
  • Loading branch information
McDutchie committed Jun 11, 2020
1 parent 62f8e74 commit 6e90d4d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cmd/ksh93/tests/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e90d4d

Please sign in to comment.