From: Remi Gacogne Date: Mon, 25 Jan 2016 09:40:45 +0000 (+0100) Subject: Fix bindbackend's feedRecord to handle being slave for the root X-Git-Tag: dnsdist-1.0.0-alpha2~33^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3302%2Fhead;p=thirdparty%2Fpdns.git Fix bindbackend's feedRecord to handle being slave for the root Replace the out-of-zone check by using DNSName isPartOf(). Without this commit, importing the Yeti root zone via AXFR fails with: "Unable to feed record during incoming AXFR of '.': out-of-zone data 'aaa..' during AXFR of zone '..' because stripDomainSuffix("aaa.", ".") returns false. --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index f171352959..c773784691 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -257,11 +257,23 @@ bool Bind2Backend::feedRecord(const DNSResourceRecord &rr, string *ordername) BB2DomainInfo bbd; safeGetBBDomainInfo(d_transaction_id, &bbd); - string name=bbd.d_name.toString(); - string qname=rr.qname.toString(); - - if(!stripDomainSuffix(&qname, name)) - throw DBException("out-of-zone data '"+qname+".' during AXFR of zone '"+name+".'"); + string qname; + string name = bbd.d_name.toString(); + if (bbd.d_name.empty()) { + qname = rr.qname.toString(); + } + else if (rr.qname.isPartOf(bbd.d_name)) { + if (rr.qname == bbd.d_name) { + qname = "@"; + } + else { + DNSName relName = rr.qname.makeRelative(bbd.d_name); + qname = relName.toStringNoDot(); + } + } + else { + throw DBException("out-of-zone data '"+rr.qname.toString()+"' during AXFR of zone '"+bbd.d_name.toString()+"'"); + } shared_ptr drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); string content = drc->getZoneRepresentation();