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