I'm having an issue where a PHP page running under apache alters destructively a directory's permissions, causing future attempts to access the directory to fail. A very simple script that lists a directory's contents seems to cause this:
Code: Select all
<?php
$cmd = "ls -la /Volumes/ 2>&1";
exec($cmd, $execOut, $exitCode);
echo "<PRE>EXIT CODE = $exitCode<BR/>";
foreach($execOut as $line) {
echo "$line <BR/>";
}
echo "</PRE>";
?>
Code: Select all
EXIT CODE = 1
ls: myshare: Permission denied
total 8
drwxrwxrwt@ 4 root admin 136 Jun 14 12:34 .
drwxrwxr-t 30 root admin 1088 Jun 4 13:09 ..
lrwxr-xr-x 1 root admin 1 Jun 11 16:05 galenhd -> /
Code: Select all
EXIT CODE = 0
total 40
drwxrwxrwt@ 4 root admin 136 Jun 14 12:34 .
drwxrwxr-t 30 root admin 1088 Jun 4 13:09 ..
drwx------ 1 galen staff 16384 Jun 14 09:28 myshare
lrwxr-xr-x 1 root admin 1 Jun 11 16:05 galenhd -> /
I'm pretty confident this bug/issue involves Apache to some degree, because when I take Apache out of the equation, for example by running PHP standalone, I don't see any problems.
OTHER DETAILS:
-- Running on mac Snow Leopard
-- using out-of-the-box Apache and PHP on mac
-- mounted myshare directory via Finder (i.e. smb://myserver/myshare via Go-->Connect to Server... menu)
-- If command is changed to remove "-l" option, it doesn't cause failure
-- SMB server is Windows 2003, although I've also tested this on a linux SMB server, and it also fails, so I don't think the server is at fault
-- Running the same PHP script from the command-line doesn't cause problem -- it only fails when run under Apache
-- Running "sudo ls -la /Volumes" repairs permissions on directory
-- Failure has been occurring for me roughly 1 out of every 20 page hits, but in a random fashion
Surely someone has run into this seemingly simple use case?
Thanks,
Galen