open_basedir_symlink.phpt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --TEST--
  2. Test open_basedir configuration
  3. --SKIPIF--
  4. <?php
  5. if(PHP_OS_FAMILY === "Windows") {
  6. die('skip not for 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. $target = ($initdir."/test/ok/ok.txt");
  17. var_dump(symlink($target, "../bad/symlink.txt"));
  18. var_dump(symlink($target, "../symlink.txt"));
  19. var_dump(symlink($target, "../bad/./symlink.txt"));
  20. var_dump(symlink($target, "./.././symlink.txt"));
  21. $symlink = ($initdir."/test/ok/symlink.txt");
  22. var_dump(symlink("../bad/bad.txt", $symlink));
  23. var_dump(symlink("../bad", $symlink));
  24. var_dump(symlink("../bad/./bad.txt", $symlink));
  25. var_dump(symlink("../bad/bad.txt", $symlink));
  26. var_dump(symlink("./.././bad", $symlink));
  27. $target = ($initdir."/test/ok/ok.txt");
  28. var_dump(symlink($target, $symlink));
  29. var_dump(unlink($symlink));
  30. var_dump(mkdir("ok2"));
  31. $symlink = ($initdir."/test/ok/ok2/ok.txt");
  32. var_dump(symlink("../ok.txt", $symlink)); // $target == (dirname($symlink)."/".$target) == ($initdir."/test/ok/ok.txt");
  33. var_dump(unlink($symlink));
  34. test_open_basedir_after("symlink");
  35. ?>
  36. --CLEAN--
  37. <?php
  38. require_once "open_basedir.inc";
  39. delete_directories();
  40. ?>
  41. --EXPECTF--
  42. *** Testing open_basedir configuration [symlink] ***
  43. bool(true)
  44. bool(true)
  45. bool(true)
  46. bool(true)
  47. bool(true)
  48. 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
  49. bool(false)
  50. Warning: symlink(): open_basedir restriction in effect. File(%s/test/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  51. bool(false)
  52. 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
  53. bool(false)
  54. Warning: symlink(): open_basedir restriction in effect. File(%s/test/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  55. bool(false)
  56. 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
  57. bool(false)
  58. Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
  59. bool(false)
  60. 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
  61. bool(false)
  62. 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
  63. bool(false)
  64. Warning: symlink(): open_basedir restriction in effect. File(%s/test/bad) is not within the allowed path(s): (.) in %s on line %d
  65. bool(false)
  66. bool(true)
  67. bool(true)
  68. bool(true)
  69. bool(true)
  70. bool(true)
  71. *** Finished testing open_basedir configuration [symlink] ***