Dovecot não está executando a consulta SQL de cota

2

Estou tentando configurar o dovecot para lidar com limites de cota.

Eu segui um guia e configurei as etapas corretas. Eu até os comparei com o nosso servidor de email atual.

O problema é que o Dovecot não escreve na tabela quota2 em nosso banco de dados. Verifiquei os logs do mysql e o arquivo maillog (localização do log dovecot), mas não vejo nenhum erro sobre a cota. Todas as outras consultas estão funcionando perfeitamente. A cota na tabela de usuários também é buscada.

Alguém tem uma pista? O que estou perdendo?

Saída Dovecot -n:

# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 3.14.35-28.38.amzn1.x86_64 x86_64  ext4
auth_mechanisms = plain login
dict {
  quotadict = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
}
mail_location = maildir:/var/spool/mail/virtual/%d/%n
mail_plugins = quota
mail_privileged_group = mail
mbox_write_locks = fcntl
passdb {
  args = /etc/dovecot/conf.d/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  quota = dict:user::proxy::quotadict
}
service auth-worker {
  user = vmail
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
  unix_listener auth-userdb {
    mode = 0600
    user = vmail
  }
  user = dovecot
}
service imap-login {
  inet_listener imap {
    port = 143
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
ssl_ca = </root/ssl/root-cert.pem
ssl_cert = </root/ssl/private-cert.pem
ssl_key = </root/ssl/private-key.pem
userdb {
  args = /etc/dovecot/conf.d/dovecot-sql.conf.ext
  driver = sql
}
protocol lda {
  mail_plugins = quota
}
protocol imap {
  mail_plugins = quota imap_quota imap_quota
}
protocol pop3 {
  mail_plugins = quota
  pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}

dovecot-sql.conf.ext:

password_query = SELECT email as user, password FROM users WHERE email='%u';

user_query = \
  SELECT CONCAT('/var/spool/mail/virtual/',CONCAT(SUBSTRING_INDEX(email,'@',-1),'/', \
  SUBSTRING_INDEX(email,'@',1))) AS home, \
  5001 AS uid, \
  5001 AS gid, \
  CONCAT('maildir:storage=',quota) AS quota \
  FROM users WHERE email='%u' \
  AND enabled = '1';

dovecot / dovecot-dict-sql.conf.ext:

map {
  pattern = priv/quota/storage
  table = quota2
  username_field = username
  value_field = bytes
}
map {
  pattern = priv/quota/messages
  table = quota2
  username_field = username
  value_field = messages
}

ATUALIZAÇÃO:

Arquivos de log (sem o amavis)

May  8 10:03:47 host dovecot: master: Warning: Killed with signal 15 (by pid=18369 uid=0 code=kill)
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=9721/22462
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=4471/11038
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=4663/11356
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=8663/23549
May  8 10:03:48 host dovecot: master: Dovecot v2.0.9 starting up (core dumps disabled)
May  8 10:03:48 host dovecot: ssl-params: Generating SSL parameters
May  8 10:03:50 host dovecot: ssl-params: SSL parameters regeneration completed
May  8 10:03:55 host dovecot: auth: mysql: Connected to 127.0.0.1 (mail)
May  8 10:04:47 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18399, TLS
May  8 10:04:47 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:47 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:47 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:47 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:47 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:47 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:47 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:49 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18402, TLS
May  8 10:04:49 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:49 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:49 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:49 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:49 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:49 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:49 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:51 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18404, TLS
May  8 10:04:51 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:51 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:51 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:51 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:51 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001,
May  8 10:03:47 host dovecot: master: Warning: Killed with signal 15 (by pid=18369 uid=0 code=kill)
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=9721/22462
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=4471/11038
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=4663/11356
May  8 10:03:47 host dovecot: imap: Server shutting down. bytes=8663/23549
May  8 10:03:48 host dovecot: master: Dovecot v2.0.9 starting up (core dumps disabled)
May  8 10:03:48 host dovecot: ssl-params: Generating SSL parameters
May  8 10:03:50 host dovecot: ssl-params: SSL parameters regeneration completed
May  8 10:03:55 host dovecot: auth: mysql: Connected to 127.0.0.1 (mail)
May  8 10:04:47 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18399, TLS
May  8 10:04:47 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:47 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:47 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:47 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:47 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:47 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:47 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:49 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18402, TLS
May  8 10:04:49 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:49 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:49 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:49 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:49 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:49 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:49 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:51 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18404, TLS
May  8 10:04:51 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:51 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:51 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:51 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:51 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:51 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:51 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:53 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18406, TLS
May  8 10:04:53 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:53 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:53 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:53 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:53 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:53 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:53 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427): Debug: none: root=, index=, control=, inbox=
May  8 10:06:06 host dovecot: lmtp(18427): Connect from local
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:06:06 host dovecot: lmtp(18427): Debug: auth input: [email protected] home=/var/spool/mail/virtual/jouwweb.email/test uid=5001 gid=5001 quota=maildir:storage=10
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): 9nRZJ46KTFX7RwAAx8Xrpw: msgid=<[email protected]>: saved mail to INBOX
May  8 10:06:06 host dovecot: lmtp(18427): Disconnect from local: Client quit
May  8 10:04:51 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:51 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:53 host dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=80.113.202.232, lip=172.31.18.109, mpid=18406, TLS
May  8 10:04:53 host dovecot: imap: Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:04:53 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:04:53 host dovecot: imap: Debug: Module loaded: /usr/lib64/dovecot/lib11_imap_quota_plugin.so
May  8 10:04:53 host dovecot: imap: Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:04:53 host dovecot: imap([email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:04:53 host dovecot: imap([email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:04:53 host dovecot: imap([email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427): Debug: none: root=, index=, control=, inbox=
May  8 10:06:06 host dovecot: lmtp(18427): Connect from local
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Loading modules from directory: /usr/lib64/dovecot
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Module loaded: /usr/lib64/dovecot/lib10_quota_plugin.so
May  8 10:06:06 host dovecot: lmtp(18427): Debug: auth input: [email protected] home=/var/spool/mail/virtual/jouwweb.email/test uid=5001 gid=5001 quota=maildir:storage=10
May  8 10:06:06 host dovecot: lmtp(18427): Debug: Added userdb setting: plugin/quota=maildir:storage=10
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: Effective uid=5001, gid=5001, home=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: Quota root: name=storage=10 backend=maildir args=
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): Debug: maildir++: root=/var/spool/mail/virtual/jouwweb.email/test, index=, control=, inbox=/var/spool/mail/virtual/jouwweb.email/test
May  8 10:06:06 host dovecot: lmtp(18427, [email protected]): 9nRZJ46KTFX7RwAAx8Xrpw: msgid=<[email protected]>: saved mail to INBOX
May  8 10:06:06 host dovecot: lmtp(18427): Disconnect from local: Client quit

Se você estiver interessado no log com o amavis includes, verifique o arquivo gist abaixo: link

UPDATE 2 (graças a Fox): A cota está sendo atualizada. No entanto, o email não parece bloquear quando estou acima do meu limite. O limite atual é de 10kb, o que excedi depois que enviei algumas mensagens. Falta alguma configuração?

    
por Jordi Kroon 07.05.2015 / 16:27

1 resposta

3

Um pequeno palpite baseado em comparar sua configuração com a minha.

CONCAT('maildir:storage=',quota) AS quota deve ser um pouco CONCAT('maildir:storage=',quota) AS quota_rule

Acho que você está sobrescrevendo a configuração quota= da configuração, por entrada por usuário. (Mas eu não sou especialista, então apenas um palpite)

Não lembro por quê, mas minha consulta de quota é concat('*:storage=', quota) as quota_rule , caso isso ajude de alguma forma ...

Edit: Eu acho que é entregue, porque você está usando lmtp, mas não tem quota habilitada para lmtp. Você precisa de algo como eu tenho:

protocol lmtp {
  mail_plugins = quota fts fts_solr sieve
}
    
por 08.05.2015 / 12:49

Tags