web-dev-qa-db-ja.com

システムアップグレード後にpostfixが正しく機能しない(SASL認証メカニズムなし)

UbuntuServerマシン14.04LTSで実行されているpostfix/dovecot構成が機能していました。次に、_do-release-upgrade_を使用して16.04.2にアップグレードしました。私のメールサービス以外はすべてうまくいったようです。アップデート前はすべてが機能していましたが、今では奇妙な動作をしています。内部LANから接続すると、クライアント側でエラーは発生しませんが、メールやフォルダなどが表示されず、メールサーバーが空のようです。しかし、外部(つまり、mxtoolbox)から接続しようとすると、You hung up on us after we connected. Please whitelist us. (connection lost)が表示されます。 Syslogでは、次のことが発生します。

_ postfix/smtpd[26657]: connect from pws3.mxtoolbox.com[64.20.227.134]
 dovecot: auth: Warning: sql: Ignoring changed user_query in /etc/dovecot/dovecot-sql.conf.ext, because us$
 postfix/smtpd[26657]: fatal: no SASL authentication mechanisms
 postfix/master[21009]: warning: process /usr/lib/postfix/sbin/smtpd pid 26657 exit status 1
 postfix/master[21009]: warning: /usr/lib/postfix/sbin/smtpd: bad command startup -- throttling
_

SASLなしのエラーをすでに確認しましたが、問題を見つけることができませんでした。 _libsasl2-modules_がインストールされ、saslauthdサービスが実行されています。更新の前後で、構成に何も変更していません。

メールシステムにpostfix、dovecot、mysqlデータベースを使用しています。

postconf -n

_append_dot_mydomain = no
biff = no
dovecot_destination_recipient_limit = 1
inet_interfaces = all
inet_protocols = all
local_recipient_maps = $virtual_mailbox_maps
mailbox_size_limit = 51200000
message_size_limit = 51200000
mydestination =
myhostname = mymaildomain.tld
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client sbl.spamhaus.org, check_client_access cidr:/etc/postfix/ip-block, permit
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client sbl.spamhaus.org, check_client_access cidr:/etc/postfix/ip-block
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noplaintext
smtpd_sasl_type = dovecot
smtpd_sender_restrictions = reject_unknown_sender_domain
smtpd_tls_cert_file = /etc/letsencrypt/live/koehnkenet.de/fullchain.pem
smtpd_tls_ciphers = high
smtpd_tls_key_file = /etc/letsencrypt/live/koehnkenet.de/privkey.pem
smtpd_tls_loglevel = 1
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = proxy:mysql:/etc/postfix/virtual/mysql-aliases.cf, proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual/mysql-domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/virtual/mysql-maps.cf, proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_mailbox_maps.cf, proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_catchall_maps.cf
virtual_transport = dovecot
_

systemctl status dovecot -l

_dovecot.service - Dovecot IMAP/POP3 email server
   Loaded: loaded (/lib/systemd/system/dovecot.service; enabled; vendor preset: enabled)
   Active: active (running) since Di 2017-05-02 00:59:41 CEST; 10h ago
     Docs: man:dovecot(1)
           http://wiki2.dovecot.org/
  Process: 21507 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
  Process: 21512 ExecStart=/usr/sbin/dovecot (code=exited, status=0/SUCCESS)
 Main PID: 21515 (dovecot)
   CGroup: /system.slice/dovecot.service
           ├─21515 /usr/sbin/dovecot
           ├─21516 dovecot/anvil
           ├─21517 dovecot/log
           ├─21542 dovecot/config
           ├─26588 dovecot/imap-login
           ├─26592 dovecot/imap
           ├─26662 dovecot/imap-login
           ├─26666 dovecot/imap
           ├─26679 dovecot/auth
           ├─26680 dovecot/ssl-params
           └─26685 dovecot/auth -w
_

systemctl status postfix -l

