Allow $RSYNC_TEST_TMP to indicate a good tmp dir for our tests.
[rsync/rsync.git] / testsuite / unsafe-byname.test
... / ...
CommitLineData
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. "$suitedir/rsync.fns"
8
9test_unsafe() {
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
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
22test_unsafe file from safe
23test_unsafe dir/file from safe
24test_unsafe dir/./file from safe
25test_unsafe dir/. from safe
26test_unsafe dir/ from safe
27
28test_unsafe /etc/passwd from unsafe
29test_unsafe //../etc/passwd from unsafe
30test_unsafe //./etc/passwd from unsafe
31
32test_unsafe ./foo from safe
33test_unsafe ../foo from unsafe
34test_unsafe ./../foo from unsafe
35test_unsafe .//../foo from unsafe
36test_unsafe ./../foo from/.. unsafe
37test_unsafe ../dest from/dir safe
38test_unsafe ../../dest from//dir unsafe
39test_unsafe ..//../dest from/dir unsafe
40
41test_unsafe .. from/file safe
42test_unsafe ../.. from/file unsafe
43test_unsafe ..//.. from//file unsafe
44test_unsafe dir/.. from safe
45test_unsafe dir/../.. from unsafe
46test_unsafe dir/..//.. from unsafe
47
48test_unsafe '' from unsafe
49
50