From 39a5e3635fd14c27880ec09e7e825c7a09b6d299 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Wed, 28 Aug 2024 11:52:31 +0200 Subject: [PATCH] auth: allow turning off across-zone resolving Default is unchanged. Turning off the new setting causes CNAME targets to not be followed across (local) zones. Also, queries that could be answered by following a local delegations are similarly not resolved. --- docs/settings.rst | 17 +++ pdns/auth-main.cc | 1 + pdns/packethandler.cc | 10 +- pdns/packethandler.hh | 1 + .../test_ResolveAcrossZones.py | 105 ++++++++++++++++++ 5 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 regression-tests.auth-py/test_ResolveAcrossZones.py diff --git a/docs/settings.rst b/docs/settings.rst index 35a65cfd9fcc..e1e2d974a33a 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -785,6 +785,23 @@ the server will return NODATA for A/AAAA queries for such names. In PowerDNS Authoritative Server 4.0.x, this setting did not exist and ALIAS was always expanded. +.. _setting-resolve-across-zones: + +``resolve-across-zones`` +------------------------ + +.. versionadded:: 5.0.0 + +- Boolean +- Default: yes + +If this is enabled, CNAME records and other referrals will be resolved as long as their targets exist in any local backend. +Can be disabled to allow for different authorities managing zones in the same server instance. + +Referrals not available in local backends are never resolved. +SVCB referrals are never resolved across zones. +ALIAS is not impacted by this setting. + .. _setting-forward-dnsupdate: ``forward-dnsupdate`` diff --git a/pdns/auth-main.cc b/pdns/auth-main.cc index 72e05c9e6e7f..06d874249969 100644 --- a/pdns/auth-main.cc +++ b/pdns/auth-main.cc @@ -309,6 +309,7 @@ static void declareArguments() ::arg().setSwitch("expand-alias", "Expand ALIAS records") = "no"; ::arg().set("outgoing-axfr-expand-alias", "Expand ALIAS records during outgoing AXFR") = "no"; + ::arg().setSwitch("resolve-across-zones", "Resolve CNAME targets and other referrals across local zones") = "yes"; ::arg().setSwitch("8bit-dns", "Allow 8bit dns queries") = "no"; #ifdef HAVE_LUA_RECORDS ::arg().setSwitch("enable-lua-records", "Process LUA records for all zones (metadata overrides this)") = "no"; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index d06e4724e127..f2a570a274ba 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -70,6 +70,7 @@ PacketHandler::PacketHandler():B(g_programname), d_dk(&B) ++s_count; d_doDNAME=::arg().mustDo("dname-processing"); d_doExpandALIAS = ::arg().mustDo("expand-alias"); + d_doResolveAcrossZones = ::arg().mustDo("resolve-across-zones"); d_logDNSDetails= ::arg().mustDo("log-dns-details"); string fname= ::arg()["lua-prequery-script"]; @@ -1526,12 +1527,17 @@ std::unique_ptr PacketHandler::doQuestion(DNSPacket& p) } DLOG(g_log<