diff options
| author | jvoisin | 2019-01-14 19:29:25 +0000 |
|---|---|---|
| committer | GitHub | 2019-01-14 19:29:25 +0000 |
| commit | e79f7e3bd992c7f0915ef9afe7afb6d79740527a (patch) | |
| tree | f881c25694eb00da2331a9ab280ec1c24a5662ab /src/tests/deny_writable/deny_writable_execution.phpt | |
| parent | c943db586ac46b686b49bdf61d8473e39dd93000 (diff) | |
Reorganize the testsuite
Splitting the testsuite in several components makes it easier to manage and comprehend.
This was also needed some some tests aren't passing on Alpine Linux, but we still want to run
as many of them as we can on this platform.
Diffstat (limited to 'src/tests/deny_writable/deny_writable_execution.phpt')
| -rw-r--r-- | src/tests/deny_writable/deny_writable_execution.phpt | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/tests/deny_writable/deny_writable_execution.phpt b/src/tests/deny_writable/deny_writable_execution.phpt new file mode 100644 index 0000000..916328e --- /dev/null +++ b/src/tests/deny_writable/deny_writable_execution.phpt | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | --TEST-- | ||
| 2 | Readonly execution attempt | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php | ||
| 5 | if (!extension_loaded("snuffleupagus")) print "skip"; | ||
| 6 | |||
| 7 | $filename = __DIR__ . '/test.txt'; | ||
| 8 | |||
| 9 | @unlink($filename); | ||
| 10 | |||
| 11 | file_put_contents($filename, 'a'); | ||
| 12 | chmod($filename, 0400); | ||
| 13 | |||
| 14 | if (is_writable($filename)) print "skip"; | ||
| 15 | @unlink($filename); | ||
| 16 | ?> | ||
| 17 | --INI-- | ||
| 18 | sp.configuration_file={PWD}/config/config_disable_writable.ini | ||
| 19 | --FILE-- | ||
| 20 | <?php | ||
| 21 | $dir = __DIR__; | ||
| 22 | |||
| 23 | // just in case | ||
| 24 | @unlink("$dir/non_writable_file.txt"); | ||
| 25 | @unlink("$dir/writable_file.txt"); | ||
| 26 | |||
| 27 | file_put_contents("$dir/non_writable_file.txt", '<?php echo "Code execution within a non-writable file.\n";'); | ||
| 28 | file_put_contents("$dir/writable_file.txt", '<?php echo "Code execution within a writable file.\n";'); | ||
| 29 | chmod("$dir/non_writable_file.txt", 0400); | ||
| 30 | chmod("$dir/writable_file.txt", 0777); | ||
| 31 | include "$dir/non_writable_file.txt"; | ||
| 32 | include "$dir/writable_file.txt"; | ||
| 33 | ?> | ||
| 34 | --CLEAN-- | ||
| 35 | <?php | ||
| 36 | $dir = __DIR__; | ||
| 37 | chmod("$dir/non_writable_file.txt", 0777); | ||
| 38 | chmod("$dir/writable_file.txt", 0777); | ||
| 39 | unlink("$dir/non_writable_file.txt"); | ||
| 40 | unlink("$dir/writable_file.txt"); | ||
| 41 | ?> | ||
| 42 | --EXPECTF-- | ||
| 43 | Fatal error: [snuffleupagus][readonly_exec] Attempted execution of a writable file (%a/deny_writable_execution.php). in %a/deny_writable_execution.php on line 2 | ||
