Show
Ignore:
Timestamp:
06/19/10 15:20:30 (3 years ago)
Author:
ahu
Message:

implement 'check-zone' for phibs, plus make powerdns crash violently if a non-dnssec backend tries to do dnssec

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/pdnssec.cc

    r1645 r1648  
    6363  ::arg().laxFile(configname.c_str()); 
    6464 
    65  
    6665  BackendMakers().launch(::arg()["launch"]); // vrooooom! 
    6766  ::arg().laxFile(configname.c_str());     
    68   cerr<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl; 
    69  
     67  cerr<<"Backend: "<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl; 
    7068 
    7169  S.declare("qsize-q","Number of questions waiting for database attention"); 
     
    132130} 
    133131 
     132void checkZone(DNSSECKeeper& dk, const std::string& zone) 
     133{ 
     134  loadMainConfig(); 
     135  reportAllTypes();   
     136  UeberBackend* B = new UeberBackend("default"); 
     137  SOAData sd; 
     138   
     139  if(!B->getSOA(zone, sd)) { 
     140    cerr<<"No SOA!"<<endl; 
     141    return; 
     142  }  
     143  cerr<<"ID: "<<sd.domain_id<<endl; 
     144  sd.db->list(zone, sd.domain_id); 
     145  DNSResourceRecord rr; 
     146  uint64_t numrecords=0, numerrors=0; 
     147   
     148    while(sd.db->get(rr)) { 
     149      if(rr.qtype.getCode() == QType::MX)  
     150        rr.content = lexical_cast<string>(rr.priority)+" "+rr.content; 
     151       
     152      try { 
     153        shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), 1, rr.content)); 
     154        string tmp=drc->serialize(rr.qname); 
     155      } 
     156      catch(std::exception& e)  
     157      { 
     158        cerr<<"Following record had a problem: "<<rr.qname<<" IN " <<rr.qtype.getName()<< " " << rr.content<<endl; 
     159        cerr<<"Error was: "<<e.what()<<endl; 
     160        numerrors++; 
     161      } 
     162      numrecords++; 
     163    } 
     164    cerr<<"Checked "<<numrecords<<" records, "<<numerrors<<" errors"<<endl; 
     165   
     166   
     167} 
     168 
     169 
    134170int main(int argc, char** argv) 
    135171try 
     
    167203    } 
    168204    orderZone(dk, cmds[1]); 
     205  } 
     206  if(cmds[0] == "check-zone") { 
     207    if(cmds.size() != 2) { 
     208      cerr << "Error: "<<cmds[0]<<" takes exactly 1 parameter"<<endl; 
     209      return 0; 
     210    } 
     211    checkZone(dk, cmds[1]); 
    169212  } 
    170213  else if(cmds[0] == "update-zone-keys") {