tests/t0109-gitconfig.sh (view raw)
1#!/bin/sh
2
3test_description='Ensure that git does not access $HOME'
4. ./setup.sh
5
6test -n "$(which strace 2>/dev/null)" || {
7 skip_all='Skipping access validation tests: strace not found'
8 test_done
9 exit
10}
11
12strace true 2>/dev/null || {
13 skip_all='Skipping access validation tests: strace not functional'
14 test_done
15 exit
16}
17
18test_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
31test_no_home_access_success() {
32 test_expect_success "do not access \$HOME: $1" "
33 test_no_home_access '$1'
34 "
35}
36
37test_no_home_access_success
38test_no_home_access_success foo
39test_no_home_access_success foo/refs
40test_no_home_access_success foo/log
41test_no_home_access_success foo/tree
42test_no_home_access_success foo/tree/file-1
43test_no_home_access_success foo/commit
44test_no_home_access_success foo/diff
45test_no_home_access_success foo/patch
46test_no_home_access_success foo/snapshot/master.tar.gz
47
48test_done