]> granicus.if.org Git - pdns/commitdiff
implement 'check-zone' for phibs, plus make powerdns crash violently if a non-dnssec...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 19 Jun 2010 13:20:30 +0000 (13:20 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 19 Jun 2010 13:20:30 +0000 (13:20 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1648 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/dnsbackend.hh
pdns/pdnssec.cc

index eb30b06d4817c0067065ae926624764a75cf87a8..4514b061ec4928cd79f3f01884ec17855e7e4d8f 100644 (file)
@@ -77,6 +77,7 @@ public:
   virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after)
   {
     std::cerr<<"Default beforeAndAfterAbsolute called!"<<std::endl;
+    abort();
     return false;
   }
 
index a92fcece93b33828ec4f0f83d0c85efdad274cee..5f82893e73b62dd3c6bcb6018283f417e50edc48 100644 (file)
@@ -62,11 +62,9 @@ void loadMainConfig()
   
   ::arg().laxFile(configname.c_str());
 
-
   BackendMakers().launch(::arg()["launch"]); // vrooooom!
   ::arg().laxFile(configname.c_str());    
-  cerr<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl;
-
+  cerr<<"Backend: "<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl;
 
   S.declare("qsize-q","Number of questions waiting for database attention");
     
@@ -131,6 +129,44 @@ void orderZone(DNSSECKeeper& dk, const std::string& zone)
   cerr<<"Done listing"<<endl;
 }
 
+void checkZone(DNSSECKeeper& dk, const std::string& zone)
+{
+  loadMainConfig();
+  reportAllTypes();  
+  UeberBackend* B = new UeberBackend("default");
+  SOAData sd;
+  
+  if(!B->getSOA(zone, sd)) {
+    cerr<<"No SOA!"<<endl;
+    return;
+  } 
+  cerr<<"ID: "<<sd.domain_id<<endl;
+  sd.db->list(zone, sd.domain_id);
+  DNSResourceRecord rr;
+  uint64_t numrecords=0, numerrors=0;
+  
+    while(sd.db->get(rr)) {
+      if(rr.qtype.getCode() == QType::MX) 
+       rr.content = lexical_cast<string>(rr.priority)+" "+rr.content;
+      
+      try {
+       shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content));
+       string tmp=drc->serialize(rr.qname);
+      }
+      catch(std::exception& e) 
+      {
+       cerr<<"Following record had a problem: "<<rr.qname<<" IN " <<rr.qtype.getName()<< " " << rr.content<<endl;
+       cerr<<"Error was: "<<e.what()<<endl;
+       numerrors++;
+      }
+      numrecords++;
+    }
+    cerr<<"Checked "<<numrecords<<" records, "<<numerrors<<" errors"<<endl;
+  
+  
+}
+
+
 int main(int argc, char** argv)
 try
 {
@@ -167,6 +203,13 @@ try
     }
     orderZone(dk, cmds[1]);
   }
+  if(cmds[0] == "check-zone") {
+    if(cmds.size() != 2) {
+      cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl;
+      return 0;
+    }
+    checkZone(dk, cmds[1]);
+  }
   else if(cmds[0] == "update-zone-keys") {
     if(cmds.size() != 2) {
       cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl;