open_basedir_tempnam.phpt 2.0 KB

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