}
if (phar_open_loaded(fname, fname_len, alias, alias_len, options, pphar TSRMLS_CC) == SUCCESS) {
- (*pphar)->is_writeable = 1;
+ if (!PHAR_G(readonly)) {
+ (*pphar)->is_writeable = 1;
+ }
return SUCCESS;
}
return FAILURE;
}
- fp = php_stream_open_wrapper(fname, "r+b", IGNORE_URL|STREAM_MUST_SEEK|0, NULL);
+ fp = php_stream_open_wrapper(fname, PHAR_G(readonly)?"rb":"r+b", IGNORE_URL|STREAM_MUST_SEEK|0, NULL);
if (fp && phar_open_fp(fp, fname, fname_len, alias, alias_len, options, pphar TSRMLS_CC) == SUCCESS) {
- (*pphar)->is_writeable = 1;
+ if (!PHAR_G(readonly)) {
+ (*pphar)->is_writeable = 1;
+ }
return SUCCESS;
}
}
#endif
if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) {
+ if (PHAR_G(readonly)) {
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "phar error: write operations disabled by INI setting");
+ php_url_free(resource);
+ return NULL;
+ }
if (phar_open_or_create_filename(resource->host, arch_len, NULL, 0, options, NULL TSRMLS_CC) == FAILURE)
{
php_url_free(resource);
ssb->sb.st_ctime = phar->max_timestamp;
#endif
}
- if (PHAR_G(readonly)) {
+ if (!phar->is_writeable) {
ssb->sb.st_mode = (ssb->sb.st_mode & 0555) | (ssb->sb.st_mode & ~0777);
}
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: file_put_contents(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: No such file or directory in %screate_new_phar_b.php on line %d
+Warning: file_put_contents(phar://%screate_new_phar_b.phar.php/a.php): failed to open stream: phar error: write operations disabled by INI setting in %screate_new_phar_b.php on line %d
Warning: include(%screate_new_phar_b.phar.php): failed to open stream: No such file or directory in %screate_new_phar_b.php on line %d
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: file "%sopen_for_write_existing_b.phar.php" cannot opened for writing, disabled by ini setting
-phar error: file "b/c.php" could not be created in phar "%sopen_for_write_existing_b.phar.php" in %sopen_for_write_existing_b.php on line %d
+
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: file "%sopen_for_write_existing_c.phar.php" cannot opened for writing, disabled by ini setting
-phar error: file "b/c.php" could not be created in phar "%sopen_for_write_existing_c.phar.php" in %sopen_for_write_existing_c.php on line %d
+
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: file "%sopen_for_write_newfile_b.phar.php" cannot opened for writing, disabled by ini setting
-phar error: file "b/new.php" could not be created in phar "%sopen_for_write_newfile_b.phar.php" in %sopen_for_write_newfile_b.php on line %d
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: file "%sopen_for_write_newfile_c.phar.php" cannot opened for writing, disabled by ini setting
-phar error: file "b/new.php" could not be created in phar "%sopen_for_write_newfile_c.phar.php" in %sopen_for_write_newfile_c.php on line %d
+
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
<?php if (!extension_loaded("phar")) print "skip"; ?>
<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
--INI--
+phar.readonly=1
phar.require_hash=0
--FILE--
<?php