From: Kees Monshouwer Date: Fri, 1 Oct 2021 08:33:27 +0000 (+0200) Subject: auth: fix the SOA check in pdnsutil X-Git-Tag: auth-4.6.0-alpha1~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10788%2Fhead;p=thirdparty%2Fpdns.git auth: fix the SOA check in pdnsutil --- diff --git a/pdns/dnsbackend.cc b/pdns/dnsbackend.cc index 312c4c8378..e6711e9911 100644 --- a/pdns/dnsbackend.cc +++ b/pdns/dnsbackend.cc @@ -246,25 +246,31 @@ bool DNSBackend::getSOA(const DNSName &domain, SOAData &sd) S.inc("backend-queries"); DNSResourceRecord rr; - rr.auth = true; - int hits=0; - while(this->get(rr)) { - if (rr.qtype != QType::SOA) throw PDNSException("Got non-SOA record when asking for SOA"); - hits++; - fillSOAData(rr.content, sd); - sd.domain_id=rr.domain_id; - sd.ttl=rr.ttl; - } - - if(!hits) - return false; + sd.db = nullptr; - sd.qname = domain; - sd.db=this; + try { + while (this->get(rr)) { + if (rr.qtype != QType::SOA) { + throw PDNSException("Got non-SOA record when asking for SOA, zone: '" + domain.toLogString() + "'"); + } + hits++; + sd.qname = domain; + sd.ttl = rr.ttl; + sd.db = this; + sd.domain_id = rr.domain_id; + fillSOAData(rr.content, sd); + } + } + catch (const PDNSException& e) { + while (this->get(rr)) { + ; + } + throw; + } - return true; + return hits; } bool DNSBackend::get(DNSZoneRecord& dzr) @@ -348,6 +354,6 @@ void fillSOAData(const string &content, SOAData &data) data.minimum = pdns_stou(parts.at(6).c_str()); } catch(const std::out_of_range& oor) { - throw PDNSException("Out of range exception parsing "+content); + throw PDNSException("Out of range exception parsing '" + content + "'"); } } diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index 93c7859cee..879fb816d1 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -251,7 +251,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con DomainInfo di; try { - if (!B.getDomainInfo(zone, di)) { + if (!B.getDomainInfo(zone, di, false)) { cout << "[Error] Unable to get zone information for zone '" << zone << "'" << endl; return 1; } @@ -263,11 +263,20 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con } SOAData sd; - if(!B.getSOAUncached(zone, sd)) { - cout<<"[Error] No SOA record present, or active, in zone '"<