I'm using a combination of Postfix and Procmail to handle inbound email on one of my servers. Each user has a local account and I've been using the below /usr/local/etc/procmailrc
successfully for years:
DEFAULT=$HOME/mail/
LOGFILE=/var/log/procmail
I've recently added a recipe to direct messages flagged as spam to a separate folder:
:0
* ^X-Spam-Flag: YES
$HOME/mail/.Junk/
However, it seems in some cases the messages going into this folder are owned by root instead of the correct user. I've never had this issue with the Inbox, and it also seems like it only affects certain users.
I managed to catch one of the Procmail processes in ps
and it does seem to run as the correct user. (This user also has root owned mail in the Junk folder)
# ps axu | grep procmail
{correct-local-username} 7402 0.0 0.2 12140 1780 ?? Ss 11:37AM 0:00.01 /usr/local/bin/procmail -a
Does anyone have an idea why messages handled by the recipe would end up owned by root, while messages going to the default folder would get the correct owner?
Is there anything I can do (even if it's hacky such as calling chown from the Procmail recipe) to make sure the messages are always owned by the correct user?
In case it's of importance, Procmail is configured in Postix as follows:
mailbox_command = /usr/local/bin/procmail -a "$EXTENSION"
Check the permissions on the junk folder are correct, but could you also add the following to your procmail.cf:
I'm no expert on procmail, but according to this man entry, it should drop any priveleges that procmail has had, and the recipient doesn't (emphasis mine).
Key part; executed on behalf of the recipient.
Explanation of why this works form user @Tripleee: