#33176 [Opn->WFx]: umask is not being restored when each request is finished

From: Date: Sun, 29 May 2005 08:20:27 +0000
Subject: #33176 [Opn->WFx]: umask is not being restored when each request is finished
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79658@lists.php.net to get a copy of this message
ID: 33176 Updated by: thetaphi@php.net Reported By: strovato at cdeducation dot org -Status: Open +Status: Wont fix Bug Type: iPlanet related Operating System: Solaris 10 SPARC PHP Version: 4.3.11 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2005-05-29 03:34:22] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33176&edit=1

« previous php.bugs (#79658) next »