|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-12-15 17:35 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 19:00:02 2025 UTC |
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; }