1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-20 15:07:03 +00:00

chasquid: Dovecot support (experimental)

This patch adds dovecot support to the chasquid daemon, using the
internal dovecot library added in previous patches.

Dovecot support is still considered EXPERIMENTAL and may be reverted, or
changed in backwards-incompatible ways.

The patch also adds the corresponding integration test, which brings up
a dovecot server with a custom configuration, and tests chasquid's
authentication against it.  If dovecot is not installed, the test is
skipped.
This commit is contained in:
Alberto Bertogli
2018-02-06 10:59:58 +00:00
parent 51e7c5c19e
commit d39d3aaff4
15 changed files with 304 additions and 27 deletions

View File

@@ -21,6 +21,7 @@ import (
"blitiri.com.ar/go/chasquid/internal/config"
"blitiri.com.ar/go/chasquid/internal/courier"
"blitiri.com.ar/go/chasquid/internal/dovecot"
"blitiri.com.ar/go/chasquid/internal/maillog"
"blitiri.com.ar/go/chasquid/internal/normalize"
"blitiri.com.ar/go/chasquid/internal/smtpsrv"
@@ -95,6 +96,10 @@ func main() {
s.SetAliasesConfig(conf.SuffixSeparators, conf.DropCharacters)
if conf.DovecotAuth {
loadDovecot(s, conf.DovecotUserdbPath, conf.DovecotClientPath)
}
// Load certificates from "certs/<directory>/{fullchain,privkey}.pem".
// The structure matches letsencrypt's, to make it easier for that case.
log.Infof("Loading certificates")
@@ -228,6 +233,22 @@ 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
}
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)
}
}
}
// Read a directory, which must have at least some entries.
func mustReadDir(path string) []os.FileInfo {
dirs, err := ioutil.ReadDir(path)