File: unsafe-byname.test

package info (click to toggle)
rsync 3.0.7-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,284 kB
  • ctags: 3,471
  • sloc: ansic: 35,640; sh: 4,916; perl: 1,466; makefile: 297; python: 83
file content (59 lines) | stat: -rw-r--r-- 1,831 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/sh

# Copyright (C) 2002 by Martin Pool

# Call directly into unsafe_symlink and test its handling of various filenames

. "$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
	test_fail "t_unsafe $1 $2 returned \"$result\", expected \"$3\""
    fi
}

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 /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 ./../foo			from				unsafe
test_unsafe .//../foo			from				unsafe
test_unsafe ./../foo			from/..				unsafe
test_unsafe ../dest			from/dir			safe
test_unsafe ../../dest			from//dir			unsafe
test_unsafe ..//../dest 		from/dir			unsafe

test_unsafe ..				from/file			safe
test_unsafe ../..			from/file			unsafe
test_unsafe ..//..			from//file			unsafe
test_unsafe dir/..			from				safe
test_unsafe dir/../..			from				unsafe
test_unsafe dir/..//..			from				unsafe

test_unsafe ''				from				unsafe

# Based on tests from unsafe-links by Vladimr Michl
test_unsafe ../../unsafe/unsafefile	from/safe			unsafe
test_unsafe ..//../unsafe/unsafefile	from/safe			unsafe
test_unsafe ../files/file1		from/safe			safe

test_unsafe ../../unsafe/unsafefile	safe				unsafe
test_unsafe ../files/file1		safe				unsafe

test_unsafe ../../unsafe/unsafefile	`pwd`/from/safe			safe
test_unsafe ../files/file1		`pwd`/from/safe			safe