From: Sara Golemon Date: Wed, 14 May 2003 15:12:07 +0000 (+0000) Subject: Fold 'options' parameter into wops->unlink method X-Git-Tag: RELEASE_1_0_2~812 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65d359d71aa87f83f2e2433ea1c562f4372517d2;p=php Fold 'options' parameter into wops->unlink method --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 784acfca8d..91634a71d1 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1434,7 +1434,7 @@ PHP_FUNCTION(unlink) php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s does not allow unlinking", wrapper->wops->label ? wrapper->wops->label : "Wrapper"); RETURN_FALSE; } - RETURN_BOOL(wrapper->wops->unlink(wrapper, filename, context TSRMLS_CC)); + RETURN_BOOL(wrapper->wops->unlink(wrapper, filename, ENFORCE_SAFE_MODE | REPORT_ERRORS, context TSRMLS_CC)); } /* }}} */ diff --git a/main/php_streams.h b/main/php_streams.h index 72638379b6..889eae4e0f 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -147,7 +147,7 @@ typedef struct _php_stream_wrapper_ops { const char *label; /* delete a file */ - int (*unlink)(php_stream_wrapper *wrapper, char *url, php_stream_context *context TSRMLS_DC); + int (*unlink)(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC); } php_stream_wrapper_ops; struct _php_stream_wrapper { diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index d3c36b335f..6b0f13516c 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -889,7 +889,7 @@ 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) +static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC) { char *p; int ret; @@ -900,17 +900,21 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, php_st url = p + 3; } - if (PG(safe_mode) && !php_checkuid(url, NULL, CHECKUID_CHECK_FILE_AND_DIR)) { - return 0; - } + if (options & ENFORCE_SAFE_MODE) { + 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; + 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)); + if (options & REPORT_ERRORS) { + php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno)); + } return 0; } /* Clear stat cache */