]> granicus.if.org Git - php/commitdiff
Fold 'options' parameter into wops->unlink method
authorSara Golemon <pollita@php.net>
Wed, 14 May 2003 15:12:07 +0000 (15:12 +0000)
committerSara Golemon <pollita@php.net>
Wed, 14 May 2003 15:12:07 +0000 (15:12 +0000)
ext/standard/file.c
main/php_streams.h
main/streams/plain_wrapper.c

index 784acfca8d38288762659f3d9f1519375bb38423..91634a71d12fbf9e158b2bcb33a17ca0261303ae 100644 (file)
@@ -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));
 }
 /* }}} */
 
index 72638379b6447f4d1733994b222d38b0a0512838..889eae4e0f07e4eb295ba3513691da90f0f1c6b5 100755 (executable)
@@ -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     {
index d3c36b335f2ab09904b073ec2c6ae1fe5555f73b..6b0f13516cd675a8aab3e6149707bb2499c586da 100644 (file)
@@ -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 */