Commit | Line | Data |
---|---|---|
1c3344a1 WD |
1 | #! /bin/sh |
2 | ||
3 | # This program is distributable under the terms of the GNU GPL (see | |
4 | # COPYING). | |
5 | ||
6 | # Test that rsync obeys default ACLs. -- Matt McCutchen | |
7 | ||
8 | . $srcdir/testsuite/rsync.fns | |
9 | ||
10 | $RSYNC --version | grep ", ACLs" >/dev/null || test_skipped "Rsync is configured without ACL support" | |
11 | ||
12 | case "$RSYNC" in | |
13 | *protocol=29*) test_skipped "ACLs require protocol 30" ;; | |
14 | esac | |
15 | ||
16 | case "$setfacl_nodef" in | |
17 | true) test_skipped "I don't know how to use your setfacl command" ;; | |
18 | *-k*) opts='-dm u::7,g::5,o:5' ;; | |
19 | *) opts='-m d:u::7,d:g::5,d:o:5' ;; | |
20 | esac | |
21 | setfacl $opts "$scratchdir" || test_skipped "Your filesystem has ACLs disabled" | |
22 | ||
23 | # Call as: testit <dirname> <default-acl> <file-expected> <program-expected> | |
24 | testit() { | |
25 | todir="$scratchdir/$1" | |
26 | mkdir "$todir" | |
27 | $setfacl_nodef "$todir" | |
28 | if [ "$2" ]; then | |
29 | case "$setfacl_nodef" in | |
30 | *-k*) opts="-dm $2" ;; | |
31 | *) opts="-m `echo $2 | sed 's/\([ugom]:\)/d:\1/g'`" | |
32 | esac | |
33 | setfacl $opts "$todir" | |
34 | fi | |
35 | # Make sure we obey ACLs when creating a directory to hold multiple transferred files, | |
36 | # even though the directory itself is outside the transfer | |
37 | $RSYNC -rvv "$scratchdir/dir" "$scratchdir/file" "$scratchdir/program" "$todir/to/" | |
38 | check_perms "$todir/to" $4 "Target $1" | |
39 | check_perms "$todir/to/dir" $4 "Target $1" | |
40 | check_perms "$todir/to/file" $3 "Target $1" | |
41 | check_perms "$todir/to/program" $4 "Target $1" | |
42 | # Make sure get_local_name doesn't mess us up when transferring only one file | |
43 | $RSYNC -rvv "$scratchdir/file" "$todir/to/anotherfile" | |
44 | check_perms "$todir/to/anotherfile" $3 "Target $1" | |
45 | # Make sure we obey default ACLs when not transferring a regular file | |
46 | $RSYNC -rvv "$scratchdir/dir/" "$todir/to/anotherdir/" | |
47 | check_perms "$todir/to/anotherdir" $4 "Target $1" | |
48 | } | |
49 | ||
50 | mkdir "$scratchdir/dir" | |
51 | echo "File!" >"$scratchdir/file" | |
52 | echo "#!/bin/sh" >"$scratchdir/program" | |
53 | chmod 777 "$scratchdir/dir" | |
54 | chmod 666 "$scratchdir/file" | |
55 | chmod 777 "$scratchdir/program" | |
56 | ||
57 | # Test some target directories | |
58 | umask 0077 | |
59 | testit da777 u::7,g::7,o:7 rw-rw-rw- rwxrwxrwx | |
60 | testit da775 u::7,g::7,o:5 rw-rw-r-- rwxrwxr-x | |
61 | testit da750 u::7,g::5,o:0 rw-r----- rwxr-x--- | |
62 | testit da770mask u::7,u:0:7,g::0,m:7,o:0 rw-rw---- rwxrwx--- | |
63 | testit noda1 '' rw------- rwx------ | |
64 | umask 0000 | |
65 | testit noda2 '' rw-rw-rw- rwxrwxrwx | |
66 | umask 0022 | |
67 | testit noda3 '' rw-r--r-- rwxr-xr-x | |
68 | ||
69 | # Hooray | |
70 | exit 0 |