]> granicus.if.org Git - pdns/commitdiff
check for duplicate records with pdnssec check-all-zones (Issue #607)
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 9 Sep 2013 20:19:01 +0000 (22:19 +0200)
committermind04 <mind04@monshouwer.org>
Mon, 9 Sep 2013 21:20:44 +0000 (23:20 +0200)
pdns/pdnssec.cc

index 75d628bfd895b3f712e9583a7689406d4162c834..345414249eb9ad254f9cdf02ed0cc54c984c049b 100644 (file)
@@ -341,7 +341,7 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
   DNSResourceRecord rr;
   uint64_t numrecords=0, numerrors=0, numwarnings=0;
   
-  set<string> cnames, noncnames;
+  set<string> records, cnames, noncnames;
 
   while(sd.db->get(rr)) {
     if(!endsOn(rr.qname, zone)) {
@@ -353,6 +353,18 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
     if(!rr.qtype.getCode())
       continue;
 
+    ostringstream content;
+    content<<rr.qname<<" "<<rr.qtype.getName();
+    if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
+      content<<" "<<rr.priority;
+    content<<" "<<rr.content;
+    if (records.count(content.str())) {
+      cout<<"[Error] Duplicate record found '"<<content.str()<<"' This do not belong in the database."<<endl;
+      numerrors++;
+      continue;
+    } else
+      records.insert(content.str());
+
     if (rr.qtype.getCode() == QType::CNAME) {
       if (!cnames.count(rr.qname))
         cnames.insert(rr.qname);
@@ -366,6 +378,7 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
         if(!dk.isPresigned(zone)) {
           cout<<"[Error] RRSIG found at '"<<rr.qname<<"' in non-presigned zone. These do not belong in the database."<<endl;
           numerrors++;
+          continue;
         }
       } else
         noncnames.insert(rr.qname);