|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-02 10:46 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 10:00:01 2025 UTC |
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; }