dovecot configuration question userdb driver
Greetings, I have a mail server for a few folks, basically my family. My current Dovecot configuration is the following, which works like a charm:
passdb { driver = sql args = /usr/local/etc/dovecot/dovecot-sql.conf.ext } userdb { driver = static args = uid=981 gid=981 home=/var/mail/virtual/%d/%n/home }
I've decided to deploy Solr to be able to search faster. Now, when I try to execute "doveadm index -A inbox" I get an error "Error: auth-master: userdb list: User listing returned failure" because I'm using the static userdb.
My question is, how do I implement the listing users feature while using "static driver" or a similar approach? I really want to keep using the template "/var/mail/virtual/%d/%n/home" instead of defining a custom path for each user.
So I came up with this idea to replace "static" with "sql" driver for "userdb" since there's "iterate_query" I can use to achieve my goal, tho I have to define "user_query", so I can do something like:
SELECT '/var/mail/virtual/%d/%n/home' AS maildir, 981 AS uid, 981 AS gid FROM mailbox WHERE username='%u' and active='1';
However, this is a useless waste of resources since I'm not really querying anything, and I'm not even sure if there's template support (e.g., %d/%n) in there.
Appreciate any help Best
On 16/12/2024 22:07 EET Stanislav via dovecot <dovecot@dovecot.org> wrote:
Greetings, I have a mail server for a few folks, basically my family. My current Dovecot configuration is the following, which works like a charm:
passdb { driver = sql args = /usr/local/etc/dovecot/dovecot-sql.conf.ext } userdb { driver = static args = uid=981 gid=981 home=/var/mail/virtual/%d/%n/home }
I've decided to deploy Solr to be able to search faster. Now, when I try to execute "doveadm index -A inbox" I get an error "Error: auth-master: userdb list: User listing returned failure" because I'm using the static userdb.
My question is, how do I implement the listing users feature while using "static driver" or a similar approach? I really want to keep using the template "/var/mail/virtual/%d/%n/home" instead of defining a custom path for each user.
So I came up with this idea to replace "static" with "sql" driver for "userdb" since there's "iterate_query" I can use to achieve my goal, tho I have to define "user_query", so I can do something like:
SELECT '/var/mail/virtual/%d/%n/home' AS maildir, 981 AS uid, 981 AS gid FROM mailbox WHERE username='%u' and active='1';
However, this is a useless waste of resources since I'm not really querying anything, and I'm not even sure if there's template support (e.g., %d/%n) in there.
Appreciate any help Best
You could get rid of the static userdb with these settings
mail_uid = 981 mail_gid = 981 mail_home = /var/mail/virtual/%d/%n/home
and ensure you have iterate_query in your SQL config.
Should do the trick.
Aki
You could get rid of the static userdb with these settings
mail_uid = 981 mail_gid = 981 mail_home = /var/mail/virtual/%d/%n/home
and ensure you have iterate_query in your SQL config.
Should do the trick.
Thanks, Aki!
I added those properties and also commented out the following line: user_query = SELECT maildir, 981 AS uid, 981 AS gid FROM mailbox WHERE username='%u' and active='1'
After that, I started seeing errors like: dovecot[29855]: auth-worker(29871): Warning: sqlpool(mysql): Query failed, retrying: Table 'mail.users' doesn't exist dovecot[29855]: auth-worker(29871): Error: conn unix:auth-worker (uid=143): auth-worker<26>: sql(omitted,<nFRU7G4pK jsEDmqT>): User query failed: Table 'mail.users' doesn't exist (using built-in default user_query: SELECT home, uid, gid FROM users WHERE username = '%n' AND domain = '%d')
To fix it, I set user_query to this: user_query = SELECT username FROM mailbox WHERE username='%u' AND active='1'
Now, it returns the "username" but I’m not sure how useful that is for Dovecot in the user_query context. That said, everything seems to be working fine now.
Does this look like the right approach?
Thanks!
On 17/12/2024 05:52 EET Stanislav via dovecot <dovecot@dovecot.org> wrote:
You could get rid of the static userdb with these settings
mail_uid = 981 mail_gid = 981 mail_home = /var/mail/virtual/%d/%n/home
and ensure you have iterate_query in your SQL config.
Should do the trick.
Thanks, Aki!
I added those properties and also commented out the following line: user_query = SELECT maildir, 981 AS uid, 981 AS gid FROM mailbox WHERE username='%u' and active='1'
After that, I started seeing errors like: dovecot[29855]: auth-worker(29871): Warning: sqlpool(mysql): Query failed, retrying: Table 'mail.users' doesn't exist dovecot[29855]: auth-worker(29871): Error: conn unix:auth-worker (uid=143): auth-worker<26>: sql(omitted,<nFRU7G4pK jsEDmqT>): User query failed: Table 'mail.users' doesn't exist (using built-in default user_query: SELECT home, uid, gid FROM users WHERE username = '%n' AND domain = '%d')
To fix it, I set user_query to this: user_query = SELECT username FROM mailbox WHERE username='%u' AND active='1'
Now, it returns the "username" but I’m not sure how useful that is for Dovecot in the user_query context. That said, everything seems to be working fine now.
Does this look like the right approach?
Thanks!
Looks about right. You need to return something and this normalizes a username as well.
Aki
participants (2)
-
Aki Tuomi
-
Stanislav