O Dovecot não pode autenticar através do IMAP

1

Eu quero configurar um servidor de email com postfix + postgresql e dovecot. No momento eu posso enviar e-mails para o servidor de e-mail, mas não consigo me conectar a ele com o meu cliente de e-mail porque ele diz que a senha está errada ... Também há um erro semelhante nos logs do meu servidor. Eu também estou usando o postfix-admin e dovecot 2.2.10. Aqui está o meu log do servidor.

Jan 15 20:06:34 myserver dovecot[18749]: auth: Debug: sql([email protected],83.32.150.111,<Dnt42AfwnQBTIJZv>): MD5-CRYPT(mypassword) != 'b6486d12312310sa90sa98312df96acf7
Jan 15 20:06:36 myserver dovecot[18749]: auth: Debug: client passdb out: FAIL        1        [email protected]

Mais alguns detalhes sobre minha consulta sql

-- Logs begin at Tue 2013-07-30 12:31:36 UTC, end at Thu 2014-01-16 11:06:05 UTC. --
Jan 16 11:03:05 myserver dovecot[14711]: auth: Debug: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): query: SELECT username as user, password, '/home/vmail/example.com/[email protected]' as userdb_home, 'maildir:/home/vmail/example.com/[email protected]' as userdb_mail, 5000 as  userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '[email protected]' AND active = '1'
Jan 16 11:03:05 myserver postgres[14694]: LOG:  statement: SELECT username as user, password, '/home/vmail/example.com/[email protected]' as userdb_home, 'maildir:/home/vmail/example.com/[email protected]' as userdb_mail, 5000 as  userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '[email protected]' AND active = '1'
Jan 16 11:03:05 myserver dovecot[14711]: auth: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): Password mismatch
Jan 16 11:03:05 myserver dovecot[14711]: auth: Debug: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): MD5-CRYPT(mypassword) != 'ads09d09sa9das90dsa89das099dsa90ads90asd09980dsa98dsa0909dsa980'
Jan 16 11:03:05 myserver dovecot[14711]: auth: Debug: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): query: SELECT username as user, password, '/home/vmail/example.com/[email protected]' as userdb_home, 'maildir:/home/vmail/example.com/[email protected]' as userdb_mail, 5000 as  userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '[email protected]' AND active = '1'
Jan 16 11:03:05 myserver postgres[14694]: LOG:  statement: SELECT username as user, password, '/home/vmail/example.com/[email protected]' as userdb_home, 'maildir:/home/vmail/example.com/[email protected]' as userdb_mail, 5000 as  userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '[email protected]' AND active = '1'
Jan 16 11:03:05 myserver dovecot[14711]: auth: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): Password mismatch
Jan 16 11:03:05 myserver dovecot[14711]: auth: Debug: sql([email protected],83.32.150.111,<OuSwXhTw9gBTIJZv>): MD5-CRYPT(mypassword) != 'ads09d09sa9das90dsa89das099dsa90ads90asd09980dsa98dsa0909dsa980'
Jan 16 11:03:07 myserver dovecot[14711]: auth: Debug: client passdb out: FAIL        1        [email protected]
Jan 16 11:06:05 myserver dovecot[14711]: imap-login: Disconnected: Inactivity (auth failed, 1 attempts in 180 secs): user=<[email protected]>, method=PLAIN, rip=83.32.150.111, lip=176.58.120.193, TLS, session=<OuSwXhTw9gBTIJZv>

Este é o meu /etc/postfix/main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/bin
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = localhost
unknown_local_recipient_reject_code = 550
mynetworks_style = host
relay_domains = $mydestination
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps
home_mailbox = Maildir/
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
sendmail_path = /usr/bin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix/sample
readme_directory = /usr/share/doc/postfix
inet_protocols = ipv4
relay_domains = *
virtual_alias_maps = pgsql:/etc/postfix/virtual_alias_maps.cf
virtual_mailbox_domains = pgsql:/etc/postfix/virtual_domains_maps.cf
virtual_mailbox_maps = pgsql:/etc/postfix/virtual_mailbox_maps.cf
virtual_mailbox_base = /home/vmail
virtual_mailbox_limit = 512000000
virtual_minimum_uid = 5000
virtual_transport = virtual
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = /var/run/dovecot/auth-client
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = $smtpd_sasl_security_options
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/private/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.key
smtpd_sasl_local_domain = $mydomain
broken_sasl_auth_clients = yes
smtpd_tls_loglevel = 1

