Php script user id

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Endimion
Forum Newbie
Posts: 15
Joined: Fri Feb 18, 2005 9:48 am

Php script user id

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Endimion
Forum Newbie
Posts: 15
Joined: Fri Feb 18, 2005 9:48 am

Post 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.
Last edited by Endimion on Fri Feb 18, 2005 10:15 am, edited 1 time in total.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

The user notes of chown can be quite useful.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

can also change owner on the files created by php.
Endimion
Forum Newbie
Posts: 15
Joined: Fri Feb 18, 2005 9:48 am

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
Endimion
Forum Newbie
Posts: 15
Joined: Fri Feb 18, 2005 9:48 am

Post 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 :)
Post Reply