From 32b884e8b91d3bf629f332cf4fb14b693f0089f8 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Fri, 15 Sep 2017 09:55:44 +0000 Subject: [PATCH] dovecot sql config --- templates/dovecot-sql.conf.ext.j2 | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/templates/dovecot-sql.conf.ext.j2 b/templates/dovecot-sql.conf.ext.j2 index 5e459ac..bb240ba 100644 --- a/templates/dovecot-sql.conf.ext.j2 +++ b/templates/dovecot-sql.conf.ext.j2 @@ -107,6 +107,7 @@ default_pass_scheme = MD5-CRYPT #password_query = \ # SELECT username, domain, password \ # FROM users WHERE username = '%n' AND domain = '%d' +password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1' # userdb query to retrieve the user information. It can return fields: # uid - System UID (overrides mail_uid setting) @@ -129,7 +130,12 @@ default_pass_scheme = MD5-CRYPT # FROM users WHERE username = '%n' AND domain = '%d' # # postfixadmin: Query to retrieve user information, note uid matches dovecot.conf AND Postfix virtual_uid_maps parameter. -user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE username = '%u' AND active='1' +user_query = SELECT CONCAT('*:bytes=', \ + IF(mailbox.quota = 0, domain.maxquota*1024000, mailbox.quota)) \ + as quota_rule \ + FROM mailbox, domain \ + WHERE username = '%u' AND mailbox.active = '1' AND \ + domain.domain = '%d' AND domain.active = '1' # If you wish to avoid two SQL lookups (passdb + userdb), you can use # userdb prefetch instead of userdb sql in dovecot.conf. In that case you'll @@ -139,21 +145,6 @@ user_query = SELECT maildir, 1001 AS uid, 1001 AS gid FROM mailbox WHERE usernam # SELECT userid AS user, password, \ # home AS userdb_home, uid AS userdb_uid, gid AS userdb_gid \ # FROM users WHERE userid = '%u' -# -# postfixadmin: Query to retrieve password. user can be used to retrieve username in other -# formats also. -password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1' # Query to get a list of all usernames. #iterate_query = SELECT username AS user FROM users - - - - - - -# MYSQL : -user_query = SELECT CONCAT('/var/vmail/mail/', maildir) AS home, 1001 AS uid, 1001 AS gid, - CONCAT('*:bytes=', quota) AS quota_rule FROM mailbox WHERE username = '%u' AND active='1' -# PostgreSQL : (no Quota though) : -# user_query = SELECT '/var/vmail/mail/' || maildir AS home, 1001 as uid, 1001 as gid FROM mailbox WHERE username = '%u' AND active = '1'