3 # Copyright (C) 2002 by Martin Pool
5 # Call directly into unsafe_symlink and test its handling of various filenames
7 . $srcdir/testsuite/rsync.fns
10 # $1 is the target of a symlink
11 # $2 is the directory we're copying
12 # $3 is the expected outcome: "safe" if the link lies within $2,
13 # or "unsafe" otherwise
15 result=`"$TOOLDIR/t_unsafe" "$1" "$2"` || test_fail "Failed to check $1 $2"
16 if [ "$result" != "$3" ]
18 test_fail "t_unsafe $1 $2 returned \"$result\", expected \"$3\""
22 test_unsafe file from safe
23 test_unsafe dir/file from safe
24 test_unsafe dir/./file from safe
25 test_unsafe dir/. from safe
26 test_unsafe dir/ from safe
28 test_unsafe /etc/passwd from unsafe
29 test_unsafe //../etc/passwd from unsafe
30 test_unsafe //./etc/passwd from unsafe
32 test_unsafe ./foo from safe
33 test_unsafe ../foo from unsafe
34 test_unsafe ../dest from/dir safe
36 test_unsafe '' from unsafe
38 # Based on tests from unsafe-links by VladimĂr Michl
39 test_unsafe ../../unsafe/unsafefile from/safe unsafe
40 test_unsafe ../files/file1 from/safe safe
42 test_unsafe ../../unsafe/unsafefile safe unsafe
43 test_unsafe ../files/file1 safe unsafe
45 test_unsafe ../../unsafe/unsafefile `pwd`/from/safe safe
46 test_unsafe ../files/file1 `pwd`/from/safe safe
48 # I think these are correct, but I don't really understand the code.
49 # Waiting for an answer from dwd
50 test_skipped "correct behaviour is unclear"
52 # Test suspicious handling of '..' in srcdir
53 test_unsafe ../../unsafe/unsafefile from/safe/../safe unsafe
54 test_unsafe ../files/file1 from/safe/../safe safe