open_basedir_symlink.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. $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] ***