Req #21032 [Fbk->NoF]: move_uploaded_file() behavior gives inconsistant file permissions
| From: | php-bugs at lists dot php dot net | Date: | Tue, 30 Dec 2014 10:41:16 +0000 |
| Subject: | Req #21032 [Fbk->NoF]: move_uploaded_file() behavior gives inconsistant file permissions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189357@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=21032&edit=1
ID: 21032
Updated by: php-bugs@lists.php.net
Reported by: tcarter at noggin dot com dot au
Summary: move_uploaded_file() behavior gives inconsistant file
permissions
-Status: Feedback
+Status: No Feedback
Type: Feature/Change Request
Package: *General Issues
Operating System: Redhat Linux
PHP Version: 4.2.3
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2014-04-16 18:00:03] levim@php.net
When moving to a new filesystem, what if you don't the permission to change the permissions?
------------------------------------------------------------------------
[2003-06-12 01:11:36] pprocacci at datapipe dot com
I am by no means a c programmer, but if php streams are implemented the way I think they are, then
the following patch might prove useful. Don't blame me if it doesn't work ;P This patch
is obviously and completly untested. src and dest in _php_stream_copy_to_stream are already open
stream, so in theory, this should work. Correct me if I'm wrong. I'm always willing to
know why it wouldn't ;P
main/streams.c
--- streams.c.bak Thu Jun 12 02:14:11 2003
+++ streams.c Thu Jun 12 02:13:08 2003
@@ -1152,6 +1152,7 @@
size_t readchunk;
size_t haveread = 0;
size_t didread;
+ struct stat sb;
#if HAVE_MMAP
int srcfd;
#endif
@@ -1224,7 +1225,7 @@
}
} else {
if (maxlen == 0) {
- return haveread;
+ goto ENDF;
} else {
return 0; /* error */
}
@@ -1234,6 +1235,9 @@
break;
}
}
+ ENDF:
+ if(fstat(src, &sb) != -1)
+ fchmod(dest, st.st_mode & ~(S_ISUID | S_ISGID));
return haveread;
}
------------------------------------------------------------------------
[2002-12-15 17:35:21] tcarter at noggin dot com dot au
move_uploaded_file() preserves permissions when the source
& destination are on the same filesystem, but if they are
on different filesystems sets them to (0777 & ~umask).
In ext/standard/basic_functions.c move_uploaded_file()
tries to use rename() which preserves permissions, but if
that fails it uses php_copy_file() then unlink() which
does not preserve the permissions.
I believe that the behaviour should be consistant whether
the source and destination are on the same filesystem or
not (eg if php_copy_file() is used the destination should
be chmod()ed to match the source's permissions after the
copy)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=21032&edit=1