Commit | Line | Data |
---|---|---|
d25c0e42 MP |
1 | #! /bin/sh |
2 | ||
3 | # Copyright (C) 2002 by Martin Pool | |
4 | ||
5 | # Call directly into unsafe_symlink and test its handling of various filenames | |
6 | ||
7 | . $srcdir/testsuite/rsync.fns | |
8 | ||
9 | test_unsafe() { | |
4eea7793 MP |
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 | |
14 | ||
d25c0e42 MP |
15 | result=`"$TOOLDIR/t_unsafe" "$1" "$2"` || test_fail "Failed to check $1 $2" |
16 | if [ "$result" != "$3" ] | |
17 | then | |
18 | test_fail "t_unsafe $1 $2 returned \"$result\", expected \"$3\"" | |
19 | fi | |
20 | } | |
21 | ||
e4d709cb MP |
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 | |
c81a32f0 MP |
27 | |
28 | test_unsafe /etc/passwd from unsafe | |
29 | test_unsafe //../etc/passwd from unsafe | |
30 | test_unsafe //./etc/passwd from unsafe | |
31 | ||
4eea7793 MP |
32 | test_unsafe ./foo from safe |
33 | test_unsafe ../foo from unsafe | |
34 | test_unsafe ../dest from/dir safe | |
35 | ||
36 | test_unsafe '' from unsafe | |
c81a32f0 MP |
37 | |
38 |