Page 1 of 1

Php script user id

Posted: Fri Feb 18, 2005 9:53 am
by Endimion
I realized the ownership of the files php creates is not the same as the webhost user id.

For example if my webhost user id is clientx, the user id of files created by php is 99. The result of this is that i dont have access to the files php created through ftp.

I would like to know if there is any way php can work with webhost user id isntead of using its own id.

Thank you.

Posted: Fri Feb 18, 2005 9:57 am
by Chris Corbyn
I don't understand what you mean.... :?

Are you trying the say that you can access any of your PHP files using FTP?

If you mean script access using PHP you probably just need the CHMOD the files to give the correct permissions.

Posted: Fri Feb 18, 2005 10:12 am
by Endimion
it has nothing to do with chmod permissions, on linux each file has its owner attributes, for example see this list:

drwxrwxrwx___93__32136___clientx____4096 Feb 12 13:36 .
drwxr-x---____14__32136____99_______8192 Feb 14 13:08 ..
-rw-r--r--_____1___32136___clientx____21 May 5 2004 .htaccess
drwx---r-x____2____99_______99_______4096 Nov 17 07:37 Akashi
drwx---r-x____2____99_______99_______4096 Feb 6 20:14 Andrea

Like you can see the files belong to different owners (clientx and 99), the files with owner attribute 99 are the files/directories created by php.

Posted: Fri Feb 18, 2005 10:13 am
by Maugrim_The_Reaper
I've happened across this before - he means php generated files (depending on any chmod setting) are under a different owner than the the user associated with his ftp account. i.e. Once PHP creates a file, he cannot ftp into the directory and modify/delete those files.

What you can do is a) check the user associated with php, and the user associated with your ftp account are in the same group - if possible. And ensure files created by PHP have group write permissions.

Posted: Fri Feb 18, 2005 10:17 am
by patrikG
The user notes of chown can be quite useful.

Posted: Fri Feb 18, 2005 10:17 am
by feyd
can also change owner on the files created by php.

Posted: Fri Feb 18, 2005 10:23 am
by Endimion
This is whats on php.ini:

User/Group nobody(99)/99

Guess changing this to the webhost user id might solve the problem

Posted: Fri Feb 18, 2005 10:29 am
by feyd
php is being run under the apache user, 'nobody' in your case. Changing the owner of php.ini shouldn't do a thing other than potentially making php use defaults for all settings, which doesn't help you.

Having PHP change the owner, or permissions on the files is the correct action, unless you want to change the user php runs under..

Posted: Fri Feb 18, 2005 10:41 am
by Endimion
Its not possible for php changing the owner:

Warning: chown(): Operation not permitted in [path] on line 5

on php.net site it says on chown section:
Only the superuser may change the owner of a file.

Guess im not a superuser lol :p

Well, guess it must remain like that, once i asked the server administrator to change the permission because cpanel was displaying a wrong disk usage and the files became inaccessive through web and they had to reset it like it was before.

Anyways, thank you all for helping me :)