unsafe-byname.test 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /bin/sh
  2. # Copyright (C) 2002 by Martin Pool
  3. # Call directly into unsafe_symlink and test its handling of various filenames
  4. . "$suitedir/rsync.fns"
  5. test_unsafe() {
  6. # $1 is the target of a symlink
  7. # $2 is the directory we're copying
  8. # $3 is the expected outcome: "safe" if the link lies within $2,
  9. # or "unsafe" otherwise
  10. result=`"$TOOLDIR/t_unsafe" "$1" "$2"` || test_fail "Failed to check $1 $2"
  11. if [ "$result" != "$3" ]
  12. then
  13. test_fail "t_unsafe $1 $2 returned \"$result\", expected \"$3\""
  14. fi
  15. }
  16. test_unsafe file from safe
  17. test_unsafe dir/file from safe
  18. test_unsafe dir/./file from safe
  19. test_unsafe dir/. from safe
  20. test_unsafe dir/ from safe
  21. test_unsafe /etc/passwd from unsafe
  22. test_unsafe //../etc/passwd from unsafe
  23. test_unsafe //./etc/passwd from unsafe
  24. test_unsafe ./foo from safe
  25. test_unsafe ../foo from unsafe
  26. test_unsafe ../dest from/dir safe
  27. test_unsafe .. from/file safe
  28. test_unsafe ../.. from/file unsafe
  29. test_unsafe dir/.. from safe
  30. test_unsafe dir/../.. from unsafe
  31. test_unsafe '' from unsafe
  32. # Based on tests from unsafe-links by Vladimír Michl
  33. test_unsafe ../../unsafe/unsafefile from/safe unsafe
  34. test_unsafe ../files/file1 from/safe safe
  35. test_unsafe ../../unsafe/unsafefile safe unsafe
  36. test_unsafe ../files/file1 safe unsafe
  37. test_unsafe ../../unsafe/unsafefile `pwd`/from/safe safe
  38. test_unsafe ../files/file1 `pwd`/from/safe safe