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 handles basic ACL preservation. | |
7 | ||
8 | . $srcdir/testsuite/rsync.fns | |
9 | ||
10 | $RSYNC --version | grep ", ACLs" >/dev/null || test_skipped "Rsync is configured without ACL support" | |
11 | ||
1c3344a1 WD |
12 | makepath "$fromdir/foo" |
13 | echo something >"$fromdir/file1" | |
14 | echo else >"$fromdir/file2" | |
15 | ||
16 | files='foo file1 file2' | |
17 | ||
c50a9076 WD |
18 | case "$setfacl_nodef" in |
19 | true) | |
20 | if ! chmod --help 2>&1 | fgrep +a >/dev/null; then | |
21 | test_skipped "I don't know how to use setfacl or chmod for ACLs" | |
22 | fi | |
23 | chmod +a "root allow read,write,execute" "$fromdir/foo" || test_skipped "Your filesystem has ACLs disabled" | |
24 | chmod +a "root allow read,execute" "$fromdir/file1" | |
25 | chmod +a "admin allow read" "$fromdir/file1" | |
26 | chmod +a "daemon allow read,write" "$fromdir/file1" | |
27 | chmod +a "root allow read,execute" "$fromdir/file2" | |
28 | ||
29 | see_acls() { | |
30 | ls -le "${@}" | |
31 | } | |
32 | ;; | |
33 | *) | |
34 | setfacl -m u:0:7 "$fromdir/foo" || test_skipped "Your filesystem has ACLs disabled" | |
35 | setfacl -m g:1:5 "$fromdir/foo" | |
36 | setfacl -m g:2:1 "$fromdir/foo" | |
37 | setfacl -m g:0:7 "$fromdir/foo" | |
38 | setfacl -m u:2:1 "$fromdir/foo" | |
39 | setfacl -m u:1:5 "$fromdir/foo" | |
40 | ||
41 | setfacl -m u:0:5 "$fromdir/file1" | |
42 | setfacl -m g:0:4 "$fromdir/file1" | |
43 | setfacl -m u:1:6 "$fromdir/file1" | |
44 | ||
45 | setfacl -m u:0:5 "$fromdir/file2" | |
46 | ||
47 | see_acls() { | |
48 | getfacl "${@}" | |
49 | } | |
50 | ;; | |
51 | esac | |
1c3344a1 | 52 | |
1c3344a1 | 53 | cd "$fromdir" |
49f7162e WD |
54 | $RSYNC -avvA $files "$todir/" |
55 | ||
c50a9076 | 56 | see_acls $files >"$scratchdir/acls.txt" |
1c3344a1 WD |
57 | |
58 | cd "$todir" | |
c50a9076 | 59 | see_acls $files | diff $diffopt "$scratchdir/acls.txt" - |
1c3344a1 WD |
60 | |
61 | # The script would have aborted on error, so getting here means we've won. | |
62 | exit 0 |