From:             assid at assid dot com
Operating system: debian gnu/linux
PHP version:      5.2.6RC5
PHP Bug Type:     Scripting Engine problem
Bug description:  File handling causes issues

Description:
------------
5.2.6RC starts behaving very strangely if you have a code that sets chmod
and chown on the new file being uploaded.

This function used to work before, and now it starts causing issues.

It seems to crash on chmod, chown, and chgrp

Reproduce code:
---------------
        function handleFileUpload($uploadpath, $filenameprepend, $filesField)
        {
                $filename = NULL;
                if (isset($_FILES[$filesField]['name']) &&
!empty($_FILES[$filesField]['name']) )
                {
                        $pinfo = pathinfo($_FILES[$filesField]['name']);
                        $extn = strtolower($pinfo['extension']);
                        $uploaddir = $uploadpath;
                        $filename = $filenameprepend . '.' . $extn;
                        $uploadfile = $uploaddir . $filename;
                        move_uploaded_file($_FILES[$filesField]['tmp_name'], 
$uploadfile);
                        sleep(2);
                        chmod($uploadfile,"0666");
                        chown($uploadfile,$this->getSystemUser());
                        chgrp($uploadfile,$this->getSystemGroup());

                }
                return $filename;
        }


Expected result:
----------------
The above code block worked on 5.2.4. I believe this is being caused by
Fixed move_uploaded_file() to always set file permissions of resulting file
according to UMASK. (Andrew Sitnikov)

It should set the mode and ownership and group IF the user is explicitly
coding it in.

Actual result:
--------------
Errors like the following show up

Warning: chown() [function.chown]: Operation not permitted in
/home/chinajapantraders/www/scripts/generalfunctions.php on line 43

Warning: chgrp() [function.chgrp]: Operation not permitted in
/home/chinajapantraders/www/scripts/generalfunctions.php on line 44

chmod doesnt give an error, however, the modes arent being set correctly
either. The modes show up as : --w--wx-wT if i set it as 0666 as mentioned
above.

-- 
Edit bug report at http://bugs.php.net/?id=44884&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44884&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44884&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44884&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44884&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44884&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44884&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44884&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44884&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44884&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44884&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44884&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44884&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44884&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44884&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44884&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44884&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44884&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44884&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44884&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44884&r=mysqlcfg

Reply via email to