Re: Creating Files

From: Date: Thu, 04 Jan 2001 21:04:05 +0000
Subject: Re: Creating Files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32732@lists.php.net to get a copy of this message
> I am having some problems with files being created by a script. The > directory they are created in has had its mode changed to 777 so that the > files can be created by the script. The script uses fopen with "a" to create > the file. > > Whereas all my other files are owned by me (pdunford) and can be accessed > using the FTP client, the newly created file is owned by "nobody" and > attempts to view or download it by the FTP client are refused. How can I > ensure when creating the file that it is owned by user "pdunford" ? > Obviously I want to be able to do this in the script without using any other > tools. When PHP runs, it runs as user "nobody". This is good, because if it ran as "pdunford", then *anybody* with access to your machine could write a PHP script and use it to open/read/write all your files. That would be very bad, particularly on a shared server with a couple hundred users. There are some builtin file-system commands to PHP that might include chown() that you might be able to use to make a file owned by "pdunford". But you should *NOT* leaved file as 777. 777 is excessively dangerous. Anybody could dump any sort of nasty thing into such a file and execute it. Once you get it working, work out the minimum permissions you need to make it all work.

« previous php.general (#32732) next »