default-acls.test 2.2 KB

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