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--INI--
10open_basedir=.
11--FILE--
12<?php
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));
35var_dump(unlink($symlink));
36
37test_open_basedir_after("readlink");
38?>
39--CLEAN--
40<?php
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
73Warning: unlink(): open_basedir restriction in effect. File(%s/test/ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
74bool(false)
75*** Finished testing open_basedir configuration [readlink] ***
76
77