php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33176 umask is not being restored when each request is finished
Submitted: 2005-05-29 03:34 UTC Modified: 2005-05-29 10:20 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: strovato at cdeducation dot org Assigned:
Status: Wont fix Package: iPlanet related
PHP Version: 4.3.11 OS: Solaris 10 SPARC
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: strovato at cdeducation dot org
New email:
PHP Version: OS:

 

 [2005-05-29 03:34 UTC] strovato at cdeducation dot org
Description:
------------
If the umask is set by a PHP script and not restored, the new umask persists and is inherited by any scripts that follow.

This seems like the same bug as #28401, but under the Sun Java System Web Server 6.1 instead of Apache.  It is marked there as Wont fix.  If it's not fixable here, either, then perhaps the docs should be fixed, since they state that "the umask is restored when each request is finished."

-S

Reproduce code:
---------------
<?PHP
echo umask();
umask(0111);
?>


Expected result:
----------------
Each time the script is run, it should echo the same number.

Actual result:
--------------
The new umask instead of the default will be echoed every time after the first run.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-29 10:20 UTC] thetaphi@php.net
You could also save the umask like in the patch of Apache2 but because iPlanet/SunONE is a multithreaded webserver, each PHP request does not run in its own process (like Apache1, Apache2Prefork), so changing the umask affects all currently running PHP requests and other threads the webserver spawns.
A secure implementation of a umask emulation here would be to save the new umask only in a per-thread-global variable and change the umask only directly before a open() and restore it after the call. This must be together with a locking scheme.

Without that the following could occur:
* PHP script 1 changes umask to (a)
* does some work
* PHP script 2 changes umask to (b) in another thread
* PHP script 1 creates a file (now with the wrong umask (2))

The documentation should be updated that umask SHOULD NOT BE USED in multithreaded webservers, because it changes the umask not only of the running php script.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC