Quote:
Originally Posted by pizzipie
Thanks for your replys.
Using Firefox, I now have a directory created. However it has the Owner/Group set as www-data and Permissions set to 0744. I had set mode to 0766 but that was ignored.
When run from the Command line in a Terminal this doesn't happen. Owner/Group is set to $user:$user and Permissions were set to 0764, however,as above I had set mode to 0766 and this was ignored.
chown() doesn't work so I can't change the Owner back to $user:$user.
How do I fix this???
R
|
You need to realize that when "using Firefox" you are actually using your web server and running as the web server user,
www-data in your case. The web server and the PHP it processes are running in a
totally different context than when run as a system user,
rick or
root, in the shell.
The www-data user should not have access permission to system user directories and sane defaults and built-in limits prevent it from doing known, potentially harmful things such as creating directories and files where it ought not do so.
Trying to write a PHP script to work the same when run in a shell by a system user, and when run in web server context is problematic at best and probably not what you want to do.
If you really want your user rick to be able to do these things in his home directory using PHP running under a web server, then add him to the web server group (www-data) and create a virtual host with a server root directory under /home/rick owned by rick:www-data. Then the web server will be able to write and make directories there and rick can run from a shell there.
Additionally, never, ever, do this...
Quote:
All permissions on php script are set to 777. Desktop permissions are set to 777 to test this.
|
...you only introduce additional confusion at best, and trigger other problems.
Why would you even try that as a troubleshooting method (rhetorical question)? Because you do not yet understand the how and why of those permissions and you think, mostly incorrectly, that 777 will mask permission problems temporarily, "
to test this".
Realize that doing this is a shot in the dark with a loaded weapon and _always_ creates additional problems! Learn not to do that!
The next time the you think, "I'll set perms to 777...", pause and try to explain to yourself what you expect that to accomplish. When you realize that you probably
can't explain it to yourself, refrain from doing so and try to better understand what is actually happening.
For example, in this case the answer would have been, "Because the script in Firefox cannot create the directory. Why is that?". And the answer would have been, "Because when 'running in Firefox' I am running as the web server user, www-data, which does not have access to rick's home directory...". Which would lead to a solution, not another problem wearing a mask.
So I would suggest that you divide the problem into its natural parts:
1. How to manage these images from a shell, maybe using PHP as the scripting language.
2. How to write a web server application in PHP which does the same tasks (code).
3. How to configure a web server virtual host to support this application (paths, ownerships, permissions).
4. How much code can be shared between shell and web server application, and what parts should be separate?
The method and understanding the various aspects of the problems will lead to a solution.