Search code examples
linuxwordpresssetuidsticky

Can I use setuid or sticky to make a file created by PHP a certain user?


I'm using WordPress and I want files created by WordPress to have the user of the file that created them, not the user the web server is running as. For example, my WordPress files and directories are owned by philip in the group www-data. When WordPress creates a file, I want the owner of the file to be philip and not www-data.

Is this possible? My suspicion is it can be achieve with setuid or sticky bit, but I'm not sure how to apply it.


Solution

  • Not without a lot of extra effort. From what you're describing, it sounds like you're probably running PHP using mod_php or something similar; that will always run within the web server, as the web server user. setuid/setgid only work when there's a new process being executed, which isn't the case here.

    You can work around this by running PHP using CGI or FastCGI (which'll let you run all PHP scripts as your own user), but that's a lot of extra setup that you probably don't want to get into.