From: kylewong at southa dot com Operating system: linux kernel 2.6.10 PHP version: 4.3.11 PHP Bug Type: *Directory/Filesystem functions Bug description: copy() sometime fail with permission error
Description: ------------ I have a script which unzip an uploaded ZIP file (contains image files) into a temp directory, "/dev/shm/tmp" (tmpfs for speed, I tried to use /tmp but still got the problem), which is owned by "nobody" and 777 in permission. The script will then process the unzipped image files, one by one, by calling an resize_image() function. The resize_image() function will try to resize the image, then copy the resized image to somewhere else. The script works most of the time, but sometime, it failed with something like: [04-Jun-2005 17:19:47] PHP Warning: copy(/dev/shm/tmp/00800040.jpg): failed to open stream: Permission denied in /home/platform/fs_unix.php on line 15 [04-Jun-2005 17:19:48] PHP Warning: copy(/dev/shm/tmp/00800041.jpg): failed to open stream: Permission denied in /home/platform/fs_unix.php on line 15 [04-Jun-2005 17:19:49] PHP Warning: copy(/dev/shm/tmp/00800042.jpg): failed to open stream: Permission denied in /home/platform/fs_unix.php on line 15 [04-Jun-2005 17:19:50] PHP Warning: copy(/dev/shm/tmp/00800043.jpg): failed to open stream: Permission denied in /home/platform/fs_unix.php on line 15 ..... when the error happens, all of the files insize the same zip file will result in same error. I don't really know what's wrong since the scipt sometime works, sometime doesn't Reproduce code: --------------- util.php, $src will == $dest, $target is target size function resize_image($src, $dest, $target) { if (!strcmp($src,$dest)) { $useTemp = true; $out = "$dest.tmp"; } else { $out = $dest; $useTemp = false; } /* resize xxx.jpg to xxx.jpg.tmp at the same directory */ $err = exec_wrapper("convert -quality 85 -size ${target}x${target} $src $out"); if (file_exists("$out") && filesize("$out") > 0) { if ($useTemp) { //// copy back xxx.jpg.tmp to xxx.jpg //// all errors happen here ---> $ret = copy($out, $dest); unlink($out); if (!$ret){ return 0; } return 1; } } else { return 0; } } Expected result: ---------------- fs_copy() should not be failed with "permission denied" error Actual result: -------------- something failed with permission error -- Edit bug report at http://bugs.php.net/?id=33241&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33241&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33241&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33241&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33241&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33241&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33241&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33241&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33241&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33241&r=support Expected behavior: http://bugs.php.net/fix.php?id=33241&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33241&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33241&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33241&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33241&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33241&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33241&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33241&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33241&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33241&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33241&r=mysqlcfg