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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/usr/bin/env bash
. wvtest.sh
. wvtest-bup.sh
. dev/lib.sh
set -o pipefail
if ! command -v getfacl > /dev/null || ! command -v setfacl > /dev/null; then
WVSKIP "No getfacl and setfacl; skipping test-meta-acls"
exit 0
fi
top="$(WVPASS pwd)" || exit $?
bup() { "$top/bup" "$@"; }
compare-trees() { "$top/dev/compare-trees" "$@"; }
id-other-than() { "$top/dev/id-other-than" "$@"; }
if ! bup features | grep -qi 'posix acls: yes'; then
WVSKIP "bup features missing POSIX ACLs; skipping test-meta-acls"
exit 0
fi
if ! compare-trees --features | grep -qi 'posix acls: yes'; then
WVSKIP "compare-trees --features missing POSIX ACLs; skipping test-meta-acls"
exit 0
fi
tmpdir="$(WVPASS wvmktempdir)" || exit $?
bup_dir="$tmpdir/bup"
export BUP_DIR="$bup_dir"
uid=$(WVPASS id -un) || exit $?
other_uinfo="$(id-other-than --user "$uid")" || exit $?
other_user="${other_uinfo%%:*}"
other_uid="${other_uinfo##*:}"
gid=$(WVPASS id -gn) || exit $?
other_ginfo="$(id-other-than --group "$gid")" || exit $?
other_group="${other_ginfo%%:*}"
other_gid="${other_ginfo##*:}"
WVPASS cd "$tmpdir"
WVPASS mkdir src
WVPASS touch src/u-r
if ! setfacl -m "u:$other_user:r" src/u-r; then
WVSKIP "setfacl $top/testfile failed; skipping test-meta-acls"
exit 0
fi
WVSTART "Basic ACL support (setup)"
# file ACL_USER access acl(5)
for perm in r rw rwx; do
WVPASS touch src/u-"$perm"
WVPASS setfacl -m "u:$other_user:$perm" src/u-"$perm"
done
# file ACL_GROUP access acl(5)
for perm in r rw rwx; do
WVPASS touch src/g-"$perm"
WVPASS setfacl -m "g:$other_group:$perm" src/g-"$perm"
done
# directory ACL_USER access acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-u-"$perm"
WVPASS setfacl -m "u:$other_user:$perm" src/d-u-"$perm"
done
# directory ACL_GROUP access acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-g-"$perm"
WVPASS setfacl -m "g:$other_group:$perm" src/d-g-"$perm"
done
# directory ACL_USER default acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-def-u-"$perm"
WVPASS setfacl -d -m "u:$other_user:$perm" src/d-def-u-"$perm"
done
# directory ACL_GROUP default acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-def-g-"$perm"
WVPASS setfacl -d -m "g:$other_group:$perm" src/d-def-g-"$perm"
done
# directory ACL_USER access and default acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-both-u-"$perm"
WVPASS setfacl -m "u:$other_user:$perm" src/d-both-u-"$perm"
WVPASS setfacl -d -m "u:$other_user:$perm" src/d-both-u-"$perm"
done
# directory ACL_GROUP access and default acl(5)
for perm in r rw rwx; do
WVPASS mkdir src/d-both-g-"$perm"
WVPASS setfacl -m "g:$other_group:$perm" src/d-both-g-"$perm"
WVPASS setfacl -d -m "g:$other_group:$perm" src/d-both-g-"$perm"
done
test-save-restore()
{
WVPASS test "$#" -eq 2
local saver="$1" restorer="$2"
WVPASS rm -rf "$bup_dir" dest
WVPASS "$saver" init
WVPASS "$saver" index -u src
WVPASS "$saver" save --strip -n acls src
WVPASS "$restorer" restore -C dest acls/latest/.
WVPASS compare-trees src/ dest/
}
WVSTART "Basic ACL support (save and restore)"
test-save-restore bup bup
if test -z "$BUP_TEST_OTHER_BUP"; then
# FIXME: need ability to "skip", without skipping this entire file
WVMSG 'BUP_TEST_OTHER_BUP not set; skipping cross-version test'
else
test-save-restore "$BUP_TEST_OTHER_BUP" bup
fi
cd "$top"
WVPASS rm -rf "$tmpdir"
|