From: Kees Monshouwer Date: Thu, 14 Jul 2022 19:22:07 +0000 (+0200) Subject: auth: support catalog version "1" as consumer X-Git-Tag: auth-4.8.0-alpha0~7^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dab6f75084f2c1fcb1c1bcbefe2031c198b1add5;p=thirdparty%2Fpdns.git auth: support catalog version "1" as consumer --- diff --git a/docs/catalog.rst b/docs/catalog.rst index 4703d8ff50..36677ef9c0 100644 --- a/docs/catalog.rst +++ b/docs/catalog.rst @@ -1,7 +1,20 @@ Catalog Zone (RFC TBD) ======================= -Starting with the PowerDNS Authoritative Server 4.7.0, catalog zone support is available. The current supported catalog version is "2". All all the important features of catalog zones are supported. There are however a few properties where support is limited: +Starting with the PowerDNS Authoritative Server 4.7.0, catalog zone support is available. + +Supported catalog versions +-------------------------- + ++-----------------+----------+----------+ +| Catalog version | Producer | Consumer | ++=================+==========+==========+ +| 1 (ICS) | No | Yes | ++-----------------+----------+----------+ +| 2 (RFC TBD) | Yes | Yes | ++-----------------+----------+----------+ + +All all the important features of catalog zone version "2" are supported. There are however a few properties where support is limited: - There is no support for group templates on consumers; - There is no support for custom extensions; diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index 83ecc21856..7c8d76af8e 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -292,8 +292,8 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, // From XFR bool hasSOA{false}; - bool hasVersion{false}; bool zoneInvalid{false}; + int hasVersion{0}; CatalogInfo ci; @@ -313,9 +313,16 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, } else if (rr.qname == DNSName("version") + di.zone && rr.qtype == QType::TXT) { - if (rr.content == "\"2\"") { - hasVersion = true; - continue; + if (hasVersion) { + g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', multiple version records found, aborting" << endl; + return false; + } + + if (rr.content == "\"1\"") { + hasVersion = 1; + } + else if (rr.content == "\"2\"") { + hasVersion = 2; } else { g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', unsupported catalog zone schema version " << rr.content << ", aborting" << endl; @@ -355,21 +362,23 @@ static bool catalogProcess(const DomainInfo& di, vector& rrs, } } - else if (rel == (DNSName("coo") + unique) && rr.qtype == QType::PTR) { - if (!ci.d_coo.empty()) { - g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', duplicate COO for unique '" << unique << "'" << endl; - zoneInvalid = true; - } - else { - ci.d_coo = DNSName(rr.content); + else if (hasVersion == 2) { + if (rel == (DNSName("coo") + unique) && rr.qtype == QType::PTR) { + if (!ci.d_coo.empty()) { + g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', duplicate COO for unique '" << unique << "'" << endl; + zoneInvalid = true; + } + else { + ci.d_coo = DNSName(rr.content); + } } - } - else if (rel == (DNSName("group") + unique) && rr.qtype == QType::TXT) { - std::string content = rr.content; - if (content.length() >= 2 && content.at(0) == '\"' && content.at(content.length() - 1) == '\"') { // TXT pain - content = content.substr(1, content.length() - 2); + else if (rel == (DNSName("group") + unique) && rr.qtype == QType::TXT) { + std::string content = rr.content; + if (content.length() >= 2 && content.at(0) == '\"' && content.at(content.length() - 1) == '\"') { // TXT pain + content = content.substr(1, content.length() - 2); + } + ci.d_group.insert(content); } - ci.d_group.insert(content); } } rr.disabled = true;