1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

dovecot: Support dovecot-side username changes

Dovecot has options for changing the formatting of usernames; for
example, dropping the domain part, or replacing characters.

chasquid's implementation, however, fails to handle this well, as it
expects the reply to contain the username exactly as requested.

This patch fixes the problem by making chasquid ignoring the returned
username, which is unused anyway. The protocol is unambiguous enough.

Tests are also amended to always exercise this case.
This commit is contained in:
Alberto Bertogli
2018-03-02 18:52:25 +00:00
parent d39d3aaff4
commit 0ae5798d20
3 changed files with 6 additions and 2 deletions

View File

@@ -118,7 +118,7 @@ func (a *Auth) Exists(user string) (bool, error) {
resp, err := conn.ReadLine()
if err != nil {
return false, fmt.Errorf("error receiving response: %v", err)
} else if strings.HasPrefix(resp, "USER\t1\t"+user+"\t") {
} else if strings.HasPrefix(resp, "USER\t1\t") {
return true, nil
} else if strings.HasPrefix(resp, "NOTFOUND\t") {
return false, nil

View File

@@ -5,6 +5,10 @@ ssl = no
default_internal_user = $USER
default_login_user = $USER
# Before auth checks, rename "u@d" to "u-AT-d". This exercises that chasquid
# handles well the case where the returned user information does not match the
# requested user.
auth_username_format = "%n-AT-%d"
passdb {
driver = passwd-file

View File

@@ -1 +1 @@
user@srv:{plain}password:1000:1000::/home/user
user-AT-srv:{plain}password:1000:1000::/home/user