大网数据广告活动
服务器运维问答

Procmail recipe, mail owned by root

· 52CE 我爱测

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/ LOGFI…

问题原文

原帖链接 · USD Matt · CC BY-SA 3.0

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"

已采纳解答

原帖链接 · Joe Brailsford · CC BY-SA 3.0

Check the permissions on the junk folder are correct, but could you also add the following to your procmail.cf:

DROPPRIVS=yes

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).

 DROPPRIVS            If  set  to  `yes'  procmail   will   drop   all
                      privileges  it  might  have  had (suid or sgid).
                      This is only useful if  you  want  to  guarantee
                      that the bottom half of the /etc/procmailrc file
                      is executed on behalf of the recipient.

Key part; executed on behalf of the recipient.

Explanation of why this works form user @Tripleee:

The DEFAULT delivery happens after an implicit DROPPRIVS, but if you explicitly deliver something while in privileged mode, you also need to explicitly drop your privileges.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-06-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。