dir-sgid.test 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #! /bin/sh
  2. # This program is distributable under the terms of the GNU GPL (see
  3. # COPYING).
  4. # Test that rsync obeys directory setgid. -- Matt McCutchen
  5. . $srcdir/testsuite/rsync.fns
  6. umask 077
  7. # Call as: testit <dirname> <dirperms> <file-expected> <program-expected> <dir-expected>
  8. testit() {
  9. todir="$scratchdir/$1"
  10. mkdir "$todir"
  11. chmod $2 "$todir"
  12. # Make sure we obey directory setgid when creating a directory to hold multiple transferred files,
  13. # even though the directory itself is outside the transfer
  14. $RSYNC -rvv "$scratchdir/dir" "$scratchdir/file" "$scratchdir/program" "$todir/to/"
  15. check_perms "$todir/to" $5 "Target $1"
  16. check_perms "$todir/to/dir" $5 "Target $1"
  17. check_perms "$todir/to/file" $3 "Target $1"
  18. check_perms "$todir/to/program" $4 "Target $1"
  19. }
  20. echo "File!" >"$scratchdir/file"
  21. echo "#!/bin/sh" >"$scratchdir/program"
  22. mkdir "$scratchdir/dir"
  23. chmod 2764 "$scratchdir/dir" || test_skipped "Can't chmod"
  24. chmod 664 "$scratchdir/file"
  25. chmod 775 "$scratchdir/program"
  26. [ -g "$scratchdir/dir" ] || test_skipped "The directory setgid bit vanished!"
  27. mkdir "$scratchdir/dir/blah"
  28. [ -g "$scratchdir/dir/blah" ] || test_skipped "Your filesystem doesn't use directory setgid; maybe it's BSD."
  29. # Test some target directories
  30. testit setgid-off 700 rw------- rwx------ rwx------
  31. testit setgid-on 2700 rw------- rwx------ rwx--S---
  32. # Hooray
  33. exit 0