
多年來(使用 EL6 及之前的版本),我已經在 /etc/aliases 文件中成功使用了這樣的條目:
bugs: /var/spool/mail/bugs
這個想法是,可以將發送給非使用者的郵件放入文件中以供以後處理或存檔。使用 RHEL7 或 CentOS7 時,這些條目會出現以下兩個錯誤。
首先,在沒有建立錯誤檔案的情況下,郵件日誌錯誤「無法獨佔建立檔案:權限被拒絕」:
May 16 12:17:04 foobar postfix/local[17510]: 3D313673442: to=<[email protected]>, relay=local, delay=0.12, delays=0.08/0.02/0/0.02, dsn=5.2.0, status=bounced (cannot append message to file /var/spool/mail/bugs: cannot create file exclusively: Permission denied)
其次,如果我預先建立一個具有合理所有權+上下文的檔案:
ls -l /var/spool/mail/bugs
-rw-rw----. 1 postfix mail 0 May 7 19:34 /var/spool/mail/bugs
ls -Z /var/spool/mail/bugs
-rw-rw----. postfix mail system_u:object_r:mail_spool_t:s0 /var/spool/mail/bugs
我收到“無法建立鎖定檔案”錯誤
May 16 12:11:43 foobar postfix/local[17422]: warning: unable to create lock file /var/spool/mail/bugs.lock: Permission denied
我能夠將訊息傳遞到具有以下可怕權限(1777 和 666)的文件,但是出於安全原因這顯然是不可接受的:
# ll -d /var/spool/mail; ll /var/spool/mail/bugs
drwxrwxrwt. 2 root mail 52 May 16 13:36 /var/spool/mail
-rw-rw-rw-. 1 postfix mail 6913 May 16 13:31 /var/spool/mail/bugs
EL7 是 postfix-2.10'ish,EL6 是 postfix-2.6'ish。
答案1
main.cf
解決這個問題的方法是在參數中進行設置,而無需建立新用戶default_privs = mail
。
請記住,不鼓勵對 default_privs 使用 root 或 postfix。