PHP GENERAL 8 RE PHP ABOUT WRITING PERMISSIONS
Date: Tue, 8 Jul 2003 16:31:57 +0200

Subject: Re: [PHP] about writing permissions
From: corwin@no-spam (Martin Hudec)

Hello,

On Tuesday July 8 2003 15:42, George Papatheodorou wrote:
> I noticed that in all versions before php5 (I haven't seen this one > yet), a script cannot open a file for writing mode is the file's > owner is different from php's owner.
if user2 other than owner is trying to write to file which does not have permission to write for group in which user2 is, or write for others, then write will fail
like in
rw-r--r-- user group file.txt only user has permission to write
or in
rw-rw-r-- user group file.txt only user and users attached to group have permission to write...

> Eg when php's owner is apache > and test.php's owner is user1, user1's script cannot write in > test.php but it can write to test2.php which is owned by apache.
All scripts on webserver run with owner/uid of apache (like nobody, apache or such), therefore you have to set correct permissions to files....

if test.php is set to rw-r--r-- user1 group then only user1 is allowed to write to it....

test2.php is set to rw-r--r-- apache group... so apache can write there
> there any solution to this problem? (except making apache own all > files). Sorry if my question is kinda newbish or stupid and sorry for > my poor english too. Thank you in advance.

solution is to set all files to be writable by group (rw-rw-r--) by chmod 664 and add apache owner/uid to group which is listed as ownergroup of that file (change group id of apache in its configuration file to group).

like
rw-rw-r-- user group test.php
I hope I have explained it a bit to you.

-- Martin Hudec ------------------------------------
:@no-spam corwin@no-spam :w: http://www.corwin.sk :m: +421.907.303.393

"In google non est, ergo non est."
- unknown IRC operator ------------------------------------