acls.test 1.6 KB

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