From 67fe88f4311630b81dfaf0c99cd024fd5bf0d351 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Fri, 13 Oct 2023 08:51:02 +0200 Subject: [PATCH] change the autodiscover SRV record to point to the mail server hostname directly, not to a cname srv targest shouldn't be cname's. bind was warning about it. --- http/web.go | 5 +++++ mox-/admin.go | 2 +- webadmin/admin.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/http/web.go b/http/web.go index 5ee9579..43a9fac 100644 --- a/http/web.go +++ b/http/web.go @@ -623,6 +623,11 @@ func Listen() { dom.ASCII = strings.TrimPrefix(dom.ASCII, "autoconfig.") dom.Unicode = strings.TrimPrefix(dom.Unicode, "autoconfig.") } + // Autodiscovery uses a SRV record. It shouldn't point to a CNAME. So we directly + // use the mail server's host name. + if dom == mox.Conf.Static.HostnameDomain || dom == mox.Conf.Static.Listeners["public"].HostnameDomain { + return true + } _, ok := mox.Conf.Domain(dom) return ok } diff --git a/mox-/admin.go b/mox-/admin.go index 574203d..ec93c22 100644 --- a/mox-/admin.go +++ b/mox-/admin.go @@ -626,7 +626,7 @@ func DomainRecords(domConf config.Domain, domain dns.Domain, hasDNSSEC bool) ([] records = append(records, "; Autoconfig is used by Thunderbird. Autodiscover is (in theory) used by Microsoft.", fmt.Sprintf(`autoconfig.%s. CNAME %s.`, d, h), - fmt.Sprintf(`_autodiscover._tcp.%s. SRV 0 1 443 autoconfig.%s.`, d, d), + fmt.Sprintf(`_autodiscover._tcp.%s. SRV 0 1 443 %s.`, d, h), "", // ../rfc/6186:133 ../rfc/8314:692 diff --git a/webadmin/admin.go b/webadmin/admin.go index 70b056f..a71404f 100644 --- a/webadmin/admin.go +++ b/webadmin/admin.go @@ -1364,7 +1364,7 @@ When enabling MTA-STS, or updating a policy, always update the policy first (thr defer logPanic(ctx) defer wg.Done() - addf(&r.Autodiscover.Instructions, "Ensure DNS records like the following exist:\n\n\t_autodiscover._tcp.%s SRV 0 1 443 autoconfig.%s\n\tautoconfig.%s CNAME %s\n\nNote: the trailing dots are relevant, it makes the host names absolute instead of relative to the domain name.", domain.ASCII+".", domain.ASCII+".", domain.ASCII+".", mox.Conf.Static.HostnameDomain.ASCII+".") + addf(&r.Autodiscover.Instructions, "Ensure DNS records like the following exist:\n\n\t_autodiscover._tcp.%s SRV 0 1 443 %s\n\tautoconfig.%s CNAME %s\n\nNote: the trailing dots are relevant, it makes the host names absolute instead of relative to the domain name.", domain.ASCII+".", mox.Conf.Static.HostnameDomain.ASCII+".", domain.ASCII+".", mox.Conf.Static.HostnameDomain.ASCII+".") _, srvs, _, err := resolver.LookupSRV(ctx, "autodiscover", "tcp", domain.ASCII+".") if err != nil {