I'm using Exim4 to run PHP scripts when an email is received.
This script should create a file in the /var/log/myapp folder if it doesn't exist, otherwise it should just read the file and add more content to the log.
I performed some tests applying the 777 permission on the folder and I saw that the user used by Exim4 is nobody
.
However, in some cases my administrative user (eg bob
) can manually run the PHP file via the PHP CLI and also use these log files.
I ran the commands below to add my user and nobody to write to the folder but only my user can create files, but 'nobody' can't.
sudo groupadd eximapplog
sudo usermod -a -G eximapplog bob
sudo usermod -a -G eximapplog nobody
sudo chgrp -R eximapplog /var/log/myapp
sudo chmod g+rwx /var/log/myapp
sudo chmod -R 775 /var/log/myapp
What could I be doing wrong?