_    postfix.service - LSB: Postfix Mail Transport Agent
       Loaded: loaded (/etc/init.d/postfix; bad; vendor preset: enabled)
      Drop-In: /run/systemd/generator/postfix.service.d
               └─50-postfix-$mail-transport-agent.conf
       Active: active (running) since Di 2017-05-02 00:28:49 CEST; 11h ago
         Docs: man:systemd-sysv-generator(8)
      Process: 20854 ExecStop=/etc/init.d/postfix stop (code=exited, status=0/SUCCESS)
      Process: 20883 ExecStart=/etc/init.d/postfix start (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/postfix.service
               ├─21009 /usr/lib/postfix/sbin/master
               ├─21011 qmgr -l -t fifo -u
               ├─21015 tlsmgr -l -t unix -u -c
               └─25923 pickup -l -t fifo -u -c
_

systemctl status saslauthd -l

_saslauthd.service - LSB: saslauthd startup script
   Loaded: loaded (/etc/init.d/saslauthd; bad; vendor preset: enabled)
   Active: active (running) since Di 2017-05-02 00:27:59 CEST; 11h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 20756 ExecStop=/etc/init.d/saslauthd stop (code=exited, status=0/SUCCESS)
  Process: 20775 ExecStart=/etc/init.d/saslauthd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/saslauthd.service
           ├─20799 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 5
           ├─20800 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 5
           ├─20801 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 5
           ├─20802 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 5
           └─20803 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 5

Mai 02 00:27:59 Mydomain systemd[1]: Starting LSB: saslauthd startup script...
Mai 02 00:27:59 Mydomain saslauthd[20775]:  * Starting SASL Authentication Daemon saslauthd
Mai 02 00:27:59 Mydomain saslauthd[20799]: detach_tty      : master pid is: 20799
Mai 02 00:27:59 Mydomain saslauthd[20799]: ipc_init        : listening on socket: /var/run/saslauthd/mux
Mai 02 00:27:59 Mydomain saslauthd[20775]:    ...done.
Mai 02 00:27:59 Mydomain systemd[1]: Started LSB: saslauthd startup script.
_

/ etc/postfix/main.cf

_smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/letsencrypt/live/mydomain.tld/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/mydomain.tld/privkey.pem
smtpd_use_tls=yes

# Disable SSLv2/3 as they are vulnerable
smtpd_tls_protocols = !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_ciphers = high

smtpd_tls_loglevel = 1


myhostname = mydomain.tld
myorigin = /etc/mailname
mydestination =
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 51200000
message_size_limit = 51200000
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

###### SASL Auth ######
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noplaintext

###### Use Dovecot LMTP Service to deliver Mails to Dovecot ######
#virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_transport = dovecot
dovecot_destination_recipient_limit=1

##### Only allow mail transport if client is authenticated or in own network (PHP Scripts, ...) ######
smtpd_recipient_restrictions =
        permit_mynetworks,
        permit_sasl_authenticated,
        reject_unauth_destination,
        reject_rbl_client sbl.spamhaus.org,
        check_client_access cidr:/etc/postfix/ip-block,
        permit
smtpd_sender_restrictions = reject_unknown_sender_domain

###### MySQL Connection ######
virtual_alias_maps = proxy:mysql:/etc/postfix/virtual/mysql-aliases.cf, proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/virtual/mysql-maps.cf, proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_mailbox_maps.cf,  proxy:mysql:/etc/postfix/virtual/mysql_virtual_alias_domain_catchall_maps.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/virtual/mysql-domains.cf
local_recipient_maps = $virtual_mailbox_maps
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client sbl.spamhaus.org, check_client_access cidr:/etc/postfix/ip-block
_

/ etc/postfix/master.cf

_smtp       inet  n       -       y       -       -       smtpd

dovecot   unix  -       n       n       -       -       pipe
    flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -d ${recipient}
_

doveconf -n

_# 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.13 (7b14904)
# OS: Linux 4.4.0-75-generic x86_64 Ubuntu 16.04.2 LTS
auth_mechanisms = plain login
base_dir = /var/run/dovecot/
first_valid_uid = 150
last_valid_uid = 150
mail_gid = mail
mail_home = /media/daten/vmail/%d/%n
mail_location = maildir:~/mail:LAYOUT=fs
mail_privileged_group = mail
mail_uid = vmail
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
postmaster_address = [email protected]
protocols = " imap lmtp"
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-userdb {
    group = mail
    mode = 0600
    user = vmail
  }
}
service lmtp {
  unix_listener lmtp {
    group = postfix
    mode = 0660
    user = postfix
  }
  user = vmail
}
ssl = required
ssl_cert = </etc/letsencrypt/live/mydomain.tld/fullchain.pem
ssl_cipher_list = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA
ssl_key = </etc/letsencrypt/live/mydomain.tld/privkey.pem
_

MySQLが機能して実行されており、資格情報も機能しています。dovecotのSQLクエリも機能しており、正しいデータを出力しています。phpmyadminで使用しようとすると、postfixadminも機能します。ハードドライブがマウントされており、パスも正しいです。vmailフォルダにメールやフォルダなどが含まれています。パブリックWebから接続できない理由はわかりませんが、ローカルネットからのみ、メールやフォルダがポストボックスに表示されません。

2
C0dR

私は問題を見つけました。問題は私が使用したことでした

smtpd_sasl_security_options = noanonymous,noplaintext

しかし、smtpd_tls_auth_only = yesを設定しなかったため、プレーンテキスト接続は即座に拒否されました。

ここで答えが見つかりました: http://postfix.1071664.n5.nabble.com/quot-smtpd-sasl-security-options-noplaintext-quot-with-dovecot-td25165.html

2
C0dR