Chown Server Problem

admin

Administrator
Staff member
I'm not sure this is the rigth sub forum.
On my webserver hosted by dh2.net, I have a problem in which I need to set the owner of a folder to the php user.

But the host doesn't allow shell access, and cpanel doesn't seem to have any way to set a file or folder owner.

This leads to me having a folders with 777 permission because otherwise the php user can't write to a folder!

I'd appreciate any help and wisdom from anyone who needed to solve this problem when being hosted by a commercial server.

ThanksHi,Just use 755, as 777 in insecure. It should work as well. Can you elaborate what owner you wish to change to and what script requires it and not the domain owner can't?Regards,Bobbyi tried 755 as a permission and even 775 but it seems that the user phpis not in the group either for the folder.

Bassically I have a form which uploads a file, then the php uses the post information and the function move_uploaded_file to move it from the temp dir to a specific dir.

Now that function is performed by the user 'php'.
So the user 'php' needs write access to the folder I'm uploading to.

So if I had control over the system I would make php the owner of that folder and then a 755 would be perfect.

Unfortunately I can't find a way to change this ownership though.Hello,

Normally this type of problem comes up when you are using mod_php to run your script.

The solution to the problem is to avoid the problem :)

If a file or folder is going to be used by mod_php you want it to be _created_ by mod_php - this means that the php user (usually the webserver user) will start out owning the file and so will have no trouble reading or writing to it later on.i tried 755 as a permission and even 775 but it seems that the user phpis not in the group either for the folder.Bassically I have a form which uploads a file, then the php uses the post information and the function move_uploaded_file to move it from the temp dir to a specific dir.Now that function is performed by the user 'php'.So the user 'php' needs write access to the folder I'm uploading to.So if I had control over the system I would make php the owner of that folder and then a 755 would be perfect.Unfortunately I can't find a way to change this ownership though.It sounds like you got the short end of the stick here. I am surprised how many hosts still prefer to use a non-suexec PHP system - it's extremely insecure and allows any users to fully access (read/write) to any other account's files/directories if owned by the same PHP user (nobody, httpd, apache).Your only option around this is to chmod to 777 - regardless of it being an insecure permission (world-writable) - i don't think it will make much difference as every account on the system is already executing your PHP scripts as the webserver's user.With no shell access - the only way another user is going to have access to your 777 files is to use a piped php/perl script which parses shell commands via common shell functions such as shell_exec, exec, system, ect.You can't use chown without root access. This option is simply not available.hzDylan is correct. Even with SSH you wont be able to change ownership of a file as a regular user. -edit - deleted something dangeroushzDylan is correct. Even with SSH you wont be able to change ownership of a file as a regular user. -edit - deleted something dangerous I saw it! Didnt read too dangerous though.Probably not, but he gave out his host info, and indicated they weren't running a very secure setup in the first place.Have you tried asking your host for assistance?Probably not, but he gave out his host info, and indicated they weren't running a very secure setup in the first place.Point taken.Im kind of scratching my head here...

Im sorry if I am off topic... but is there a particular reason why you are coding this to be this complicated?

I have written a php upload script before, and I didnt need to use SSH to fix the problem (even tho I have root)

Maybe a different approach is in order?
 
Back
Top