mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
fix bug #30388 (rename across filesystems loses ownership and permission info)
This commit is contained in:
parent
c8cc96e6fe
commit
ceacc834fb
1 changed files with 25 additions and 2 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue