summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/basic_functions.c5
-rw-r--r--ext/standard/basic_functions.h2
-rw-r--r--ext/standard/file.c6
3 files changed, 11 insertions, 2 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 424687df9a..e495de48e9 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 6d3d60f77c..fcad4091b6 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 bc5ee3d2c1..f43225e961 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);
}