PDA

View Full Version : PHP and chmod


GCharb
03-23-2005, 10:21 PM
Hello all!

I have created a small but fun online webpage creator, got a problem though!

For me to be able to write to a folder, like a sub-domain, I need to chmod it to 0777, which is a bit of a security gap.
I thought of chmod it to 0777 before writing to the file then chmod it back to lower values after the writting is done.
Anyone knows a way to write to a folder thar is chmod to 0755 or lower?

Thanks for your time

Silmaril8n
03-24-2005, 01:28 PM
Well, the problem is that the folder needs to be owned by the "nobody" user. If it is owned by that user then PHP can write to the files and modify them anyway it chooses. You can ask HR to chown the folder for you (I have in the past), or you can create a folder, chmod 777, and then create another folder using PHP which would set the owner to "nobody". Then you would just chmod the root folder back to 755 or lower and the new folder you created would have the effective permissions.

GCharb
03-31-2005, 03:05 PM
Thanks a bunch, solved the problem. Never actually noticed that the files we're onwed in such a way, even after all these years. I guess you learn everyday! :)

Thanks again!

Gilles

f-stop
03-31-2005, 07:09 PM
Is this something that you are planning on sharing when you get it finished? I am looking for something like that for use on my site.

GCharb
04-06-2005, 11:05 AM
I am not planning to release the codes since it is very specific to what I need and it is in french only.

But you can find php codes at www.hotscripts.com

I made mine from scratch since I wanted to get better at php, and this is definatlly one way to do it.

Gilles