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:
@@ -118,7 +118,7 @@ func (a *Auth) Exists(user string) (bool, error) {
|
|||||||
resp, err := conn.ReadLine()
|
resp, err := conn.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("error receiving response: %v", err)
|
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
|
return true, nil
|
||||||
} else if strings.HasPrefix(resp, "NOTFOUND\t") {
|
} else if strings.HasPrefix(resp, "NOTFOUND\t") {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ ssl = no
|
|||||||
default_internal_user = $USER
|
default_internal_user = $USER
|
||||||
default_login_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 {
|
passdb {
|
||||||
driver = passwd-file
|
driver = passwd-file
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
user@srv:{plain}password:1000:1000::/home/user
|
user-AT-srv:{plain}password:1000:1000::/home/user
|
||||||
|
|||||||
Reference in New Issue
Block a user