diff --git a/internal/dovecot/dovecot.go b/internal/dovecot/dovecot.go index 9a7f26e..855cfee 100644 --- a/internal/dovecot/dovecot.go +++ b/internal/dovecot/dovecot.go @@ -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 diff --git a/test/t-11-dovecot/config/dovecot.conf.in b/test/t-11-dovecot/config/dovecot.conf.in index d770287..3f59a86 100644 --- a/test/t-11-dovecot/config/dovecot.conf.in +++ b/test/t-11-dovecot/config/dovecot.conf.in @@ -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 diff --git a/test/t-11-dovecot/config/passwd b/test/t-11-dovecot/config/passwd index 0182c1a..2ceb0ee 100644 --- a/test/t-11-dovecot/config/passwd +++ b/test/t-11-dovecot/config/passwd @@ -1 +1 @@ -user@srv:{plain}password:1000:1000::/home/user +user-AT-srv:{plain}password:1000:1000::/home/user