后缀:SASL 身份验证失败:无法连接到 saslauthd 服务器:权限被拒绝

fla*_*ang 6 postfix saslauthd dovecot sasl

我有一个 Postfix/Dovecot 服务器并运行了大约一周,直到我不得不重新启动它。当我这样做时,事情就停止了。我已经搜索了几个小时但毫无结果。

IMAP 成功验证(尽管 dovecot 被配置为搭载 postfix 验证)。Postfix 不会,而是失败并出现以下错误:SASL authentication failure: cannot connect to saslauthd server: Permission denied

我尝试将 postfix 用户添加到 saslauth 组(不是 sasl,根据几个谷歌结果。)这并没有改变任何东西。Postfix 似乎根本没有/var/spool/postfix/var/目录(它没有/var/,/etc/或任何东西),因此/var/run/saslauthd无法修改任何权限。但是,它在重新启动之前就可以工作,所以我认为这不是问题所在。

我已在调试模式下启动 saslauthd,但它不输出任何内容。我到处搜索并尝试了我能找到的所有解决方案,但似乎没有一个有帮助。

Postfix 配置为PLAINauthLOGIN机制。saslauthd配置为使用 PAM 身份验证(更改为影子没有帮助)。

如果措辞有些不好,我深表歉意,现在是午夜 12 点,我从晚上 9:45 左右就开始处理这个问题。

鸽子会议-n:

# 2.2.13: /etc/dovecot/dovecot.conf
# OS: Linux 3.14.5-200.fc20.x86_64 x86_64 Fedora release 20 (Heisenbug)
auth_mechanisms = plain login
mail_location = maildir:~/Maildir
mbox_write_locks = fcntl
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    auto = create
    special_use = \Drafts
  }
  mailbox Junk {
    auto = create
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    auto = create
    special_use = \Trash
  }
  prefix =
  }
passdb {
  driver = pam
}
protocols = imap pop3
ssl = required
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_cipher_list =      EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4
ssl_key = </etc/pki/dovecot/private/dovecot.pem
ssl_prefer_server_ciphers = yes
ssl_protocols = !SSLv2 !SSLv3
userdb {
  driver = passwd
}
Run Code Online (Sandbox Code Playgroud)

后会议-n:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd     $daemon_directory/$process_name $process_id & sleep 5
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = (example.com)
myhostname = mail.(example.com)
mynetworks = 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix/README_FILES
sample_directory = /usr/share/doc/postfix/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_recipient_restrictions =     permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = cyrus
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
Run Code Online (Sandbox Code Playgroud)

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").
#
# 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       -       n       -       -       smtpd
smtps     inet  n       -       n       -       -       smtpd
      -o smtpd_sasl_auth_enable=yes
      -o smtpd_reject_unlisted_sender=yes
      -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
      -o broken_sasl_auth_clients=yes
#smtp      inet  n       -       n       -       1       postscreen
#smtpd     pass  -       -       n       -       -       smtpd
#dnsblog   unix  -       -       n       -       0       dnsblog
#tlsproxy  unix  -       -       n       -       0       tlsproxy
#submission inet n       -       n       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -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=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       n       -       -       smtpd
#  -o syslog_name=postfix/smtps
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -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=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       n       -       -       qmqpd
pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop  unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
#
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# 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/local/sbin/bsmtp -f $sender $nexthop $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}
Run Code Online (Sandbox Code Playgroud)

saslauthd run_path 是/run/saslauthd

Nil*_*ann 5

告诉 saslauthd 通过其选项在 postfix 的 chroot 监狱中创建套接字-m,例如-m /var/spool/postfix/var/run/saslauthd。在我的 Ubuntu 上,我将此行附加到 /etc/default/saslauthd:

 OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
Run Code Online (Sandbox Code Playgroud)

然后我做了

 service saslauthd stop
 mkdir -p /var/spool/postfix/var/run
 mv /var/run/saslauthd /var/spool/postfix/var/run/
 service saslauthd start
Run Code Online (Sandbox Code Playgroud)

您可能希望在旧位置保留软链接,以防其他服务(如 IMAP 服务)期望找到 /var/run/saslauthd:

 ln -s /var/spool/postfix/var/run/saslauthd/ /var/run/
Run Code Online (Sandbox Code Playgroud)

如果 /var/run/ 是 tmpfs,您可能必须在每次启动后创建该链接,例如 /etc/init.d/saslauthd 中的某个位置


Jim*_*nis 3

我刚刚遇到了类似的问题,最终使用从 Postfix chroot Jail 到 SASL Auth 守护进程的首选路径的绑定挂载来解决该问题:

mkdir -p     /var/spool/postfix/var/run/saslauthd
chgrp sasl   /var/spool/postfix/var/run/saslauthd
mount --bind /var/spool/postfix/var/run/saslauthd /var/run/saslauthd
Run Code Online (Sandbox Code Playgroud)

我还必须稍微更改权限以允许 Postfix 遍历(-x)到该目录。(我没有更改 Postfix 目录 /var/spool/postfix 的权限)...这就是我使用绑定挂载的原因;因为更改 Postfix 权限似乎可能会比仅更改包含 Unix 域套接字和 PID 文件的 saslauthd 目录上的“其他执行”权限带来更多麻烦。

我仍然欢迎您提供有关启用 Postfix 和 SASLauthd 的更好的 HOWTO 指南。

顺便说一句,虽然我自己想出了这个解决方法,但在这个 Serverfault 条目之后(对我来说,此时)Google 中的下一个链接是:

https://github.com/webmin/webmin/issues/58

...这是问题和解决方案的更详细描述。和我自己摸索的基本一样。