xref: /PHP-5.3/ext/phar/tests/security.phpt (revision 228c2886)
1--TEST--
2Phar: test to ensure phar.readonly cannot be circumvented
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip");?>
5--INI--
6phar.readonly=0
7detect_unicode=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
11$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.php';
12$a = new Phar($fname);
13$a->setStub('<?php
14Phar::mapPhar();
15$phar = new Phar(__FILE__);
16var_dump($phar->isWritable());
17try {
18$phar["b"] = "should not work!";
19} catch (Exception $e) {
20echo $e->getMessage(),"\n";
21}
22__HALT_COMPILER();
23?>');
24$a['hi'] = 'hi';
25unset($a);
26copy($fname, $fname2);
27Phar::unlinkArchive($fname);
28ini_set('phar.readonly', 1);
29include $fname2;
30?>
31===DONE===
32--CLEAN--
33<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.php'); ?>
34--EXPECT--
35bool(false)
36Write operations disabled by the php.ini setting phar.readonly
37===DONE===
38