Edit: From a post in this topic, found out that my problem wasn't what I thought it was, and ended up solving my problem in aonther topic: http://www.unix.com/showthread.php?p=302076761\#post302076761
Hi, I'm not sure if this is a Unix problem or a PHP problem, but I'll see if anyone here knows.
So I have a PHP script that calls shell_exec('mkdir thefolder'); - for anyone who doesn't know php, shell_exec just throws a command at the command shell. "thefolder" is able to be created, BUT it is somehow created as read-only. When I click the file in Windows and try to uncheck the read-only, it won't let me. I tried deleting it through Unix, didn't work. The only way I could delete the folder was to use shell_exec('rm thefolder'); in PHP.
Now this makes no sense to me, shell_exec is just supposed to send a command to the Shell. calling 'mkdir thefolder' in Unix does not create it as read only, despite being the same command. As well, 'rm thefolder' does not work in the normal Unix, but the PHP script calls it fine.
I'm so confused. Any Ideas?
Thanks,
Graeme
The PHP is running on a Web server (e.g. Apache) with the identity of a special user (e.g. nobody), and it makes sense that only that user on the system is able to remove the directory created by himself. Most Unix Web servers today are installed this way.
Ok thanks, that makes sense.
But I'd assume if I could have it chmod'd so that all users have write access then there wouldn't be a problem? If thats the case then the other thread that i just posted "chmod - "future" changes", if that can get solved, it will probably solve the problem.
oh but one question, is there anyway to change the user PHP is calling as from "nobody" to something else a little more secure?
No, at least on the user (script) level.
However, you can configure Apache to run CGI scripts (recall that PHP scripts may be executed as CGI scripts with PHP CGI executable) in suEXEC mode, which allows scripts to run with the privileges of the script owner instead of the server user. But as I said, few servers I have seen are configured this way with suEXEC.
http://httpd.apache.org/docs/2.2/suexec.html