]>
Commit | Line | Data |
---|---|---|
7aba6185 MM |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2010 Matthieu Moy | |
4 | # | |
5 | ||
6 | test_description='Test repository with default ACL' | |
7 | ||
8 | # Create the test repo with restrictive umask | |
9 | # => this must come before . ./test-lib.sh | |
10 | umask 077 | |
11 | ||
b2e5d75d | 12 | TEST_PASSES_SANITIZE_LEAK=true |
7aba6185 MM |
13 | . ./test-lib.sh |
14 | ||
15 | # We need an arbitrary other user give permission to using ACLs. root | |
16 | # is a good candidate: exists on all unices, and it has permission | |
17 | # anyway, so we don't create a security hole running the testsuite. | |
a14ad109 JK |
18 | test_expect_success 'checking for a working acl setup' ' |
19 | if setfacl -m d:m:rwx -m u:root:rwx . && | |
20 | getfacl . | grep user:root:rwx && | |
21 | touch should-have-readable-acl && | |
81580fa0 | 22 | getfacl should-have-readable-acl | grep -E "mask::?rw-" |
a14ad109 JK |
23 | then |
24 | test_set_prereq SETFACL | |
25 | fi | |
26 | ' | |
7aba6185 | 27 | |
ac2604cf RS |
28 | if test -z "$LOGNAME" |
29 | then | |
7544b2e2 | 30 | LOGNAME="${USER:-$(id -u -n)}" |
ac2604cf RS |
31 | fi |
32 | ||
7aba6185 | 33 | check_perms_and_acl () { |
71c4d6c6 | 34 | test -r "$1" && |
7aba6185 MM |
35 | getfacl "$1" > actual && |
36 | grep -q "user:root:rwx" actual && | |
37 | grep -q "user:${LOGNAME}:rwx" actual && | |
81580fa0 | 38 | grep -E "mask::?r--" actual > /dev/null 2>&1 && |
7aba6185 MM |
39 | grep -q "group::---" actual || false |
40 | } | |
41 | ||
42 | dirs_to_set="./ .git/ .git/objects/ .git/objects/pack/" | |
43 | ||
063b7e0c | 44 | test_expect_success SETFACL 'Setup test repo' ' |
ab04a905 | 45 | setfacl -m d:u::rwx,d:g::---,d:o:---,d:m:rwx $dirs_to_set && |
2e85575a | 46 | setfacl -m m:rwx $dirs_to_set && |
7aba6185 | 47 | setfacl -m u:root:rwx $dirs_to_set && |
db826571 BC |
48 | setfacl -m d:u:"$LOGNAME":rwx $dirs_to_set && |
49 | setfacl -m d:u:root:rwx $dirs_to_set && | |
7aba6185 MM |
50 | |
51 | touch file.txt && | |
52 | git add file.txt && | |
53 | git commit -m "init" | |
54 | ' | |
55 | ||
063b7e0c | 56 | test_expect_success SETFACL 'Objects creation does not break ACLs with restrictive umask' ' |
7aba6185 | 57 | # SHA1 for empty blob |
06d18bdf | 58 | check_perms_and_acl .git/objects/$(echo $EMPTY_BLOB | sed -e "s,^\(..\),\1/,") |
7aba6185 MM |
59 | ' |
60 | ||
063b7e0c | 61 | test_expect_success SETFACL 'git gc does not break ACLs with restrictive umask' ' |
7aba6185 MM |
62 | git gc && |
63 | check_perms_and_acl .git/objects/pack/*.pack | |
64 | ' | |
65 | ||
66 | test_done |