open_basedir_readlink.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. --FILE--
  10. <?php
  11. chdir(__DIR__);
  12. ini_set("open_basedir", ".");
  13. require_once "open_basedir.inc";
  14. $initdir = getcwd();
  15. test_open_basedir_before("readlink", FALSE);
  16. chdir($initdir);
  17. $target = ($initdir."/test/bad/bad.txt");
  18. $symlink = ($initdir."/test/ok/symlink.txt");
  19. var_dump(symlink($target, $symlink));
  20. chdir($initdir."/test/ok");
  21. var_dump(readlink("symlink.txt"));
  22. var_dump(readlink("../ok/symlink.txt"));
  23. var_dump(readlink("../ok/./symlink.txt"));
  24. var_dump(readlink("./symlink.txt"));
  25. var_dump(readlink($initdir."/test/ok/symlink.txt"));
  26. $target = ($initdir."/test/ok/ok.txt");
  27. $symlink = ($initdir."/test/ok/symlink.txt");
  28. var_dump(symlink($target, $symlink));
  29. var_dump(readlink($symlink));
  30. test_open_basedir_after("readlink");
  31. ?>
  32. --CLEAN--
  33. <?php
  34. chdir(__DIR__);
  35. require_once "open_basedir.inc";
  36. delete_directories();
  37. ?>
  38. --EXPECTF--
  39. *** Testing open_basedir configuration [readlink] ***
  40. bool(true)
  41. bool(true)
  42. bool(true)
  43. bool(true)
  44. bool(true)
  45. Warning: readlink(): open_basedir restriction in effect. File(symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  46. bool(false)
  47. Warning: readlink(): open_basedir restriction in effect. File(../ok/symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  48. bool(false)
  49. Warning: readlink(): open_basedir restriction in effect. File(../ok/./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  50. bool(false)
  51. Warning: readlink(): open_basedir restriction in effect. File(./symlink.txt) is not within the allowed path(s): (.) in %s on line %d
  52. bool(false)
  53. 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
  54. bool(false)
  55. 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
  56. bool(false)
  57. 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
  58. bool(false)
  59. *** Finished testing open_basedir configuration [readlink] ***