File: acls.test

package info (click to toggle)
rsync 3.4.1%2Bds1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,388 kB
  • sloc: ansic: 35,682; sh: 6,538; python: 1,759; asm: 829; perl: 479; makefile: 365; cpp: 298; awk: 191
file content (62 lines) | stat: -rw-r--r-- 1,653 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh

# This program is distributable under the terms of the GNU GPL (see
# COPYING).

# Test that rsync handles basic ACL preservation.

. $suitedir/rsync.fns

$RSYNC -VV | grep '"ACLs": true' >/dev/null || test_skipped "Rsync is configured without ACL support"

makepath "$fromdir/foo"
echo something >"$fromdir/file1"
echo else >"$fromdir/file2"

files='foo file1 file2'

case "$setfacl_nodef" in
true)
    if ! chmod --help 2>&1 | grep -F +a >/dev/null; then
        test_skipped "I don't know how to use setfacl or chmod for ACLs"
    fi
    chmod +a "root allow read,write,execute" "$fromdir/foo" || test_skipped "Your filesystem has ACLs disabled"
    chmod +a "root allow read,execute" "$fromdir/file1"
    chmod +a "admin allow read" "$fromdir/file1"
    chmod +a "daemon allow read,write" "$fromdir/file1"
    chmod +a "root allow read,execute" "$fromdir/file2"

    see_acls() {
        ls -le "${@}"
    }
    ;;
*)
    setfacl -m u:0:7 "$fromdir/foo" || test_skipped "Your filesystem has ACLs disabled"
    setfacl -m g:1:5 "$fromdir/foo"
    setfacl -m g:2:1 "$fromdir/foo"
    setfacl -m g:0:7 "$fromdir/foo"
    setfacl -m u:2:1 "$fromdir/foo"
    setfacl -m u:1:5 "$fromdir/foo"

    setfacl -m u:0:5 "$fromdir/file1"
    setfacl -m g:0:4 "$fromdir/file1"
    setfacl -m u:1:6 "$fromdir/file1"

    setfacl -m u:0:5 "$fromdir/file2"

    see_acls() {
        getfacl "${@}"
    }
    ;;
esac

cd "$fromdir"
$RSYNC -avvA $files "$todir/"

see_acls $files >"$scratchdir/acls.txt"

cd "$todir"
see_acls $files | diff $diffopt "$scratchdir/acls.txt" -

# The script would have aborted on error, so getting here means we've won.
exit 0