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