]>
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 | ||
12 | . ./test-lib.sh | |
13 | ||
14 | # We need an arbitrary other user give permission to using ACLs. root | |
15 | # is a good candidate: exists on all unices, and it has permission | |
16 | # anyway, so we don't create a security hole running the testsuite. | |
17 | ||
18 | if ! setfacl -m u:root:rwx .; then | |
19 | say "Skipping ACL tests: unable to use setfacl" | |
20 | test_done | |
21 | fi | |
22 | ||
7aba6185 | 23 | check_perms_and_acl () { |
71c4d6c6 | 24 | test -r "$1" && |
7aba6185 MM |
25 | getfacl "$1" > actual && |
26 | grep -q "user:root:rwx" actual && | |
27 | grep -q "user:${LOGNAME}:rwx" actual && | |
80700fde | 28 | egrep "mask::?r--" actual > /dev/null 2>&1 && |
7aba6185 MM |
29 | grep -q "group::---" actual || false |
30 | } | |
31 | ||
32 | dirs_to_set="./ .git/ .git/objects/ .git/objects/pack/" | |
33 | ||
34 | test_expect_success 'Setup test repo' ' | |
ab04a905 | 35 | setfacl -m d:u::rwx,d:g::---,d:o:---,d:m:rwx $dirs_to_set && |
2e85575a | 36 | setfacl -m m:rwx $dirs_to_set && |
7aba6185 | 37 | setfacl -m u:root:rwx $dirs_to_set && |
db826571 BC |
38 | setfacl -m d:u:"$LOGNAME":rwx $dirs_to_set && |
39 | setfacl -m d:u:root:rwx $dirs_to_set && | |
7aba6185 MM |
40 | |
41 | touch file.txt && | |
42 | git add file.txt && | |
43 | git commit -m "init" | |
44 | ' | |
45 | ||
5256b006 | 46 | test_expect_success 'Objects creation does not break ACLs with restrictive umask' ' |
7aba6185 MM |
47 | # SHA1 for empty blob |
48 | check_perms_and_acl .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 | |
49 | ' | |
50 | ||
f80c7ae8 | 51 | test_expect_success 'git gc does not break ACLs with restrictive umask' ' |
7aba6185 MM |
52 | git gc && |
53 | check_perms_and_acl .git/objects/pack/*.pack | |
54 | ' | |
55 | ||
56 | test_done |