Forum Moderators: coopster
At my new hosting it's a little different, if I upload a file it'll be assigned to the ownership of my username, but if I create a file it will be under the ownership of 'nobody'. I get a permission denied error when I try to write to any file that is owned by my username.
This creates a problem as I can't edit any files created by nobody without changing the ownership. Last week all the files in my public_html directory changed ownership to my username, even if the owner was 'nobody'. This is a strange problem, it occured again today and the only solution I can find is to delete the files and let them be created again under the owner 'nobody'.
Because I am not the superuser I cannot change file ownership, why hey changed in the first place I am not sure, the support from my new hosting has been almost non existent, they claim the problem lies in my scripts. Even the error_log files have been changed to my username from 'nobody', so they haven't been updated since December 20.
Is there any way of authenticating a script to be able to modify files under my username?
I have suppressed the errors by putting an '@' in front of the file commands, is there any way of outputing a less obvious custom error?
Thanks a lot.
Your username - let's pretend it's 'iceman' - is almost never the same (and really shouldn't be the same) as the name of the user that the Apache server is running under. In your case, Apache runs under the name 'nobody', quite a common setup. When you create files with scripts, these files are owned by the "user" who created them: that's the webserver, or "nobody". In general, you try to set things up so your webserver can only write to the files it needs to write to - otherwise anyone who succeeds in getting your webserver to run one of their scripts can change whatever files the webserver has permissions for.
This might be why those files changed ownership from 'nobody' to your username. It's possible your host runs some kind of script that checks for webserver-owned files, and switches them to your user name. However, I think it's more likely that somehow you, without knowing it, ftp'd these files back up. In that case, when you use ftp, the server sees these as 'your' files (your username, iceman).
What you can do to make files which iceman owns be writeable by the server is chmod them to 666. For directories, it's 777. Writeable by 'the world'. This comes, of course, with consequences for security.
I changed the permissions of the text file again, this time to 666, that fixed it.
Is there any other way to do this, because it would be good for a script to be able to create and add to the text file without having to change the permissions every time.
There are a lot of PHP error functions, is it possible to get the error so that I can output it the way I want?
Thanks.