From: Ant Phillips Date: Thu, 1 May 2008 11:46:17 +0000 (+0000) Subject: open_basedir tests for directory functions X-Git-Tag: RELEASE_2_0_0b1~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6946c497191517cd462732355fbc24cf80106197;p=php open_basedir tests for directory functions --- diff --git a/ext/standard/tests/dir/open_basedir.inc b/ext/standard/tests/dir/open_basedir.inc new file mode 100644 index 0000000000..7fd0afc8bb --- /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 0000000000..3f800371ac --- /dev/null +++ b/ext/standard/tests/dir/open_basedir_dir.phpt @@ -0,0 +1,154 @@ +--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] *** +--UEXPECTF-- +*** 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) { + [u"path"]=> + unicode(%d) "%s/test/ok/" + [u"handle"]=> + resource(%d) of type (stream) +} +object(Directory)#1 (2) { + [u"path"]=> + unicode(%d) "%s/test/ok" + [u"handle"]=> + resource(%d) of type (stream) +} +object(Directory)#1 (2) { + [u"path"]=> + unicode(%d) "%s/test/ok/../ok" + [u"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 0000000000..d67c22a093 --- /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 0000000000..1c5072046d --- /dev/null +++ b/ext/standard/tests/dir/open_basedir_scandir.phpt @@ -0,0 +1,198 @@ +--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] *** +--UEXPECTF-- +*** 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]=> + unicode(1) "." + [1]=> + unicode(2) ".." + [2]=> + unicode(6) "ok.txt" +} +array(3) { + [0]=> + unicode(1) "." + [1]=> + unicode(2) ".." + [2]=> + unicode(6) "ok.txt" +} +array(3) { + [0]=> + unicode(1) "." + [1]=> + unicode(2) ".." + [2]=> + unicode(6) "ok.txt" +} +*** Finished testing open_basedir configuration [scandir] *** +