summaryrefslogtreecommitdiff
path: root/main/streams/plain_wrapper.c
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2003-05-14 06:10:04 +0000
committerSara Golemon <pollita@php.net>2003-05-14 06:10:04 +0000
commit5126fbe556a4e4fa5f48b6d5ca63395688faf3bc (patch)
treef1e1052d04dcdebfe42fe0137e4b0d1a04d0c214 /main/streams/plain_wrapper.c
parentf1679e402774edaa2f465701b0ac22f69347c4a7 (diff)
downloadphp-git-5126fbe556a4e4fa5f48b6d5ca63395688faf3bc.tar.gz
Setup unlink() method in wrapper_ops structure, implement unlink in plainfiles wrapper, explicitly set method NULL in other wrappers (for now), and rewrite unlink userland function to call into wrapper_ops
Diffstat (limited to 'main/streams/plain_wrapper.c')
-rw-r--r--main/streams/plain_wrapper.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 67ffc48cf2..d3c36b335f 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -889,13 +889,47 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, ph
return VCWD_STAT(url, &ssb->sb);
}
+static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, php_stream_context *context TSRMLS_DC)
+{
+ char *p;
+ int ret;
+ zval funcname;
+ zval *retval = NULL;
+
+ if (p = strstr(url, "://")) {
+ url = p + 3;
+ }
+
+ if (PG(safe_mode) && !php_checkuid(url, NULL, CHECKUID_CHECK_FILE_AND_DIR)) {
+ return 0;
+ }
+
+ if (php_check_open_basedir(url TSRMLS_CC)) {
+ return 0;
+ }
+
+ ret = VCWD_UNLINK(url);
+ if (ret == -1) {
+ php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno));
+ return 0;
+ }
+ /* Clear stat cache */
+ ZVAL_STRINGL(&funcname, "clearstatcache", sizeof("clearstatcache")-1, 0);
+ call_user_function_ex(CG(function_table), NULL, &funcname, &retval, 0, NULL, 0, NULL TSRMLS_CC);
+ if (retval) {
+ zval_dtor(retval);
+ }
+ return 1;
+}
+
static php_stream_wrapper_ops php_plain_files_wrapper_ops = {
php_plain_files_stream_opener,
NULL,
NULL,
php_plain_files_url_stater,
php_plain_files_dir_opener,
- "plainfile"
+ "plainfile",
+ php_plain_files_unlink
};
php_stream_wrapper php_plain_files_wrapper = {