Hi all, I was directed earlier to use the set uid options which I did. My web server is running as user "apache" and as group "apache". I am running the simple script below trying to create a directory. I have full perms on the box, so that's not a problem. The directory I'm working in, is in the path of my web site. Since I have been having some problems getting this to work, I have included the "getmyuid" and "get_current_user" functions to see what is going on. The script output tells me that I am actually running my script AS 'root', get_current_user() says so. However when I try to create a new directory in this same directory where the script is running, I get a Permission Denied. I also need to say that I do have the u+s set on my script. Currently the permissions on the script are "-rwsr-xr-x". Now, after a lot of testing, the only way this works is if I give "others" the writes to "write" on the current directory - ".". So, even though I should be allowed to create a directory in this directory because of permissions on the "." directory "drwxr-xr-x", as root, it is not. So I then changed perms on "." to "drwxrwxrwx" and it worked. This is unsuitable for me and I would like some input please.
My script is running as root, so then why can't I create the directory?
Thank you,
John
Script:
<?PHP
$uid = getmyuid();
print "UID = $uid<br>";
$curr_user = get_current_user();
print "User = $curr_user<br>";
// I tried these just incase
// but they didn't work either.
// I mean they did not change
// the "." directory permissions.
//chmod(".",777);
//chmod("/website/",777);
//exec("chmod 777 .");
//exec("chmod 777 /website/");
if (!file_exists($directory))
{
mkdir($directory, 0777);
}
?>
OutPut in browser:
#!/usr/bin/php
UID = 0
User = root
Warning: MkDir failed (Permission denied)