We have an e-mail server running Postfix (SMTP) and Dovecot (POP/IMAP) on Debian 10. Users cannot log directly on it (SSH), but have access to their homes through NFS.
We would like to use Procmail to sort messages tagged as spam by SpamAssassin (X-Spam-Flag: YES header) in a separate folder for each user, using a global /etc/procmailrc file. This seems easy to do, as shown in https://serverfault.com/questions/488044/send-spam-mail-to-a-special-folder-using-postfix, to give an example.
The question is: we don't want to allow our users to use $HOME/.procmailrc files, for security reasons. Is there a way to prevent Procmail from activating $HOME/.procmailrc for most users, except for some trusted ones?
EDIT:
Considering tripleee's answer, I could then write a /etc/procmailrc file containing a test for privileged users (i.e. users allowed to have a local .procmailrc file) as this:
# /etc/procmailrc
# if the e-mail is flagged as spam, deliver it to $JUNK and stop
:0:
* ^X-Spam-Flag: YES
$JUNK
# if the user is NOT allowed to have a $HOME/.procmailrc,
# then deliver the message to the default mailbox and stop
:0W:
# check whether the user is allowed to have a .procmailrc file
* ! ? check_allowed_user $LOGNAME
$DEFAULT
# else, do nothing (and $HOME/.procmailrc will be activated)
Do you think this is the way to go? If so, I just need to find a simple and robust way to make the check_allowed_user test.