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