]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #36630 (umask not reset at the end of the request).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 14 May 2006 16:06:48 +0000 (16:06 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 14 May 2006 16:06:48 +0000 (16:06 +0000)
NEWS
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/file.c

diff --git a/NEWS b/NEWS
index 22bb7e69dc3e2448de46b249f4dd879f4c7ba4de..ec94d0e5fe07c72fc1f884f7aace3b64f34e3255 100644 (file)
--- 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
index 424687df9ad560e541c73efc8c500eb4b73e7e73..e495de48e9fabe39ea96223ed0bb1e9ed4f59757 100644 (file)
@@ -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) {
index 6d3d60f77c3c8517724023cfa4562d369ee824a6..fcad4091b6d94f0d54f2719eca85324504a8b4ba 100644 (file)
@@ -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
index bc5ee3d2c1d2691aaf0439608ac16abb411b9390..f43225e961b935b1c1c677828bb096faa14503b7 100644 (file)
@@ -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);
 }