Dovecot user lookup fails when using username@domain format
Solution 1:
Userids in dovecot using passdb don't include the domain. The userid the user should use is the local part, not the full email address.
The checks that are passing and failing are working as expected. Setting auth_username_format=%n
before the password db definition does work. The domain is not validated though.
Solution 2:
I am using Ubuntu Server 12.04 and I tried the above solutions. However, I found that simplest and easiest way was in 10-auth.conf to set
auth_username_format = %n
I use PAM for the authentication which is the default in Ubuntu 12.04.
Solution 3:
I suspect that Dovecot 2.1 either broke this solution or has changed the expected behavior.
I've traced the same authorization error to the userdb:
userdb {
driver = passwd
}
When a local user (non-virtual) receives an email via exim->lmtp it includes the domain. Defining auth_username_format=%Ln does fix local delivery, but it breaks virtual deliveries. The offered fix of adding args = username_format seems to be ignored:
userdb {
driver = passwd
args = username_format=%n
}
and the logs include a warning
Apr 4 11:24:57 moe dovecot: auth: Warning: userdb passwd: Move templates args to override_fields setting
Interestingly, using passwd-file does work, but auth is mad that the passwd file is owned by root.
userdb {
driver = passwd-file
args = username_format=%n /etc/passwd
}
Apr 4 11:26:12 moe dovecot: auth: Error: passwd-file /etc/passwd: User root has invalid UID '0'
Apr 4 11:26:12 moe dovecot: auth-worker(6855): Error: passwd-file /etc/passwd: User root has invalid UID '0'