From edd7d2a1df68ca4a382d83954bd8e8bae430a5ac Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 6 Mar 2006 14:27:45 +0000 Subject: [PATCH] Fixed bug #36630 (umask not reset at the end of the request). # This needs to be MFHed, but since it requires an API break it has to wait # until the next minor release. --- NEWS | 1 + ext/standard/basic_functions.c | 5 +++++ ext/standard/basic_functions.h | 2 ++ ext/standard/file.c | 6 ++++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index b20bac0b77..9e89b8c894 100644 --- a/NEWS +++ b/NEWS @@ -29,4 +29,5 @@ PHP NEWS the part of haystack before or after first occurence of needle. (Johannes) - Added possibility to check in which extension an internal function was defined using reflection API. (Johannes) +- Fixed bug #36630 (umask not reset at the end of the request). (Ilia) - Fixed bug #34286 (__toString() behavior is inconsistent). (Marcus) diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 8ec7c843df..ab7d375569 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -909,6 +909,7 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p TSRMLS_DC) { BG(rand_is_seeded) = 0; BG(mt_rand_is_seeded) = 0; + BG(umask) = -1; BG(next) = NULL; BG(left) = -1; @@ -1177,6 +1178,10 @@ PHP_RSHUTDOWN_FUNCTION(basic) zend_hash_destroy(&BG(putenv_ht)); #endif + if (BG(umask) != -1) { + umask(BG(umask)); + } + /* Check if locale was changed and change it back to the value in startup environment */ if (BG(locale_string) != NULL) { diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 21d706979a..07197f7b9b 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -212,6 +212,8 @@ typedef struct _php_basic_globals { #if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T) mbstate_t mblen_state; #endif + + int umask; } php_basic_globals; #ifdef ZTS diff --git a/ext/standard/file.c b/ext/standard/file.c index e4f1d803ce..88d4062c6f 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1473,6 +1473,10 @@ PHP_FUNCTION(umask) oldumask = umask(077); + if (BG(umask) != -1) { + BG(umask) = oldumask; + } + if (arg_count == 0) { umask(oldumask); } else { @@ -1483,8 +1487,6 @@ PHP_FUNCTION(umask) umask(Z_LVAL_PP(arg1)); } - /* XXX we should maybe reset the umask after each request! */ - RETURN_LONG(oldumask); } -- 2.40.0