unsafe-links.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #! /bin/sh
  2. # Originally by Vladimír Michl <Vladimir.Michl@hlubocky.del.cz>
  3. . "$suitedir/rsync.fns"
  4. test_symlink() {
  5. is_a_link "$1" || test_fail "File $1 is not a symlink"
  6. };
  7. test_regular() {
  8. if [ ! -f "$1" ]; then
  9. test_fail "File $1 is not regular file or not exists";
  10. fi;
  11. };
  12. cd "$tmpdir"
  13. mkdir from
  14. mkdir "from/safe"
  15. mkdir "from/unsafe"
  16. mkdir "from/safe/files"
  17. mkdir "from/safe/links"
  18. touch "from/safe/files/file1"
  19. touch "from/safe/files/file2"
  20. touch "from/unsafe/unsafefile"
  21. ln -s ../files/file1 "from/safe/links/"
  22. ln -s ../files/file2 "from/safe/links/"
  23. ln -s ../../unsafe/unsafefile "from/safe/links/"
  24. echo "rsync with relative path and just -a";
  25. $RSYNC -avv from/safe/ to
  26. test_symlink to/links/file1
  27. test_symlink to/links/file2
  28. test_symlink to/links/unsafefile
  29. echo "rsync with relative path and -a --copy-links"
  30. $RSYNC -avv --copy-links from/safe/ to
  31. test_regular to/links/file1
  32. test_regular to/links/file2
  33. test_regular to/links/unsafefile
  34. echo "rsync with relative path and --copy-unsafe-links";
  35. $RSYNC -avv --copy-unsafe-links from/safe/ to
  36. test_symlink to/links/file1
  37. test_symlink to/links/file2
  38. test_regular to/links/unsafefile
  39. rm -rf to
  40. echo "rsync with relative2 path";
  41. (cd from; $RSYNC -avv --copy-unsafe-links safe/ ../to)
  42. test_symlink to/links/file1
  43. test_symlink to/links/file2
  44. test_regular to/links/unsafefile
  45. rm -rf to
  46. echo "rsync with absolute path";
  47. $RSYNC -avv --copy-unsafe-links `pwd`/from/safe/ to
  48. test_symlink to/links/file1
  49. test_symlink to/links/file2
  50. test_regular to/links/unsafefile