summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-05-14 16:06:48 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-05-14 16:06:48 +0000
commit4ab6eb3d199b0b111fff24a9bf6b05d1d10259b5 (patch)
treef09f51db2bf0970a30b12f65d1adeb50a4f9f388
parentad16c0a37521d086d31f374e711a34abcf3abc4d (diff)
downloadphp-git-4ab6eb3d199b0b111fff24a9bf6b05d1d10259b5.tar.gz
MFH: Fixed bug #36630 (umask not reset at the end of the request).
-rw-r--r--NEWS1
-rw-r--r--ext/standard/basic_functions.c5
-rw-r--r--ext/standard/basic_functions.h2
-rw-r--r--ext/standard/file.c6
4 files changed, 12 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 22bb7e69dc..ec94d0e5fe 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 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);
}