Web Hosting Talk







View Full Version : Modifying file permission usinga PHP script


talash
09-21-2002, 01:07 PM
Hi,

We are writing a script. This script will need to write to a flat text file. Now, we ar facing a small problem, where i am stuck.

How do i ensure the security of the file and make it modifyable using this script. To write to a flat text file, we possibly need chmod 666. Now if i do that, i possibly make that file insecure.

What i have in mind:

When the edit is required, i chmod the file to 666 and save the file using the PHP script (the script will run under the account of the user whose account contains the files). Once the file is saved, we get back to the old chmod setting.

How is this possible in PHP. Can someone guide me please.

This script will NOT run from dedicated server. It will have to work from a shared hosting account without intervention fromthe root system admin.

Thankx for your help.

Regards
Abhishek

nexcess.net
09-22-2002, 02:32 AM
The best scenerio would be to use the php cgi (if available) in a suexec type confiruation. That way your script runs as you as opposed to as the web server user.

Chris

priyadi
09-22-2002, 02:38 AM
Originally posted by talash


What i have in mind:

When the edit is required, i chmod the file to 666 and save the file using the PHP script (the script will run under the account of the user whose account contains the files). Once the file is saved, we get back to the old chmod setting.


Not possible unless you are using suexec wrapped PHP under CGI mode. PHP under apache module runs under Apache uid. And it is not possible for apache uid to chmod a file belongs to other user.

talash
09-22-2002, 12:54 PM
Hi,

The problem is that weneed a generic solution which is universally applicable. Since we planto sell this script. Allsystem admins are not interested in setting the server config for one site :)

Abhishek