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