From: Kees Monshouwer Date: Wed, 29 Apr 2015 20:57:01 +0000 (+0200) Subject: import pdnssec rectifyZone() from master X-Git-Tag: auth-3.3.2~2^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f1fec74fcedef8cda4c40bc6c5945ec2a6206b6;p=thirdparty%2Fpdns.git import pdnssec rectifyZone() from master --- diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index 6d059d83ea..f3d36fa12d 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -178,18 +178,19 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) if(!B.getSOA(zone, sd)) { cerr<<"No SOA known for '"<list(zone, sd.domain_id); DNSResourceRecord rr; - set qnames, nsset, dsnames, nonterm, insnonterm, delnonterm; + set qnames, nsset, dsnames, insnonterm, delnonterm; + map nonterm; bool doent=true; - + while(sd.db->get(rr)) { if (rr.qtype.getCode()) { qnames.insert(rr.qname); - if(rr.qtype.getCode() == QType::NS && !pdns_iequals(rr.qname, zone)) + if(rr.qtype.getCode() == QType::NS && !pdns_iequals(rr.qname, zone)) nsset.insert(rr.qname); if(rr.qtype.getCode() == QType::DS) dsnames.insert(rr.qname); @@ -202,21 +203,25 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) NSEC3PARAMRecordContent ns3pr; bool narrow; bool haveNSEC3=dk.getNSEC3PARAM(zone, &ns3pr, &narrow); + bool isOptOut=(haveNSEC3 && ns3pr.d_flags); if(sd.db->doesDNSSEC()) { - if(!haveNSEC3) + if(!haveNSEC3) cerr<<"Adding NSEC ordering information "<startTransaction("", -1); - + bool realrr=true; string hashed; @@ -239,14 +244,17 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) if(haveNSEC3) { - if(!narrow) { + if(!narrow && (realrr || !isOptOut || nonterm.find(qname)->second)) { hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, qname))); if(g_verbose) cerr<<"'"< '"<< hashed <<"'"<updateDNSSECOrderAndAuthAbsolute(sd.domain_id, qname, hashed, auth); } - else + else { + if(!realrr) + auth=false; sd.db->nullifyDNSSECOrderNameAndUpdateAuth(sd.domain_id, qname, auth); + } } else // NSEC { @@ -260,33 +268,39 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) if (dsnames.count(qname)) sd.db->setDNSSECAuthOnDsRecord(sd.domain_id, qname); if (!auth || nsset.count(qname)) { - if(haveNSEC3 && ns3pr.d_flags) + if(isOptOut) sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "NS"); sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "A"); sd.db->nullifyDNSSECOrderNameAndAuth(sd.domain_id, qname, "AAAA"); } - if(auth && doent) + if(doent) { shorter=qname; while(!pdns_iequals(shorter, zone) && chopOff(shorter)) { - if(!qnames.count(shorter) && !nonterm.count(shorter)) + if(!qnames.count(shorter)) { if(!(maxent)) { - cerr<<"Zone '"<(shorter, auth)); + --maxent; + } else if (auth) + nonterm[shorter]=true; } } } @@ -303,7 +317,11 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone) if(doent) { realrr=false; - qnames=nonterm; + qnames.clear(); + pair nt; + BOOST_FOREACH(nt, nonterm){ + qnames.insert(nt.first); + } goto dononterm; } }