You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.4 KiB

  1. --TEST--
  2. Test open_basedir configuration
  3. --INI--
  4. open_basedir=.
  5. --FILE--
  6. <?php
  7. require_once "open_basedir.inc";
  8. test_open_basedir_before("copy");
  9. $directory = dirname(__FILE__);
  10. var_dump(copy("ok.txt", "../bad"));
  11. var_dump(copy("ok.txt", "../bad/bad.txt"));
  12. var_dump(copy("ok.txt", ".."));
  13. var_dump(copy("ok.txt", "../"));
  14. var_dump(copy("ok.txt", "/"));
  15. var_dump(copy("ok.txt", "../bad/."));
  16. var_dump(copy("ok.txt", "../bad/./bad.txt"));
  17. var_dump(copy("ok.txt", "./../."));
  18. var_dump(copy("ok.txt", "copy.txt"));
  19. var_dump(unlink("copy.txt"));
  20. test_open_basedir_after("copy");
  21. ?>
  22. --CLEAN--
  23. <?php
  24. require_once "open_basedir.inc";
  25. delete_directories();
  26. ?>
  27. --EXPECTF--
  28. *** Testing open_basedir configuration [copy] ***
  29. bool(true)
  30. bool(true)
  31. bool(true)
  32. bool(true)
  33. bool(true)
  34. Warning: copy(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d
  35. Warning: copy(../bad): failed to open stream: %s in %s on line %d
  36. bool(false)
  37. Warning: copy(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d
  38. Warning: copy(../bad/bad.txt): failed to open stream: %s in %s on line %d
  39. bool(false)
  40. Warning: copy(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d
  41. Warning: copy(..): failed to open stream: %s in %s on line %d
  42. bool(false)
  43. Warning: copy(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d
  44. Warning: copy(../): failed to open stream: %s in %s on line %d
  45. bool(false)
  46. Warning: copy(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d
  47. Warning: copy(/): failed to open stream: %s in %s on line %d
  48. bool(false)
  49. Warning: copy(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d
  50. Warning: copy(../bad/.): failed to open stream: %s in %s on line %d
  51. bool(false)
  52. Warning: copy(): open_basedir restriction in effect. File(../bad/./bad.txt) is not within the allowed path(s): (.) in %s on line %d
  53. Warning: copy(../bad/./bad.txt): failed to open stream: %s in %s on line %d
  54. bool(false)
  55. Warning: copy(): open_basedir restriction in effect. File(./../.) is not within the allowed path(s): (.) in %s on line %d
  56. Warning: copy(./../.): failed to open stream: %s in %s on line %d
  57. bool(false)
  58. bool(true)
  59. bool(true)
  60. *** Finished testing open_basedir configuration [copy] ***