1--TEST--
2Test open_basedir configuration
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip no symlinks on 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");
24
25var_dump(readlink("symlink.txt"));
26var_dump(readlink("../ok/symlink.txt"));
27var_dump(readlink("../ok/./symlink.txt"));
28var_dump(readlink("./symlink.txt"));
29var_dump(readlink($initdir."/test/ok/symlink.txt"));
30
31$target = ($initdir."/test/ok/ok.txt");
32$symlink = ($initdir."/test/ok/symlink.txt");
33var_dump(symlink($target, $symlink));
34var_dump(readlink($symlink));
35
36test_open_basedir_after("readlink");
37?>
38--CLEAN--
39<?php
40chdir(__DIR__);
41require_once "open_basedir.inc";
42delete_directories();
43?>
44--EXPECTF--
45*** Testing open_basedir configuration [readlink] ***
46bool(true)
47bool(true)
48bool(true)
49bool(true)
50bool(true)
51
52Warning: readlink(): open_basedir restriction in effect. File(symlink.txt) is not within the allowed path(s): (.) in %s on line %d
53bool(false)
54
55Warning: readlink(): open_basedir restriction in effect. File(../ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
56bool(false)
57
58Warning: readlink(): open_basedir restriction in effect. File(../ok/./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
59bool(false)
60
61Warning: readlink(): open_basedir restriction in effect. File(./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
62bool(false)
63
64Warning: readlink(): open_basedir restriction in effect. File(%s/test/ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
65bool(false)
66
67Warning: symlink(): 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: readlink(): open_basedir restriction in effect. File(%s/test/ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
71bool(false)
72*** Finished testing open_basedir configuration [readlink] ***
73
74