chmod-option.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /bin/sh
  2. # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
  3. # This program is distributable under the terms of the GNU GPL (see
  4. # COPYING).
  5. # Test that the --chmod option functions correctly.
  6. . $srcdir/testsuite/rsync.fns
  7. # Build some files
  8. fromdir="$scratchdir/from"
  9. todir="$scratchdir/to"
  10. checkdir="$scratchdir/check"
  11. mkdir "$fromdir"
  12. name1="$fromdir/name1"
  13. name2="$fromdir/name2"
  14. dir1="$fromdir/dir1"
  15. dir2="$fromdir/dir2"
  16. echo "This is the file" > "$name1"
  17. echo "This is the other file" > "$name2"
  18. mkdir "$dir1" "$dir2"
  19. chmod 4700 "$name1" || test_skipped "Can't chmod"
  20. chmod 700 "$dir1"
  21. chmod 770 "$dir2"
  22. # Copy the files we've created over to another directory
  23. checkit "$RSYNC -avv '$fromdir/' '$checkdir/'" "$fromdir" "$checkdir"
  24. # And then manually make the changes which should occur
  25. umask 002
  26. chmod ug-s,a+rX "$checkdir"/*
  27. chmod +w "$checkdir" "$checkdir"/dir*
  28. checkit "$RSYNC -avv --chmod ug-s,a+rX,D+w '$fromdir/' '$todir/'" "$checkdir" "$todir"
  29. rm -r "$fromdir" "$checkdir" "$todir"
  30. makepath "$todir" "$fromdir/foo"
  31. touch "$fromdir/bar"
  32. checkit "$RSYNC -avv '$fromdir/' '$checkdir/'" "$fromdir" "$checkdir"
  33. chmod o+x "$fromdir"/bar
  34. checkit "$RSYNC -avv --chmod=Fo-x '$fromdir/' '$todir/'" "$checkdir" "$todir"
  35. # Tickle a bug in rsync 2.6.8: if you push a new directory with --perms off to
  36. # a daemon with an incoming chmod, the daemon pretends the directory is a file
  37. # for the purposes of the second application of the incoming chmod.
  38. build_rsyncd_conf
  39. cat >>"$scratchdir/test-rsyncd.conf" <<EOF
  40. [test-incoming-chmod]
  41. path = $todir
  42. read only = no
  43. incoming chmod = Fo-x
  44. EOF
  45. RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
  46. export RSYNC_CONNECT_PROG
  47. rm -r "$todir"
  48. makepath "$todir"
  49. checkit "$RSYNC -avv --no-perms '$fromdir/' localhost::test-incoming-chmod/" "$checkdir" "$todir"
  50. # The script would have aborted on error, so getting here means we've won.
  51. exit 0