ownership problems

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
pennywaffer
Forum Newbie
Posts: 2
Joined: Sun Oct 26, 2003 11:13 am

ownership problems

Post by pennywaffer »

This is more of a Unix-related problem, but maybe you guys now how to fix it. I have a php script that creates some directories and files on my server. The script then assigns itself as the sole owner of the files, prohibiting me from modifiying or removing them afterwards. So the only way I can remove them or do anything with them is through another script. The problem ( apart from this being quite annoying) is that I need the users of my website to be able to store and delete files from those new folders using FTP. Right now that doesn't work because the ftp connection gets established with my personal username, and the files in question are only allowed to be changed by the script because of the ownership settings.

What I want basicly is to add my own username as an valid owner of those files, so I can perform actions on them without having to use php.
I tried to let the script change ownership with chown(), but it gives me an error: (Warning: chown() [function.chown]: Operation not permitted ). When I try to do a chown through my shell it doesn't work either.
(chown: changing ownership of <filename>: Operation not permitted)
Chmod and chgrp didn't make any difference.

I don't have root access on my server, but surely there's a way to let my own scripts share their files with me? If you have the answre please let me know!

thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Chmod and chgrp didn't make any difference.
does that mean your scripts are not allowed to change the premissions and assigned group?
---
You might ask the admin if he/she/it can change the top-directory's group to a group you're a member of, set group-write/read permissions and the group-sticky bit (so that any subdirectory created gets the same group-settings)
pennywaffer
Forum Newbie
Posts: 2
Joined: Sun Oct 26, 2003 11:13 am

Post by pennywaffer »

thanks for the reply!

I kind of solved the problem already, it turned out it had something to with a safemode bug in php.
I found info on it here: http://bugs.php.net/bug.php?id=24604

I fixed it this way:

I added this line before every mkdir(); call in my script:

$old_umask = umask(0);

I'm not exactly sure what it does, but the problems dissapeared. The script still owns my files but now at least I have full access to them
Post Reply