SASL não autentica SMTP

1. SASL não autentica SMTP

Paulo Roberto Jentsch
do_morro

(usa Debian)

Enviado em 03/05/2015 - 23:02h


Boa noite, pessoal do Viva o Linux

Estou com uma bucha que não consigo resolver.

Subi um servidor de e-mails com Debian Wheezy, Postfix, PostfixAdmin, Courier, PAM, MySQL e SASL.

O mesmo recebe e envia normalmente pelo webmail por causa do permit_mynetworks configurado no postfix.

O problema é que não autentica com SASL de jeito nenhum.

Ao configurar a conta criada num cliente de e-mail não é possível enviar. Dá erro de senha.

Criei uma conta de e-mail de teste. Postarei com a senha para verificação do hash, mas vou ocultar o domínio e o IP.

Seguem os arquivos de configuração:

/etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
myorigin = $mydomain

smtpd_banner = $myhostname ESMTP $mail_name
biff = no
debug_peer_level = 100

append_dot_mydomain = no

readme_directory = no

myhostname = mail.meudominio.com.br
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mydestination = $myhostname, localhost.localdomain, mailfertil.$mydomain
relayhost =
mynetworks_style = host
mynetworks = 127.0.0.0/8 xxx.xxx.xxx.xxx/32
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4

#SASL
smtpd_sasl_local_domain =
smtpd_sasl_path = /etc/postfix/sasl/smtpd
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_unauth_destination

smtpd_tls_auth_only = no
smtpd_sasl_authenticated_header = yes

#MySQL
transport_maps = mysql:/etc/postfix/mysql_transport_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_transport = maildrop
virtual_minimum_uid = 8
virtual_uid_maps = static:8
virtual_gid_maps = static:8
virtual_mailbox_base = /var/virtual


/etc/default/saslauthd



START=yes

DESC="SASL Authentication Daemon"

NAME="saslauthd"

MECHANISMS="pam"

MECH_OPTIONS=""

THREADS=5

OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"



/etc/pam.d/smtp


auth required /lib/security/pam_mysql.so user=usuario passwd=senha host=127.0.0.1 db=postfix table=mailbox usercolumn=username passwdcolumn=password crypt=1
account sufficient /lib/security/pam_mysql.so user=usuario password=senha host=127.0.0.1 db=postfix table=mailbox usercolumn=username passwdcolumn=password crypt=1


/etc/postfix/sasl/smtpd.conf


pwcheck_method: saslauthd
mech_list: plain login
log_level: 9
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: 127.0.0.1
sql_user: usuario
sql_passwd: senha
sql_database: postfix
sql_select: select password from mailbox where username = '%u'


Foi criada a conta de e-mail teste@meudominio.com.br com a senha teste123testando

Ao tentar enviar por essa conta (ou qualquer outro) dá erro.

Segue o log

/var/log/mail.log

