PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #41255 move_uploaded_file wrong permissions cgi
Submitted:2 May 2007 12:22am UTC Modified: 2 May 2007 10:46am UTC
From:agrimm61 at gmail dot com Assigned to:
Status:Bogus Category:Filesystem function related
Version:4.4.6 OS:Linux
View/Vote Developer Edit Submission

[2 May 2007 12:22am UTC] agrimm61 at gmail dot com
Description:
------------
When moving an uploaded file with move_uploaded_file while php is
running in cgi mode the originated file has permissions 600. copy()
creates a file with the expected permissions 644. 
As a result the webserver isn't able to read the file.
Safe_Mode is off!

Reproduce code:
---------------
<?
    echo umask();
    copy($_FILES['userfile']['tmp_name'],
"./".$_FILES['userfile']['name'].".copy");
    move_uploaded_file($_FILES['userfile']['tmp_name'],
"./".$_FILES['userfile']['name']);

?>

Expected result:
----------------
output of 18 which is the right umask ( 022 ), so permissions should be
set to 644.

file moved by copy has permissions 644
file moved by move_uploaded_file has permissions 644

Actual result:
--------------
output of 18 which is the right umask ( 022 ), so permissions should be
set to 644.

file moved by copy has permissions 644
file moved by move_uploaded_file has permissions 600

As a hint i added some lines in basic_functions.c to get the expected
behaviour. Here is the patch :

--- ext/standard/basic_functions.c.orig 2007-01-01 10:46:47.000000000
+0100
+++ ext/standard/basic_functions.c      2007-05-02 01:43:22.000000000
+0200
@@ -2867,10 +2867,12 @@

        VCWD_UNLINK(Z_STRVAL_PP(new_path));
        if (rename(Z_STRVAL_PP(path), Z_STRVAL_PP(new_path)) == 0) {
+               VCWD_CHMOD(Z_STRVAL_PP(new_path),420);
                successful = 1;
        } else
                if (php_copy_file(Z_STRVAL_PP(path),
Z_STRVAL_PP(new_path) TSRMLS_CC) == SUCCESS) {
                VCWD_UNLINK(Z_STRVAL_PP(path));
+               VCWD_CHMOD(Z_STRVAL_PP(new_path),420);
                successful = 1;
        }

[2 May 2007 10:46am UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC