a4d243688c453621aa7f52e01c85acac16dd7995
[rsync/rsync.git] / testsuite / unsafe-byname.test
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() {
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
17 set -x
18
19 test_unsafe file from safe
20 test_unsafe dir/file from safe
21 test_unsafe dir/./file from safe
22 test_unsafe dir/. from safe
23 test_unsafe dir/ from safe
24
25 test_unsafe /etc/passwd         from unsafe
26 test_unsafe //../etc/passwd     from unsafe
27 test_unsafe //./etc/passwd      from unsafe
28
29 test_unsafe ./foo               from safe
30 test_unsafe ../foo              from unsafe
31 test_unsafe ../dest             from/dir safe
32
33 # Based on tests from unsafe-links by VladimĂ­r Michl
34 test_unsafe ../../unsafe/unsafefile    from/safe        unsafe
35 test_unsafe ../files/file1             from/safe        safe
36
37 test_unsafe ../../unsafe/unsafefile    safe     unsafe
38 test_unsafe ../files/file1             safe     unsafe
39
40 test_unsafe ../../unsafe/unsafefile    `pwd`/from/safe  safe
41 test_unsafe ../files/file1             `pwd`/from/safe  safe
42