May 3 18:57:06 meuhostname postfix/smtpd[14786]: connection established
May 3 18:57:06 meuhostname postfix/smtpd[14786]: master_notify: status 0
May 3 18:57:06 meuhostname postfix/smtpd[14786]: name_mask: resource
May 3 18:57:06 meuhostname postfix/smtpd[14786]: name_mask: software
May 3 18:57:06 meuhostname postfix/smtpd[14786]: warning: hostname 186-203-12-51.ded.intelignet.com.br does not resolve to address 186.203.12.51: Name or service not known
May 3 18:57:06 meuhostname postfix/smtpd[14786]: connect from unknown[186.203.12.51]
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: unknown: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: 186.203.12.51: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: unknown: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: 186.203.12.51: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: smtp_stream_setup: maxtime=300 enable_deadline=0
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostname: unknown ~? 127.0.0.0/8
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostaddr: 186.203.12.51 ~? 127.0.0.0/8
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostname: unknown ~? xxx.xxx.xxx.xxx/32
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostaddr: 186.203.12.51 ~? xxx.xxx.xxx.xxx/32
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostname: unknown ~? xxx.xxx.xxx.xxx/32
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostaddr: 186.203.12.51 ~? xxx.xxx.xxx.xxx/32
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostname: unknown ~? [::ffff:127.0.0.0]/104
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostaddr: 186.203.12.51 ~? [::ffff:127.0.0.0]/104
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostname: unknown ~? [::1]/128
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_hostaddr: 186.203.12.51 ~? [::1]/128
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: unknown: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: 186.203.12.51: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: send attr request = connect
May 3 18:57:06 meuhostname postfix/smtpd[14786]: send attr ident = 587:186.203.12.51
May 3 18:57:06 meuhostname postfix/smtpd[14786]: private/anvil: wanted attribute: status
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute name: status
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute value: 0
May 3 18:57:06 meuhostname postfix/smtpd[14786]: private/anvil: wanted attribute: count
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute name: count
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute value: 1
May 3 18:57:06 meuhostname postfix/smtpd[14786]: private/anvil: wanted attribute: rate
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute name: rate
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute value: 1
May 3 18:57:06 meuhostname postfix/smtpd[14786]: private/anvil: wanted attribute: (list terminator)
May 3 18:57:06 meuhostname postfix/smtpd[14786]: input attribute name: (end)
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 220 mail.meudominio.com.br ESMTP Postfix
May 3 18:57:06 meuhostname postfix/smtpd[14786]: xsasl_cyrus_server_create: SASL service=smtp, realm=(null)
May 3 18:57:06 meuhostname postfix/smtpd[14786]: name_mask: noanonymous
May 3 18:57:06 meuhostname postfix/smtpd[14786]: < unknown[186.203.12.51]: EHLO [192.168.1.17]
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: unknown: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: match_list_match: 186.203.12.51: no match
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-mail.meudominio.com.br
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-PIPELINING
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-SIZE 10240000
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-VRFY
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-ETRN
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-AUTH DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-AUTH=DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-ENHANCEDSTATUSCODES
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250-8BITMIME
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 250 DSN
May 3 18:57:06 meuhostname postfix/smtpd[14786]: < unknown[186.203.12.51]: AUTH CRAM-MD5
May 3 18:57:06 meuhostname postfix/smtpd[14786]: xsasl_cyrus_server_first: sasl_method CRAM-MD5
May 3 18:57:06 meuhostname postfix/smtpd[14786]: xsasl_cyrus_server_auth_response: uncoded server challenge: <2097487184.4630551@mail.meudominio.com.br>
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 334 PDIwOTc0ODcxODQuNDYzMDU1MUBtYWlsLm9wdGljYWxob3N0Lm5ldC5icj4=
May 3 18:57:06 meuhostname postfix/smtpd[14786]: < unknown[186.203.12.51]: dGVzdGVAb3B0aWNhbGhvc3QubmV0LmJyIDlmZjlmNDA4OGUwOWNhNDRmMGQ4YTc3YWFlYmYxOWVi
May 3 18:57:06 meuhostname postfix/smtpd[14786]: xsasl_cyrus_server_next: decoded response: teste@meudominio.com.br 9ff9f4088e09ca44f0d8a77aaebf19eb
May 3 18:57:06 meuhostname postfix/smtpd[14786]: warning: unknown[186.203.12.51]: SASL CRAM-MD5 authentication failed: authentication failure
May 3 18:57:06 meuhostname postfix/smtpd[14786]: > unknown[186.203.12.51]: 535 5.7.8 Error: authentication failed: authentication failure


Outros testes:

Usando o testsaslauthd. O primeiro foi feito corretamente e o segundo com a senha errada pra desencargo de consciência.

root@meuhostname:/# testsaslauthd -u teste@meudominio.com.br -p teste123testando -f /var/spool/postfix/var/run/saslauthd/mux -s smtp
0: OK "Success."

root@meuhostname:/# testsaslauthd -u teste@meudominio.com.br -p teste123testano -f /var/spool/postfix/var/run/saslauthd/mux -s smtp
0: NO "authentication failed"


Dando um SELECT no banco do MySQL:

mysql> select * from mailbox where username = 'teste@meudominio.com.br' and active = 1;
+--------------------------+------------------------------------+----------------+---------------------------+-------+------------+--------------------+---------------------+---------------------+--------+
| username | password | name | maildir | quota | local_part | domain | created | modified | active |
+--------------------------+------------------------------------+----------------+---------------------------+-------+------------+--------------------+---------------------+---------------------+--------+
| teste@meudominio.com.br | $1$fadc6fa2$TWXmlJ.TFpztGY2eTTQM3. | Conta de teste | meudominio.com.br/teste/ | 0 | teste | meudominio.com.br | 2015-05-03 19:04:22 | 2015-05-03 19:04:22 | 1 |
+--------------------------+------------------------------------+----------------+---------------------------+-------+------------+--------------------+---------------------+---------------------+--------+
1 row in set (0.00 sec)


Alguém pode me dar uma luz? Já estou sem ideias!

Desde já agradeço.


Paulo





  






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts