1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

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)
This commit is contained in:
Martijn Dekker 2020-05-24 23:39:02 +01:00
parent 62f8e744f1
commit 6e90d4d76c

View file

@ -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