]> gitweb.ps.run Git - ps-cgit/blob - tests/t0109-gitconfig.sh
git: update to v2.46.0
[ps-cgit] / tests / t0109-gitconfig.sh
1 #!/bin/sh
2
3 test_description='Ensure that git does not access $HOME'
4 . ./setup.sh
5
6 test -n "$(which strace 2>/dev/null)" || {
7         skip_all='Skipping access validation tests: strace not found'
8         test_done
9         exit
10 }
11
12 strace true 2>/dev/null || {
13         skip_all='Skipping access validation tests: strace not functional'
14         test_done
15         exit
16 }
17
18 test_no_home_access () {
19         non_existent_path="/path/to/some/place/that/does/not/possibly/exist"
20         while test -d "$non_existent_path"; do
21                 non_existent_path="$non_existent_path/$(date +%N)"
22         done &&
23         strace \
24                 -E HOME="$non_existent_path" \
25                 -E CGIT_CONFIG="$PWD/cgitrc" \
26                 -E QUERY_STRING="url=$1" \
27                 -e access -f -o strace.out cgit &&
28         ! grep "$non_existent_path" strace.out
29 }
30
31 test_no_home_access_success() {
32         test_expect_success "do not access \$HOME: $1" "
33                 test_no_home_access '$1'
34         "
35 }
36
37 test_no_home_access_success
38 test_no_home_access_success foo
39 test_no_home_access_success foo/refs
40 test_no_home_access_success foo/log
41 test_no_home_access_success foo/tree
42 test_no_home_access_success foo/tree/file-1
43 test_no_home_access_success foo/commit
44 test_no_home_access_success foo/diff
45 test_no_home_access_success foo/patch
46 test_no_home_access_success foo/snapshot/master.tar.gz
47
48 test_done