diff --git a/ext/standard/tests/dir/open_basedir.inc b/ext/standard/tests/dir/open_basedir.inc new file mode 100644 index 00000000000..7fd0afc8bb0 --- /dev/null +++ b/ext/standard/tests/dir/open_basedir.inc @@ -0,0 +1,133 @@ + + diff --git a/ext/standard/tests/dir/open_basedir_dir.phpt b/ext/standard/tests/dir/open_basedir_dir.phpt new file mode 100644 index 00000000000..f6835d15fe8 --- /dev/null +++ b/ext/standard/tests/dir/open_basedir_dir.phpt @@ -0,0 +1,88 @@ +--TEST-- +Test open_basedir configuration +--INI-- +open_basedir=. +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing open_basedir configuration [dir] *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: dir(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(../bad): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(..): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(../): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(/): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(../bad/.): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(%s/test/bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: dir(): open_basedir restriction in effect. File(%s/test/bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: dir(%s/test/bad/../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) +object(Directory)#1 (2) { + ["path"]=> + string(%d) "%s/test/ok/" + ["handle"]=> + resource(%d) of type (stream) +} +object(Directory)#1 (2) { + ["path"]=> + string(%d) "%s/test/ok" + ["handle"]=> + resource(%d) of type (stream) +} +object(Directory)#1 (2) { + ["path"]=> + string(%d) "%s/test/ok/../ok" + ["handle"]=> + resource(%d) of type (stream) +} +*** Finished testing open_basedir configuration [dir] *** + diff --git a/ext/standard/tests/dir/open_basedir_opendir.phpt b/ext/standard/tests/dir/open_basedir_opendir.phpt new file mode 100644 index 00000000000..d67c22a0930 --- /dev/null +++ b/ext/standard/tests/dir/open_basedir_opendir.phpt @@ -0,0 +1,73 @@ +--TEST-- +Test open_basedir configuration +--INI-- +open_basedir=. +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing open_basedir configuration [opendir] *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: opendir(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(../bad): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(..): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(../): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(/): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(../bad/.): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(%s/test/bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) + +Warning: opendir(): open_basedir restriction in effect. File(%s/test/bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: opendir(%s/test/bad/../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d +bool(false) +resource(8) of type (stream) +resource(9) of type (stream) +resource(10) of type (stream) +*** Finished testing open_basedir configuration [opendir] *** + diff --git a/ext/standard/tests/dir/open_basedir_scandir.phpt b/ext/standard/tests/dir/open_basedir_scandir.phpt new file mode 100644 index 00000000000..a997bb993f9 --- /dev/null +++ b/ext/standard/tests/dir/open_basedir_scandir.phpt @@ -0,0 +1,110 @@ +--TEST-- +Test open_basedir configuration +--INI-- +open_basedir=. +--FILE-- + +--CLEAN-- + +--EXPECTF-- +*** Testing open_basedir configuration [scandir] *** +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: scandir(): open_basedir restriction in effect. File(../bad) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(../bad): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(..) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(..): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(../) is not within the allowed path(s): (.) in %s on line 80 + +Warning: scandir(../): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(/) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(/): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(../bad/.) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(../bad/.): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(%s/test/bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(%s/test/bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) + +Warning: scandir(): open_basedir restriction in effect. File(%s/test/bad/../bad/bad.txt) is not within the allowed path(s): (.) in %s on line %d + +Warning: scandir(%s/test/bad/../bad/bad.txt): failed to open dir: Operation not permitted in %s on line %d + +Warning: scandir(): (errno 1): Operation not permitted in %s on line %d +bool(false) +array(3) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(6) "ok.txt" +} +array(3) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(6) "ok.txt" +} +array(3) { + [0]=> + string(1) "." + [1]=> + string(2) ".." + [2]=> + string(6) "ok.txt" +} +*** Finished testing open_basedir configuration [scandir] *** +