From 9febe910b6c1df9c52c5b0fbbb30e4ac410086fb Mon Sep 17 00:00:00 2001 From: James Farrell Date: Tue, 24 May 2022 15:44:09 +0000 Subject: [PATCH] Handle test.test being run as root. Root always has read and write access. Tested with `sudo make test_test` --- tests/test.test | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test.test b/tests/test.test index 1ea527138..6a859e139 100644 --- a/tests/test.test +++ b/tests/test.test @@ -47,11 +47,13 @@ touch walrus MASK=111 for i in x w r k g u; do [ $i == k ] && MASK=1000 + XX=no + [ $UID -eq 0 ] && [ $i == r -o $i == w ] && XX=yes # Root always has access # test everything off produces "off" chmod 000 walrus - testcmd "-$i 0" "-$i walrus || echo yes" "yes\n" "" "" + testcmd "-$i 0" "-$i walrus && echo yes || echo no" "$XX\n" "" "" chmod $((7777-$MASK)) walrus - testcmd "-$i inverted" "-$i walrus || echo yes" "yes\n" "" "" + testcmd "-$i inverted" "-$i walrus && echo yes || echo no" "$XX\n" "" "" MASK=$(($MASK<<1)) done unset MASK @@ -63,6 +65,7 @@ for i in uu+s gg+s k+t; do done # test each ugo+rwx bit position individually XX=no +[ $UID -eq 0 ] && XX=yes # Root always has access for i in 1 10 100; do for j in x w r; do chmod $i walrus