1--TEST--
2Test open_basedir configuration
3--SKIPIF--
4<?php
5if(PHP_OS_FAMILY === "Windows") {
6    die('skip no links on Windows');
7}
8?>
9--INI--
10open_basedir=.
11--FILE--
12<?php
13require_once "open_basedir.inc";
14$initdir = getcwd();
15test_open_basedir_before("link");
16
17$target = ($initdir."/test/ok/ok.txt");
18var_dump(link($target, "../bad/link.txt"));
19var_dump(link($target, "../link.txt"));
20var_dump(link($target, "../bad/./link.txt"));
21var_dump(link($target, "./.././link.txt"));
22
23$link = ($initdir."/test/ok/link.txt");
24var_dump(link("../bad/bad.txt", $link));
25var_dump(link("../bad", $link));
26var_dump(link("../bad/./bad.txt", $link));
27var_dump(link("../bad/bad.txt", $link));
28var_dump(link("./.././bad", $link));
29
30$target = ($initdir."/test/ok/ok.txt");
31
32var_dump(link($target, $link));
33var_dump(unlink($link));
34test_open_basedir_after("link");
35?>
36--CLEAN--
37<?php
38require_once "open_basedir.inc";
39delete_directories();
40?>
41--EXPECTF--
42*** Testing open_basedir configuration [link] ***
43bool(true)
44bool(true)
45bool(true)
46bool(true)
47bool(true)
48
49Warning: link(): open_basedir restriction in effect. File(%s/test/bad/link.txt) is not within the allowed path(s): (.) in %s on line %d
50bool(false)
51
52Warning: link(): open_basedir restriction in effect. File(%s/test/link.txt) is not within the allowed path(s): (.) in %s on line %d
53bool(false)
54
55Warning: link(): open_basedir restriction in effect. File(%s/test/bad/link.txt) is not within the allowed path(s): (.) in %s on line %d
56bool(false)
57
58Warning: link(): open_basedir restriction in effect. File(%s/test/link.txt) is not within the allowed path(s): (.) in %s on line %d
59bool(false)
60
61Warning: link(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
62bool(false)
63
64Warning: link(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
65bool(false)
66
67Warning: link(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
68bool(false)
69
70Warning: link(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
71bool(false)
72
73Warning: link(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
74bool(false)
75bool(true)
76bool(true)
77*** Finished testing open_basedir configuration [link] ***
78