cvs: php-src(PHP_4_3) /ext/standard file.c
| From: | Antony Dovgal | Date: | Wed, 27 Oct 2004 12:01:20 +0000 |
| Subject: | cvs: php-src(PHP_4_3) /ext/standard file.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-29038@lists.php.net to get a copy of this message | ||
tony2001 Wed Oct 27 08:01:20 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/standard file.c
Log:
MFH: fix bug #30388 (rename across filesystems loses ownership and permission info)
http://cvs.php.net/diff.php/php-src/ext/standard/file.c?r1=1.279.2.62&r2=1.279.2.63&ty=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.279.2.62 php-src/ext/standard/file.c:1.279.2.63
--- php-src/ext/standard/file.c:1.279.2.62 Fri Sep 24 09:07:18 2004
+++ php-src/ext/standard/file.c Wed Oct 27 08:01:20 2004
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.279.2.62 2004/09/24 13:07:18 derick Exp $ */
+/* $Id: file.c,v 1.279.2.63 2004/10/27 12:01:20 tony2001 Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -1914,9 +1914,30 @@
if (ret == -1) {
#ifdef EXDEV
if (errno == EXDEV) {
- if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) {
- VCWD_UNLINK(old_name);
- RETURN_TRUE;
+ struct stat sb;
+ if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) {
+ if (VCWD_STAT(old_name, &sb) == 0) {
+ if (VCWD_CHMOD(new_name, sb.st_mode)) {
+ if (errno == EPERM) {
+ php_error_docref2(NULL TSRMLS_CC, old_name, new_name, E_WARNING, "%s",
strerror(errno));
+ VCWD_UNLINK(old_name);
+ RETURN_TRUE;
+ }
+ php_error_docref2(NULL TSRMLS_CC, old_name, new_name, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+ if (VCWD_CHOWN(new_name, sb.st_uid, sb.st_gid)) {
+ if (errno == EPERM) {
+ php_error_docref2(NULL TSRMLS_CC, old_name, new_name, E_WARNING, "%s",
strerror(errno));
+ VCWD_UNLINK(old_name);
+ RETURN_TRUE;
+ }
+ php_error_docref2(NULL TSRMLS_CC, old_name, new_name, E_WARNING, "%s",
strerror(errno));
+ RETURN_FALSE;
+ }
+ VCWD_UNLINK(old_name);
+ RETURN_TRUE;
+ }
}
}
#endif