dovecot 2.4.4 community edition, bug in variables
I'm using this passdb sql to a postgres db
passdb sql {
query = SELECT NULL AS password, 'Y' as nopassword, userid AS user
FROM users
WHERE addr = '%{user}' AND password = '%{password}'
}
This succeed and the addr passed in as user is foo@example.com as expected
I use this userdb sql
userdb sql {
query = SELECT home, uid, gid
FROM users
WHERE addr = '%{user}'
# For using doveadm -A:
# iterate_query = SELECT userid AS username, domain FROM users
}
This fails because postgres receivesĀ just "foo" not "foo@example.com" as user.
maybe there is a bug in my stuff but I cannot see it. I can see the query in the postgres log where it clearly says:
WHERE addr = 'foo'
It also logs the passdb query:
WHERE addr = 'foo@example.com' ANDĀ password='secret'
thanks
Terry
On 22/05/2026 19:37 EEST Terry Braun via dovecot <dovecot@dovecot.org> wrote:
I'm using this passdb sql to a postgres db
passdb sql { query = SELECT NULL AS password, 'Y' as nopassword, userid AS user
FROM users
WHERE addr = '%{user}' AND password = '%{password}' }
Returning foo as userid will, in your config, change user to foo.
Aki
This explains the problem very well! I would have struggled with this one because I have a hard time wrapping my head around the concept that the returned value of the passdb query will modify 'user' for the userdb query.
Just a side note, but I think it would be helpful to explicitly add the side effect to the documentation. The ability to verify the password in the case where there are multiple instances is very, very helpful, so other people may have the same trouble.
Thank you for the help!!
Terry
On 5/22/26 12:57 PM, Aki Tuomi wrote:
On 22/05/2026 19:37 EEST Terry Braun via dovecot <dovecot@dovecot.org> wrote:
I'm using this passdb sql to a postgres db
passdb sql { query = SELECT NULL AS password, 'Y' as nopassword, userid AS user
FROM users
WHERE addr = '%{user}' AND password = '%{password}' }Returning
fooas userid will, in your config, change user tofoo.Aki
participants (2)
-
Aki Tuomi
-
Terry Braun