Diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0302-home-access.sh | 20 |
1 file changed, 18 insertions, 2 deletions
diff --git a/tests/t0302-home-access.sh b/tests/t0302-home-access.sh index 0c0fcd2..3d49deb 100755 --- a/tests/t0302-home-access.sh +++ b/tests/t0302-home-access.sh @@ -22,14 +22,30 @@ test_have_prereq STRACE || { test_done } +# Valgrind reads a .valgrindrc from the home directory itself, and strace +# would follow it there. +test -z "$CGIT_TEST_VALGRIND" || { + skip_all='Skipping access validation tests: strace would trace valgrind' + test_done +} + +# cgit unsets HOME before git starts, so a read that fell back on the home +# directory in the password database would name that one instead. +passwd_home=$(getent passwd "$(id -u)" 2>/dev/null | cut -d: -f6) + +# The page has to render, as a request that fails early opens fewer files, and +# the config cgit was handed shows that its calls made it into the trace. test_no_home_access() { missing_home=/path/to/some/place/that/does/not/possibly/exist && strace \ -E HOME="$missing_home" \ -E CGIT_CONFIG="$PWD/cgitrc" \ -E QUERY_STRING="url=$1" \ - -e trace=%file -f -o strace.out cgit && - ! grep "$missing_home" strace.out + -e trace=%file -f -o strace.out cgit >page && + grep "^Status: 200" page && + grep -F "\"$PWD/cgitrc\"" strace.out && + ! grep "$missing_home" strace.out && + { test -z "$passwd_home" || ! grep -F "\"$passwd_home/." strace.out; } } test_no_home_access_success() { |
