I have found a funky situation that I am trying to figure out if it is 
bug or not:

I see this behavior on both redhat 9 and fedora running 

php 4.3.4
httpd(apache) 2.0.48

calling umask(0002) in a script leaves the httpd process with a umask of
2 after exit so that the next process to hit that process gets the new
umask. in other words the environment does not revert to default as the
umask() docs say it should.  This does not happen on my 7.3 box running 
apache-1.3.27-2
php-4.1.2-7.3.6

I found this chasing a rabbit trail of a bug.  This is kind of sneaky
since it only changes the umask for the single httpd process it hits. 
multiple calls to umask(0002) will change every process it hits.

I distilled this down to this test:
BTW this is also file at buzilla.redhat.com as bug number 121454:

http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=121454

1.install umask.php in a directory accessible by the web server 

####### umask.php

<?php
if ( isset( $_GET['newmask']) ) {
    print "newmask is set to $_GET[newmask] calling umask()<br>\n";
    print umask($_GET['newmask']) ."<br>\n";
}
else {
    print "umask is ". umask() . "<br>\n";
}
?>
################# end of umask.php

2. copy chkmask.sh somwhere on the server


########## chkumask.sh  

#!/bin/sh

if [ -n "$1" ] ; then
    echo "setting hostname to input host $1"
    myhost=$1
else
    myhost=$HOSTNAME
fi
echo "using $myhost as wget host"

while [ 1 ]; do
    
    echo -n `date +'%D'` " host: $myhost  "
    
    wget -q -O - "http://$myhost/umask.php";
    sleep 1
done

############ end of of chkumask.sh   

3. run chkumask.sh [hostnameofserver]
this will start looping and making calls to the umask.php script on
the server  defaults to value of $HOSTNAME

4. with a broser or whatever go to
http://servername/locationofumask.php?newmask=0002

5 observe output of chkumask.sh depending on the number of threads
started by httpd the umask changes from 18(octal 22, the default) to 2
for that thread.

refresh the browser several times to have more threads get changed.

Actual Results:  output of chkumask.sh:

using 10.23.0.137 as wget host
04/21/04  host: 10.23.0.137  umask is 2<br>
04/21/04  host: 10.23.0.137  umask is 18<br>
04/21/04  host: 10.23.0.137  umask is 2<br>
04/21/04  host: 10.23.0.137  umask is 2<br>
04/21/04  host: 10.23.0.137  umask is 18<br>
04/21/04  host: 10.23.0.137  umask is 18<br>
04/21/04  host: 10.23.0.137  umask is 18<br>
04/21/04  host: 10.23.0.137  umask is 2<br>
04/21/04  host: 10.23.0.137  umask is 2<br>
04/21/04  host: 10.23.0.137  umask is 18<br>
04/21/04  host: 10.23.0.137  umask is 2<br>

any tips appreciated as well as report wither the behavior is seen or
not on various versions.  I am trying to isolate when this behavior
started or what I have done wrong.


Bret



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to