este é o meu /etc/dovecot/dovecot.conf

disable_plaintext_auth=no
protocols = imap sieve

ssl = yes
ssl_cert = </etc/ssl/certs/server.crt
ssl_key = </etc/ssl/private/server.key
first_valid_uid = 5000
first_valid_gid = 5000
auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@

namespace {
    location = maildir:/home/vmail/%d/%n/Maildir
    type = private
    prefix = INBOX.
    inbox = yes
    hidden = yes
}

service auth {

    unix_listener auth-userdb {
        mode = 0600
        user = vmail # User running dovecot-lda
        #group = vmail # Or alternatively mode 0660 + dovecot-lda user in this group
      }
}

passdb  {
    driver=sql
    args = /etc/dovecot/dovecot-sql.conf
}

userdb  {
    driver=static
    args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
}

protocol imap {
  imap_client_workarounds = delay-newmail tb-extra-mailbox-sep
}

protocol lda {
    postmaster_address = [email protected]
    hostname = local.exaple.com
    sendmail_path = /usr/sbin/sendmail
    mail_plugins = $mail_plugins sieve
    log_path = /var/log/dovecot-lda-errors.log
    info_log_path = /var/log/dovecot-lda.log
}

protocol sieve {
# Defaults are OK, so nothing in this section.
}

plugin {
  sieve = ~/.dovecot.sieve
  sieve_global_path = /home/vmail/globalsieverc
  sieve_dir = ~/
}

passdb {
    driver = sql
    args = /etc/dovecot/dovecot-sql.conf
}

userdb {
    driver = sql
    args = /etc/dovecot/dovecot-sql.conf
}

mail_debug=yes
auth_debug_passwords=yes

E este é o dovecot-sql.conf

driver = pgsql
connect = host=localhost dbname=postfix_db user=user_for_db password=password_for_db
default_pass_scheme = MD5-CRYPT

# Get the mailbox
user_query = SELECT '/home/vmail/%d/%u' as home, 'maildir:/home/vmail/%d/%u' as mail, 5000 AS uid, 5000 AS gid, concat('dirsize:storage=',  quota) AS quota FROM mailbox WHERE username = '%u' AND active = '1'
# Get the password
password_query = SELECT username as user, password, '/home/vmail/%d/%u' as userdb_home, 'maildir:/home/vmail/%d/%u' as userdb_mail, 5000 as  userdb_uid, 5000 as userdb_gid FROM mailbox WHERE username = '%u' AND active = '1'

Obrigado antecipadamente.

    
por kokeroulis 15.01.2014 / 21:28

2 respostas

1

Eu não sei até que ponto você redigiu a saída acima, mas nas linhas importantes da consulta SQL ( Incompatibilidade de senha , e a linha que segue) está comparando um MD5- hash para uma cadeia muito longa.

Os hashes MD5 têm 32 bytes, portanto nenhuma string será MD5-hash no tipo de string que você dá, que parece ter 63 bytes de comprimento e, além disso, é composta de caracteres não-hexadecimais. Se isso não for todo o resultado de uma redação ruim (e sem sentido), uma incompatibilidade nos algoritmos de hash pode ser o seu problema (o SHA256 produz somas de verificação de 64 bytes, então pode ser o que você deveria estar usando). >     

por 28.02.2015 / 08:20
0

Você precisa alterar suas consultas ao banco de dados do dovecot de uma maneira:

    user_query = SELECT maildir as home, \
                        username as mail, \
                        5000 AS uid, \
                        5000 AS gid, \
                        concat('dirsize:storage=',  quota) AS quota \
                 FROM mailbox \
                 WHERE username = '%u' \
                   AND active = '1'
    password_query = SELECT username as user, \
                            password, \
                            maildir as userdb_home, \
                            username as userdb_mail, \
                            5000 as  userdb_uid, \
                            5000 as userdb_gid \
                       FROM mailbox \
                      WHERE username = '%u' \
                        AND active = '1'
   iterate_query = SELECT username AS user FROM mailbox

Pode ser que você tenha que usar o campo local_part em vez de username , mas isso depende do esquema de postfix e autorização que você usou.

    
por 16.01.2014 / 17:34