Uploaded over FTP, served by PHP-FPM, and the two disagree about who owns the file

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
635
Points
28
A directory on one of my boxes ended up with two sets of files, half owned by the FTP user and half by the pool user PHP-FPM runs as. Both look fine in a listing. The site works until something tries to write next to a file it does not own.

The symptom that gave it away was WordPress asking for FTP credentials to run an update. It does that when the files are not owned by the user executing PHP, which is correct behaviour and a useful signal, though it took me a while to read it that way instead of as a bug.

What I do now is put the FTP user and the pool user in the same group, set the setgid bit on the document root so anything created inherits that group, and set umask 002 in the pool config so new files come out group writable. After that it stops mattering which path a file arrived by.

The part I am less sure about is doing this on a box with a control panel on top. I have had a panel rewrite ownership during an account rebuild and undo the whole thing. Has anyone found a way to make that stick across a panel update, or do you just re-apply it afterwards?
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top