X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/e4d709cbf884fea90d748bbcb6c267d6f9006136..b769ad6a3e7ef871ea0aabd5b033018ba6cdbb90:/testsuite/unsafe-byname.test diff --git a/testsuite/unsafe-byname.test b/testsuite/unsafe-byname.test index adb95156..61e0e24a 100644 --- a/testsuite/unsafe-byname.test +++ b/testsuite/unsafe-byname.test @@ -4,9 +4,14 @@ # Call directly into unsafe_symlink and test its handling of various filenames -. $srcdir/testsuite/rsync.fns +. "$suitedir/rsync.fns" test_unsafe() { + # $1 is the target of a symlink + # $2 is the directory we're copying + # $3 is the expected outcome: "safe" if the link lies within $2, + # or "unsafe" otherwise + result=`"$TOOLDIR/t_unsafe" "$1" "$2"` || test_fail "Failed to check $1 $2" if [ "$result" != "$3" ] then @@ -17,16 +22,23 @@ test_unsafe() { test_unsafe file from safe test_unsafe dir/file from safe test_unsafe dir/./file from safe -test_unsafe dir/. from safe -test_unsafe dir/ from safe +test_unsafe dir/. from safe +test_unsafe dir/ from safe + +test_unsafe /etc/passwd from unsafe +test_unsafe //../etc/passwd from unsafe +test_unsafe //./etc/passwd from unsafe + +test_unsafe ./foo from safe +test_unsafe ../foo from unsafe +test_unsafe ../dest from/dir safe -test_unsafe /etc/passwd from unsafe -test_unsafe //../etc/passwd from unsafe -test_unsafe //./etc/passwd from unsafe +test_unsafe .. from/file safe +test_unsafe ../.. from/file unsafe +test_unsafe dir/.. from safe +test_unsafe dir/../.. from unsafe -test_unsafe ./foo from safe -test_unsafe ../foo from unsafe -test_unsafe ../dest from/dir safe +test_unsafe '' from unsafe # Based on tests from unsafe-links by VladimĂ­r Michl test_unsafe ../../unsafe/unsafefile from/safe unsafe @@ -37,8 +49,3 @@ test_unsafe ../files/file1 safe unsafe test_unsafe ../../unsafe/unsafefile `pwd`/from/safe safe test_unsafe ../files/file1 `pwd`/from/safe safe - -# Test suspicious handling of '..' in srcdir -test_unsafe ../../unsafe/unsafefile from/safe/../safe unsafe -test_unsafe ../files/file1 from/safe/../safe safe -