Jason A. Donenfeld | dd1f0e5 | 2013-04-08 22:18:21 +0200 | [diff] [blame] | 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 | |
Christian Hesse | ca98c9e | 2019-12-11 10:55:24 +0100 | [diff] [blame^] | 12 | strace true 2>/dev/null || { |
| 13 | skip_all='Skipping access validation tests: strace not functional' |
| 14 | test_done |
| 15 | exit |
| 16 | } |
| 17 | |
John Keeping | 64f3068 | 2013-04-14 17:07:41 +0100 | [diff] [blame] | 18 | test_no_home_access () { |
Ville Skyttä | 67d0f87 | 2017-10-14 22:05:51 +0300 | [diff] [blame] | 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)" |
John Keeping | 64f3068 | 2013-04-14 17:07:41 +0100 | [diff] [blame] | 22 | done && |
Jason A. Donenfeld | dd1f0e5 | 2013-04-08 22:18:21 +0200 | [diff] [blame] | 23 | strace \ |
Ville Skyttä | 67d0f87 | 2017-10-14 22:05:51 +0300 | [diff] [blame] | 24 | -E HOME="$non_existent_path" \ |
Jason A. Donenfeld | dd1f0e5 | 2013-04-08 22:18:21 +0200 | [diff] [blame] | 25 | -E CGIT_CONFIG="$PWD/cgitrc" \ |
John Keeping | 64f3068 | 2013-04-14 17:07:41 +0100 | [diff] [blame] | 26 | -E QUERY_STRING="url=$1" \ |
John Keeping | 880223d | 2013-04-10 13:11:57 +0100 | [diff] [blame] | 27 | -e access -f -o strace.out cgit && |
Ville Skyttä | 67d0f87 | 2017-10-14 22:05:51 +0300 | [diff] [blame] | 28 | test_must_fail grep "$non_existent_path" strace.out |
John Keeping | 64f3068 | 2013-04-14 17:07:41 +0100 | [diff] [blame] | 29 | } |
| 30 | |
John Keeping | 7966fd9 | 2013-05-09 19:40:58 +0100 | [diff] [blame] | 31 | test_no_home_access_success() { |
John Keeping | 64f3068 | 2013-04-14 17:07:41 +0100 | [diff] [blame] | 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 |
Jason A. Donenfeld | 8bf4a04 | 2013-04-30 12:27:41 +0200 | [diff] [blame] | 46 | test_no_home_access_success foo/snapshot/master.tar.gz |
Jason A. Donenfeld | dd1f0e5 | 2013-04-08 22:18:21 +0200 | [diff] [blame] | 47 | |
| 48 | test_done |