1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

dovecot: Retry auto-detect until we find a usable socket pair

Currently, chasquid attempts to auto-detect dovecot sockets when
starting up (if needed). If autodetection fails, chasquid emits an
error, continues serving, and never tries again.

This can be problematic if chasquid starts up before dovecot, and at the
time the dovecot sockets are not present (e.g. after a reboot). In that
case, chasquid will not use dovecot for authentication even after
dovecot has started.

This patch changes the autodetect logic, by doing autodetection at
startup and on each request, until we find a working pair of sockets.
Once we do, they're used consistently.

That way, if dovecot is not ready when chasquid starts, it's not a
problem and chasquid will start using dovecot once it becomes available.

Thanks to Thor77 (thor77@thor77.org) for reporting and helping
troubleshoot this issue.
This commit is contained in:
Alberto Bertogli
2021-05-24 00:22:19 +01:00
parent 84e6c066fa
commit fa651e74e3
4 changed files with 150 additions and 112 deletions

View File

@@ -281,18 +281,12 @@ func loadDomain(name, dir string, s *smtpsrv.Server) {
}
func loadDovecot(s *smtpsrv.Server, userdb, client string) {
a := dovecot.Autodetect(userdb, client)
if a == nil {
log.Errorf("Dovecot autodetection failed, no dovecot fallback")
return
}
a := dovecot.NewAuth(userdb, client)
s.SetAuthFallback(a)
log.Infof("Fallback authenticator: %v", a)
if a != nil {
s.SetAuthFallback(a)
log.Infof("Fallback authenticator: %v", a)
if err := a.Check(); err != nil {
log.Errorf("Failed dovecot authenticator check: %v", err)
}
if err := a.Check(); err != nil {
log.Errorf("Warning: Dovecot auth is not responding: %v", err)
}
}