Postfix

使用 Postfix 拒絕 SpamAssassin 發送郵件權限

  • October 18, 2016

我的伺服器工作正常,但我SpamAssassin使用Digital Ocean 的教程安裝。

這是我的/etc/default/spamassassin

# /etc/default/spamassassin
# Duncan Findlay

# WARNING: please read README.spamd before using.
# There may be security risks.

# Change to one to enable spamd
ENABLED=1

# Options
# See man spamd for possible options. The -d option is automatically added.

# SpamAssassin uses a preforking model, so be careful! You need to
# make sure --max-children is not set to anything higher than 5,
# unless you know what you're doing.
SAHOME="/var/log/spamassassin/"
OPTIONS="--create-prefs --max-children 2 --username spamd -H ${SAHOME} -s ${SAHOME}spamd.log"
# Pid file
# Where should spamd write its PID to file? If you use the -u or
# --username option above, this needs to be writable by that user.
# Otherwise, the init script will not be able to shut spamd down.
PIDFILE="${SAHOME}spamd.pid"

# Set nice level of spamd
#NICE="--nicelevel 15"

# Cronjob
# Set to anything but 0 to enable the cron job to automatically update
# spamassassin's rules on a nightly basis
CRON=1

並且/etc/postfix/master.cf

# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
 -o content_filter=spamassassin
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
submission inet n       -       -       -       -       smtpd
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       -       -       -       smtpd
 -o syslog_name=postfix/smtps
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o smtpd_reject_unlisted_recipient=no
#  -o smtpd_client_restrictions=$mua_client_restrictions
#  -o smtpd_helo_restrictions=$mua_helo_restrictions
#  -o smtpd_sender_restrictions=$mua_sender_restrictions
#  -o smtpd_recipient_restrictions=
#  -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
 flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
 flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
 flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
 flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
 flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
 ${nexthop} ${user}
spamassassin unix -     n       n       -       -       pipe
       user=spamd argv=/usr/bin/spamc -f -e
       /usr/sbin/sendmail -oi -f ${sender} ${recipient}
                                                                                                                  129,1         Bot

權限如下:

-rw-r-----   1 root root   329 Oct 17 13:58 dynamicmaps.cf
-rw-r--r--   1 root root  2237 Oct 17 21:18 main.cf
-rw-r-----   1 root root  1359 Oct 17 18:04 main.cf.orig
-rw-r-----   1 root root  6383 Oct 18 08:47 master.cf
-rw-r-----   1 root root  6068 Oct 17 18:20 master.cf.orig
-rw-r-----   1 root root   160 Oct 17 18:18 mysql-virtual-alias-maps.cf
-rw-r-----   1 root root   151 Oct 17 18:18 mysql-virtual-email2email.cf
-rw-r-----   1 root root   148 Oct 17 18:16 mysql-virtual-mailbox-domains.cf
-rw-r-----   1 root root   147 Oct 17 18:17 mysql-virtual-mailbox-maps.cf
-rw-r-----   1 root root 20281 Feb  5  2015 postfix-files
-rwxr-x---   1 root root  8861 Feb  5  2015 postfix-script
-rwxr-x---   1 root root 28047 Feb  5  2015 post-install
drwxr-x---   2 root root  4096 Feb  5  2015 sasl

我收到以下錯誤:

Oct 18 08:57:57 ubuntuserver postfix/pipe[3132]: 40CA0A1A2C: to=<admin@mydomain.com>, relay=spamassassin, delay=356, delays=355/0.03/0/0.71, dsn=4.3.0, status=deferred (temporary failure. Command output: sendmail: fatal: open /etc/postfix/main.cf: Permission denied )

我應該將權限更改為 777 還是配置文件?我認為這是最糟糕的主意。

我剛剛為這個文件夾設置了 744 權限,但它仍然不起作用(我試圖為這個 main.cf 設置 777 權限,仍然不起作用。

Spam Assasin 不以 root 使用者身份執行,spamd而是:

spamassassin unix -     n       n       -       -       pipe
       user=spamd argv=/usr/bin/spamc -f -e
       /usr/sbin/sendmail -oi -f ${sender} ${recipient}

當 Spam Assasin 嘗試將掃描的郵件送回 Postfix 系統時,日誌消息表明 Postfix 配置的權限不正確:

10 月 18 日 08:57:57 ubuntuserver 後綴/管道

$$ 3132 $$: 40CA0A1A2C: to=, relay=spamassassin, delay=356, delays=355/0.03/0/0.71, dsn=4.3.0, status=deferred (暫時失敗。命令輸出: sendmail: fatal: open /etc/postfix/ main.cf:權限被拒絕

sendmail由 Postfix 在您的系統上實現。

您可能以某種方式弄亂了 Postfix 配置文件/etc/postfix/main.cf/etc/postifx文件夾的權限。兩者都應該屬於root並且任何人都可以讀取(但只能對root寫入),該目錄還需要可執行權限集:

$ ls -lad /etc/postfix /etc/postfix/main.cf
drwxr-xr-x 1 root root  146 Aug 12 21:52 /etc/postfix/
-rw-r--r-- 1 root root 1873 Feb 22  2016 /etc/postfix/main.cf

可能有包含憑據的敏感文件/etc/postfix(例如用於 SMTP 智能主機傳送)——確保它們具有嚴格的權限!

引用自:https://serverfault.com/questions/809671