Настраиваю связку mysql+postfix+dovecot+postfixadmin+sasl2 и столкнулся со следующей проблемой: при использовании метода хранения хешей паролей в базе mysql не могу аутентифицироваться с помощью sasl2 в postfix.
Конфиги:
#postfix config file
# uncomment for debugging if needed
#soft_bounce=yes
# postfix main
mail_owner = postfix
setgid_group = postdrop
delay_warning_time = 4
# postfix paths
html_directory = no
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
queue_directory = /var/spool/postfix
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
# network settings
inet_interfaces = all
mydomain = dp.ua
myhostname = myhostname.dp.ua
mynetworks = 10.0.0.0/8,
127.0.0.0/24,
mydestination = $myhostname,
localhost.$mydomain,
localhost
relay_domains = $mydestination
# mail delivery
recipient_delimiter = +
# mappings
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
#local_recipient_maps =
# virtual setup
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual_alias_maps.cf,
regexp:/etc/postfix/virtual_regexp
virtual_gid_maps = static:89
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual_mailbox_maps.cf
virtual_minimum_uid = 89
virtual_transport = virtual
virtual_uid_maps = static:89
# debugging
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
xxgdb $daemon_directory/$process_name $process_id & sleep 5
# authentication
smtpd_sasl_type = cyrus
smtpd_sasl_path = smtpd
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
#smtpd_sasl_local_domain = $myhostname
smtpd_sasl_local_domain = MYDOMAIN
broken_sasl_auth_clients = yes
# tls config
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.pem
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.pem
smtpd_tls_CAfile = /etc/postfix/ssl/smtpd.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
# rules restrictions
# smtpd_client_restrictions = reject_rbl_client zen.spamhaus.org
smtpd_helo_restrictions = permit_sasl_authenticated,
permit_mynetworks,
reject_non_fqdn_hostname
smtpd_sender_restrictions = reject_non_fqdn_sender,
reject_unknown_sender_domain
smtpd_recipient_restrictions = permit_sasl_authenticated,
permit_mynetworks,
reject_unauth_destination,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain
smtpd_helo_required = yes
unknown_local_recipient_reject_code = 550
disable_vrfy_command = yes
smtpd_data_restrictions = reject_unauth_pipelining
# Dovecot config file
auth_mechanisms = plain login cram-md5
passdb {
driver = sql
args = /etc/dovecot-mysql.conf
}
userdb {
driver = sql
args = /etc/dovecot-mysql.conf
}
first_valid_uid = 89
mail_location = maildir:/home/vmail/%d/%u
protocols = pop3 imap
ssl_cert = </etc/postfix/ssl/smtpd.pem
ssl_key = </etc/postfix/ssl/smtpd.pem
log_path = /var/log/dovecot.log
auth_debug = yes
disable_plaintext_auth = no
# /etc/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=postfix user=postfix password=password
default_pass_scheme = MD5-CRYPT
password_query = SELECT password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, 89 AS uid, 89 AS gid FROM mailbox WHERE username = '%u'
# /etc/sasl2/smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 MD5-CRYPT
sql_verbose: yes
sql_engine: mysql
sql_hostnames: 127.0.0.1, localhost, MYDOMAIN
sql_user: postfix
sql_passwd: password
sql_database: postfix
sql_select: select password from mailbox where username = '%u'@'%r'
# cat /usr/share/postfixadmin/config.inc.php | grep encrypt
$CONF['encrypt'] = 'md5crypt';
# mysql> select password from mailbox where username = 'user@MYDOMAIN';
+------------------------------------+
| password |
+------------------------------------+
| $1$f388d975$XJSJ.caT/S2qEw1mq8BQ/1 |
+------------------------------------+
1 row in set (0.00 sec)
# выдержка из лога
Jan 9 23:36:02 server postfix/smtpd[5942]: connect from unknown[10.0.0.208]
Jan 9 23:36:02 server postfix/smtpd[5942]: setting up TLS connection from unknown[10.0.0.208]
Jan 9 23:36:03 server postfix/smtpd[5942]: Anonymous TLS connection established from unknown[10.0.0.208]: TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)
Jan 9 23:36:06 server postfix/smtpd[5942]: warning: SASL authentication failure: Password verification failed
Jan 9 23:36:06 server postfix/smtpd[5942]: warning: unknown[10.0.0.208]: SASL PLAIN authentication failed: authentication failure
Jan 9 23:36:06 server postfix/smtpd[5942]: warning: unknown[10.0.0.208]: SASL LOGIN authentication failed: authentication failure
Jan 9 23:37:46 server postfix/smtpd[5942]: lost connection after AUTH from unknown[10.0.0.208]
Jan 9 23:37:46 server postfix/smtpd[5942]: disconnect from unknown[10.0.0.208]
можно ли хранить вместо паролей открытым текстом в mysql хеши паролей и аутентифицироваться в postfix'е с помощью SASL2? И если нельзя, то как лучше настроить подобную связку?