Skip to content
Snippets Groups Projects
Commit b7c86593 authored by ale's avatar ale
Browse files

Handle dovecot dict key lookup prefix properly

parent ba8f75e8
Branches
No related tags found
No related merge requests found
......@@ -80,17 +80,17 @@ func NewKeyLookupProxy(config *Config) (*KeyLookupProxy, error) {
// Lookup a key using the dovecot dict proxy interface.
//
// We can be sent a userdb lookup, or a passdb lookup, and we can tell
// them apart from the structure of the key:
//
// If it contains passwordSep, then it's a passdb lookup and the key
// consists of 'username' and 'password'. Otherwise, it's a userdb
// lookup and the key is simply the username.
// them apart with the key prefix (passdb/ or userdb/).
func (s *KeyLookupProxy) Lookup(ctx context.Context, key string) (interface{}, bool) {
if strings.Contains(key, passwordSep) {
kparts := strings.SplitN(key, passwordSep, 2)
switch {
case strings.HasPrefix(key, "passdb/"):
kparts := strings.SplitN(key[7:], passwordSep, 2)
return s.lookupPassdb(ctx, kparts[0], kparts[1])
case strings.HasPrefix(key, "userdb/"):
return s.lookupUserdb(ctx, key[7:])
default:
return nil, false
}
return s.lookupUserdb(ctx, key)
}
func (s *KeyLookupProxy) lookupUserdb(ctx context.Context, username string) (interface{}, bool) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment