From: Andi Gutmans Date: Sun, 19 Feb 2006 01:10:13 +0000 (+0000) Subject: - Some more safe_mode nuking X-Git-Tag: RELEASE_1_2~177 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3b1e8c5ddf56369d6eba69692c71b7d8be19dcd;p=php - Some more safe_mode nuking --- diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 3cf8b77c89..992e846e57 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -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); } diff --git a/main/main.c b/main/main.c index 8ef09e4666..06fe98397e 100644 --- a/main/main.c +++ b/main/main.c @@ -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; } diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 35145ce88a..12c708f11b 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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); }