From f77a6352fbc2bfb7b62bcf7dcd42d053b7a556c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Sun, 24 Mar 2024 19:46:57 +0000 Subject: [PATCH] test: avoid false failure with setgid directories * tests/chmod/symlinks.sh: Ensure this new test is immune to setgid directories by resetting modes with =777 rather than 777. Also output more debugging in all failure cases. --- tests/chmod/symlinks.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/chmod/symlinks.sh b/tests/chmod/symlinks.sh index 815e8fb5c..0bb6be0b1 100755 --- a/tests/chmod/symlinks.sh +++ b/tests/chmod/symlinks.sh @@ -40,40 +40,42 @@ ln -s b a/dirlink || framework_failure_ # |-- dangle -> foo # '-- dirlink -> b/ -reset_modes() { chmod 777 a/b a/c a/b/file a/c/file || fail=1; } -count_755() { test "$(grep 'rwxr-xr-x' 'out' | wc -l)" = "$1"; } +reset_modes() { chmod =777 a/b a/c a/b/file a/c/file || fail=1; } +count_755() { + test "$(grep 'rwxr-xr-x' 'out' | wc -l)" = "$1" || { cat out; fail=1; } +} reset_modes # -R (with default -H) does not deref traversed symlinks (only cli args) chmod 755 -R a/c || fail=1 ls -l a/b > out || framework_failure_ -count_755 0 || fail=1 +count_755 0 ls -lR a/c > out || framework_failure_ -count_755 1 || fail=1 +count_755 1 reset_modes # set a/c a/c/file and a/b/file (through symlink) to 755 chmod 755 -LR a/c || fail=1 ls -ld a/c a/c/file a/b/file > out || framework_failure_ -count_755 3 || { cat out; fail=1; } +count_755 3 reset_modes # do not set /a/b/file through symlink (should try to chmod the link itself) chmod 755 -RP a/c/ || fail=1 ls -l a/b > out || framework_failure_ -count_755 0 || fail=1 +count_755 0 reset_modes # set /a/b/file through symlink chmod 755 --dereference a/c/link || fail=1 ls -l a/b > out || framework_failure_ -count_755 1 || fail=1 +count_755 1 reset_modes # do not set /a/b/file through symlink (should try to chmod the link itself) chmod 755 --no-dereference a/c/link 2>err || fail=1 ls -l a/b > out || framework_failure_ -count_755 0 || fail=1 +count_755 0 # Dangling links should not induce an error if not dereferencing for noderef in '-h' '-RP' '-P'; do -- 2.11.4.GIT