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:
16
chasquid.go
16
chasquid.go
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user