blob: 8cee75cd00b3a2a947b238263b24fa80cd4da417 [file] [log] [blame]
Jason A. Donenfelddd1f0e52013-04-08 22:18:21 +02001#!/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
Christian Hesseca98c9e2019-12-11 10:55:24 +010012strace true 2>/dev/null || {
13 skip_all='Skipping access validation tests: strace not functional'
14 test_done
15 exit
16}
17
John Keeping64f30682013-04-14 17:07:41 +010018test_no_home_access () {
Ville Skyttä67d0f872017-10-14 22:05:51 +030019 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 Keeping64f30682013-04-14 17:07:41 +010022 done &&
Jason A. Donenfelddd1f0e52013-04-08 22:18:21 +020023 strace \
Ville Skyttä67d0f872017-10-14 22:05:51 +030024 -E HOME="$non_existent_path" \
Jason A. Donenfelddd1f0e52013-04-08 22:18:21 +020025 -E CGIT_CONFIG="$PWD/cgitrc" \
John Keeping64f30682013-04-14 17:07:41 +010026 -E QUERY_STRING="url=$1" \
John Keeping880223d2013-04-10 13:11:57 +010027 -e access -f -o strace.out cgit &&
Ville Skyttä67d0f872017-10-14 22:05:51 +030028 test_must_fail grep "$non_existent_path" strace.out
John Keeping64f30682013-04-14 17:07:41 +010029}
30
John Keeping7966fd92013-05-09 19:40:58 +010031test_no_home_access_success() {
John Keeping64f30682013-04-14 17:07:41 +010032 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
Jason A. Donenfeld8bf4a042013-04-30 12:27:41 +020046test_no_home_access_success foo/snapshot/master.tar.gz
Jason A. Donenfelddd1f0e52013-04-08 22:18:21 +020047
48test_done