]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
pdnssec check-all-zones now detect ttl differnce within a rrset
authorKees Monshouwer <mind04@monshouwer.org>
Mon, 9 Sep 2013 21:17:46 +0000 (23:17 +0200)
committermind04 <mind04@monshouwer.org>
Fri, 22 Nov 2013 00:02:29 +0000 (01:02 +0100)
pdns/pdnssec.cc

index 1f67417c02db7d0376f25740ce164f9a97be008c..87fa47d5ad409de5edd9b148f88d700d2e0269fa 100644 (file)
@@ -338,36 +338,49 @@ int checkZone(DNSSECKeeper &dk, UeberBackend &B, const std::string& zone)
   sd.db->list(zone, sd.domain_id);
   DNSResourceRecord rr;
   uint64_t numrecords=0, numerrors=0, numwarnings=0;
-  
+
   set<string> records, cnames, noncnames;
+  map<string, int> ttl;
+
+  ostringstream content;
+  pair<map<string, int>::iterator,bool> ret;
 
   while(sd.db->get(rr)) {
+    if(!rr.qtype.getCode())
+      continue;
+
     if(!endsOn(rr.qname, zone)) {
-      cout<<"[Warning] The record "<<rr.qname<<" with type "<<rr.qtype.getName()<<" in zone "<<zone<<" is out-of-zone."<<endl;
+      cout<<"[Warning] The record '"<<rr.qname<<"' with type "<<rr.qtype.getName()<<" in zone "<<zone<<" is out-of-zone."<<endl;
       numwarnings++;
       continue;
     }
 
-    if(!rr.qtype.getCode())
-      continue;
-
-    ostringstream content;
+    content.str("");
     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;
+      cout<<"[Error] Duplicate record found in rrset '"<<rr.qname<<"' with type "<<rr.qtype.getName()<<"."<<endl;
       numerrors++;
       continue;
     } else
       records.insert(content.str());
 
+    content.str("");
+    content<<rr.qname<<" "<<rr.qtype.getName();
+    ret = ttl.insert(pair<string ,int>(content.str(), rr.ttl));
+    if (ret.second==false && ret.first->second != rr.ttl) {
+      cout<<"[Error] TTL mismatch in rrset '"<<rr.qname<<"' with type "<<rr.qtype.getName()<<" ("<<ret.first->second<<" <> "<<rr.ttl<<")"<<endl;
+      numerrors++;
+      continue;
+    }
+
     if (rr.qtype.getCode() == QType::CNAME) {
       if (!cnames.count(rr.qname))
         cnames.insert(rr.qname);
       else {
-        cout<<"[Error] Duplicate CNAME found at '"<<rr.qname<<"'. These do not belong in the database."<<endl;
+        cout<<"[Error] Duplicate CNAME found at '"<<rr.qname<<"'."<<endl;
         numerrors++;
         continue;
       }