]> granicus.if.org Git - php/commitdiff
Fixed bug #36630 (umask not reset at the end of the request).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 6 Mar 2006 14:27:45 +0000 (14:27 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 6 Mar 2006 14:27:45 +0000 (14:27 +0000)
# This needs to be MFHed, but since it requires an API break it has to wait
# until the next minor release.

NEWS
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/file.c

diff --git a/NEWS b/NEWS
index b20bac0b772fb55a41507ea8dd847221c7e93142..9e89b8c89475435f570239f95b93cf47013a55da 100644 (file)
--- 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)
index 8ec7c843df31d667c6a3701d2c9083060220647e..ab7d3755696afbdf43df3789b5cac374415652fa 100644 (file)
@@ -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) {
index 21d706979a7e2d9389e4d2421122ed632bf9ded4..07197f7b9b1311e898cf93f78f01e36420f854c9 100644 (file)
@@ -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
index e4f1d803cedc6104522e6914618d9348098f787d..88d4062c6f91814bff4d853f7d18edc99aae6bde 100644 (file)
@@ -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);
 }