open_basedir_link.phpt 2.4 KB

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