Annotation of embedaddon/php/tests/security/open_basedir_symlink.phpt, revision 1.1
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("symlink");
! 16:
! 17: $target = ($initdir."/test/ok/ok.txt");
! 18: var_dump(symlink($target, "../bad/symlink.txt"));
! 19: var_dump(symlink($target, "../symlink.txt"));
! 20: var_dump(symlink($target, "../bad/./symlink.txt"));
! 21: var_dump(symlink($target, "./.././symlink.txt"));
! 22:
! 23: $symlink = ($initdir."/test/ok/symlink.txt");
! 24: var_dump(symlink("../bad/bad.txt", $symlink));
! 25: var_dump(symlink("../bad", $symlink));
! 26: var_dump(symlink("../bad/./bad.txt", $symlink));
! 27: var_dump(symlink("../bad/bad.txt", $symlink));
! 28: var_dump(symlink("./.././bad", $symlink));
! 29:
! 30: $target = ($initdir."/test/ok/ok.txt");
! 31:
! 32: var_dump(symlink($target, $symlink));
! 33: var_dump(unlink($symlink));
! 34:
! 35: var_dump(mkdir("ok2"));
! 36: $symlink = ($initdir."/test/ok/ok2/ok.txt");
! 37: var_dump(symlink("../ok.txt", $symlink)); // $target == (dirname($symlink)."/".$target) == ($initdir."/test/ok/ok.txt");
! 38: var_dump(unlink($symlink));
! 39:
! 40: test_open_basedir_after("symlink");
! 41: ?>
! 42: --CLEAN--
! 43: <?php
! 44: require_once "open_basedir.inc";
! 45: delete_directories();
! 46: ?>
! 47: --EXPECTF--
! 48: *** Testing open_basedir configuration [symlink] ***
! 49: bool(true)
! 50: bool(true)
! 51: bool(true)
! 52: bool(true)
! 53: bool(true)
! 54:
! 55: Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
! 56: bool(false)
! 57:
! 58: Warning: symlink(): open_basedir restriction in effect. File(%s/test/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
! 59: bool(false)
! 60:
! 61: Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
! 62: bool(false)
! 63:
! 64: Warning: symlink(): open_basedir restriction in effect. File(%s/test/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: symlink(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
! 71: bool(false)
! 72:
! 73: 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
! 74: bool(false)
! 75:
! 76: 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
! 77: bool(false)
! 78:
! 79: Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
! 80: bool(false)
! 81: bool(true)
! 82: bool(true)
! 83: bool(true)
! 84: bool(true)
! 85: bool(true)
! 86: *** Finished testing open_basedir configuration [symlink] ***
! 87:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>