I rebooted my server today and PHP scripts which use 'link' to move files from one directory to another on the server (wihin the same site) stopped working.
Background:
PHP 4.2.2, Apache 1.3.27, Ensim 3.1.10
Since PHP runs as 'apache', I originally did a little modifying to the Ensim box to get all this to work.
In /etc/group (the main server /etc/, not the site specific one.) I added the following group
www3❌605:admin3,apache
Next, I changed the folders in question on the IP-Based site as follows. All folders in question are within /home/virtual/admin3/var/www/html/:
drwxrwxr-x 2 admin3 www3 4096 Jul 14 18:29 holder
Contents of holder:
-rw-r--r-- 1 admin3 admin3 4765511 Jul 14 16:28 SBPD03-23B-03.mp3
-rw-r--r-- 1 admin3 admin3 7047567 Jul 14 16:23 SBPD03-25B-03.mp3
-rw-r--r-- 1 admin3 admin3 14079077 Jul 14 16:15 SBPD03-26B-03.mp3
-rw-r--r-- 1 admin3 admin3 12136395 Jul 14 15:59 SBPD03-27B-03.mp3
drwxrwxr-x 2 admin3 www3 4096 Jul 14 18:37 oldMP3
drwxrwxr-x 2 admin3 www3 4096 Jul 14 18:40 reserve
The PHP script could then call 'link' and 'unlink' on any files contained within the folders as the GID of the folder was 'www3' and set to 775.
A simple routine could be called and the files would move. I repeat. This all worked (for 8 + months) until a reboot of the server today. The PHP scripts could link and unlink any file in a 'admin3:www3' folder set to 775
Here's some of the code from the file_move routine:
if(!link($move_from,$move_to)) {
Error("Move Failed","Can't Move file to new directory<br>
$move_from<br>$move_to");
} elseif (!unlink($move_from)) {
Error("Unlink Failed","Can't Delete original after moving
file to new directory<br>");
} else {
return true; // file moved
}
Current Situation:
As of this afternoon, when ever I use one of the scripts to move a file from 'holder' to 'reserve' or vice-versa, I get the following error:
Warning: Link failed (Operation not permitted) in /home/virtual/site3/fst/var/www/phpinc/admin/common_vars_fns.php on line 918
Line 918 is the 'link' command in the sample code above.
Any thought?
I've tried turning 'safe_mode' on and off, but it doesn't make a difference. It seems to me as if PHP or apache or something else isn't recognizing the directory as being admin3:www3 0775 and so is failing. If I change the files inside the folder to 0777, then they move. (as noted above, the files are admin3:admin3)
The permission and owners of directories are supposed to trump file permissions, so the fact that the files inside a 775 admin3:www3 directory are 644 admin3:admin3 shouldn't make a difference as 'apache' is a member of 'www3'. (and, it used to work until this afternoon....)
Why would this stop working??