summaryrefslogtreecommitdiff
path: root/main/streams
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2004-10-27 11:58:49 +0000
committerAntony Dovgal <tony2001@php.net>2004-10-27 11:58:49 +0000
commitceacc834fb61b1eadf358fd7daa31a338e14bc6a (patch)
tree2c8310207e5e5bc2981a820c9fecc2a2d93cd0ee /main/streams
parentc8cc96e6fe156fe1a996cf6df30a37907a6dc8e0 (diff)
downloadphp-git-ceacc834fb61b1eadf358fd7daa31a338e14bc6a.tar.gz
fix bug #30388 (rename across filesystems loses ownership and permission info)
Diffstat (limited to 'main/streams')
-rw-r--r--main/streams/plain_wrapper.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 1f48ea4469..a7f7088fc1 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -1021,10 +1021,33 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, char *url_from, c
if (ret == -1) {
#ifdef EXDEV
if (errno == EXDEV) {
+ struct stat sb;
if (php_copy_file(url_from, url_to TSRMLS_CC) == SUCCESS) {
- VCWD_UNLINK(url_from);
- return 1;
+ if (VCWD_STAT(url_from, &sb) == 0) {
+ if (VCWD_CHMOD(url_to, sb.st_mode)) {
+ if (errno == EPERM) {
+ php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+ VCWD_UNLINK(url_from);
+ return 1;
+ }
+ php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+ return 0;
+ }
+ if (VCWD_CHOWN(url_to, sb.st_uid, sb.st_gid)) {
+ if (errno == EPERM) {
+ php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+ VCWD_UNLINK(url_from);
+ return 1;
+ }
+ php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+ return 0;
+ }
+ VCWD_UNLINK(url_from);
+ return 1;
+ }
}
+ php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));
+ return 0;
}
#endif
php_error_docref2(NULL TSRMLS_CC, url_from, url_to, E_WARNING, "%s", strerror(errno));