Topic on Project:Support desk

linux importImages.php catch-22 issue

3
Markdhenning (talkcontribs)

We came across an interesting issue. When running importImages.php as root, any subdirectories created in the images directory by this process (php running as root) are owned by root and use its umask. This is as it should be... however, if someone tries to upload an image through the wiki, and the hashing algorithm collides with a subdirectory created by root, it, of course, cannot import the image.

I have tried using

runuser -l apache -c "php importImages.php /tmp/toload" but this fails with the message

This account is currently not available (as it should. no one can log in as the apache user for security reasons).

I have considered making an extension "Upload Image Folder" that would essentially do the same thing, but under the apache thread, but before I go to that effort, is there something I am missing about running the existing maintenance script and having the subdirectories created as apache:apache instead of root:root?

Thank you in advance for your advice

Cordially,

Mark D Henning.

Ciencia Al Poder (talkcontribs)

you should use the sudo command with the user that should own those files

sudo -u apache php importImages.php /tmp/toload
Markdhenning (talkcontribs)

Thank you, Ciencia, That worked fine. I hadn't read sudo's man page correctly and assumed it always ran as root, which would be counter-productive in this case :-)