]> granicus.if.org Git - php/commitdiff
- Some more safe_mode nuking
authorAndi Gutmans <andi@php.net>
Sun, 19 Feb 2006 01:10:13 +0000 (01:10 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 19 Feb 2006 01:10:13 +0000 (01:10 +0000)
main/fopen_wrappers.c
main/main.c
main/streams/plain_wrapper.c

index 3cf8b77c890cfcbc5d908f01bb29b63a5df833f4..992e846e57e497e38864b7928460486b30eb3f9b 100644 (file)
@@ -379,9 +379,6 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
        
        /* Relative path open */
        if (*filename == '.') {
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
-                       return NULL;
-               }
                return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
        }
        
@@ -396,16 +393,10 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
                        /* filename is in safe_mode_include_dir (or subdir) */
                        return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
                        
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM)))
-                       return NULL;
-
                return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
        }
 
        if (!path || (path && !*path)) {
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
-                       return NULL;
-               }
                return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
        }
 
index 8ef09e4666c5450f809525a3d7a5703fc492c0d8..06fe98397e50cde947f10e3693956d800034a4d5 100644 (file)
@@ -1601,8 +1601,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        orig_unicode = UG(unicode);
        UG(unicode) = 0;
 
-       /* Disable realpath cache if safe_mode or open_basedir are set */
-       if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) {
+       /* Disable realpath cache if open_basedir are set */
+       if ((PG(open_basedir) && *PG(open_basedir))) {
                CWDG(realpath_cache_size_limit) = 0;
        }
 
index 35145ce88ad63d9c428ff3b5bb25d069ec302786..12c708f11bc6704e1bb9e255e25a46658e69f683 100644 (file)
@@ -813,10 +813,6 @@ static php_stream *php_plain_files_dir_opener(php_stream_wrapper *wrapper, char
                return NULL;
        }
        
-       if (PG(safe_mode) &&(!php_checkuid(path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
-               return NULL;
-       }
-       
        dir = VCWD_OPENDIR(path);
 
 #ifdef PHP_WIN32
@@ -935,9 +931,6 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, ch
                return NULL;
        }
 
-       if ((options & ENFORCE_SAFE_MODE) && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM)))
-               return NULL;
-
        return php_stream_fopen_rel(path, mode, opened_path, options);
 }
 
@@ -948,10 +941,6 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, in
                url += sizeof("file://") - 1;
        }
 
-       if (PG(safe_mode) &&(!php_checkuid_ex(url, NULL, CHECKUID_CHECK_FILE_AND_DIR, (flags & PHP_STREAM_URL_STAT_QUIET) ? CHECKUID_NO_ERRORS : 0))) {
-               return -1;
-       }
-
        if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) {
                return -1;
        }
@@ -975,11 +964,8 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int op
                url = p + 3;
        }
 
+       /* FIXME: Andi - Pending email I sent to internals@ re: ENFORCE_SAFE_MODE */
        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;
                }
@@ -1019,11 +1005,6 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
                url_to = p + 3;
        }
 
-       if (PG(safe_mode) && (!php_checkuid(url_from, NULL, CHECKUID_CHECK_FILE_AND_DIR) ||
-                               !php_checkuid(url_to, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
-               return 0;
-       }
-
        if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) {
                return 0;
        }
@@ -1142,10 +1123,6 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, char *dir, int mod
 
 static int php_plain_files_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
 {
-       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;
        }
@@ -1216,9 +1193,6 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char
                        return NULL;
                }
 
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
-                       return NULL;
-               }
                return php_stream_fopen_rel(filename, mode, opened_path, options);
        }
 
@@ -1240,9 +1214,6 @@ not_relative_path:
                        /* filename is in safe_mode_include_dir (or subdir) */
                        return php_stream_fopen_rel(filename, mode, opened_path, options);
 
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM)))
-                       return NULL;
-
                return php_stream_fopen_rel(filename, mode, opened_path, options);
        }
        
@@ -1264,10 +1235,7 @@ not_relative_path:
                if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC)) == 0) {
                        return php_stream_fopen_rel(trypath, mode, opened_path, options);
                }       
-               if (PG(safe_mode) && (!php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM))) {
-                       return NULL;
-               }
-               
+
                return php_stream_fopen_rel(trypath, mode, opened_path, options);
        }
 #endif
@@ -1278,9 +1246,6 @@ not_relative_path:
                        return NULL;
                }
 
-               if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
-                       return NULL;
-               }
                return php_stream_fopen_rel(filename, mode, opened_path, options);
        }