diff --git a/NEWS b/NEWS index 22bb7e69dc3..ec94d0e5fe0 100644 --- a/NEWS +++ b/NEWS @@ -39,6 +39,7 @@ PHP NEWS - Fixed bug #37306 (max_execution_time = max_input_time). (Dmitry) - Fixed bug #37244 (Added strict flag to base64_decode() that enforces RFC3548 compliance). (Ilia) +- Fixed bug #36630 (umask not reset at the end of the request). (Ilia) 04 May 2006, PHP 5.1.4 - Added "capture_peer_cert" and "capture_peer_cert_chain" context options diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 424687df9ad..e495de48e9f 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -944,6 +944,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; @@ -1217,6 +1218,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 6d3d60f77c3..fcad4091b6d 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -215,6 +215,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 bc5ee3d2c1d..f43225e961b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1464,6 +1464,10 @@ PHP_FUNCTION(umask) oldumask = umask(077); + if (BG(umask) != -1) { + BG(umask) = oldumask; + } + if (arg_count == 0) { umask(oldumask); } else { @@ -1474,8 +1478,6 @@ PHP_FUNCTION(umask) umask(Z_LVAL_PP(arg1)); } - /* XXX we should maybe reset the umask after each request! */ - RETURN_LONG(oldumask); }