]> granicus.if.org Git - pdns/commitdiff
fix pdnssec create-bind-db
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 24 Oct 2013 13:48:37 +0000 (15:48 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 29 Oct 2013 19:26:27 +0000 (20:26 +0100)
modules/bindbackend/bindbackend2.hh
modules/bindbackend/binddnssec.cc
pdns/dnsbackend.hh
pdns/pdnssec.cc
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index 67e5df5d195febfb58468e97dfc730cc17a69fdf..9df82ff9541ed335a8f583168a49a5af89e3a4b0 100644 (file)
@@ -163,7 +163,7 @@ public:
   virtual bool setTSIGKey(const string& name, const string& algorithm, const string& content);
   virtual bool deleteTSIGKey(const string& name);
   virtual bool getTSIGKeys(std::vector< struct TSIGKey > &keys);
-  static void createDNSSECDB(const string& fname);
+  virtual bool createDNSSECDB(const string& fname);
   virtual bool doesDNSSEC();
   // end of DNSSEC 
 
index 5dc7557f5779fe5ff015339ba273f31b5a21412e..8662854433f375315eee2bc64e4d4ce80277d7ed 100644 (file)
@@ -34,7 +34,7 @@ void Bind2Backend::setupDNSSEC()
 }
 
 void Bind2Backend::createDNSSECDB(const string& fname)
-{}
+{ return false; }
 
 bool Bind2Backend::doesDNSSEC()
 { return false; }
@@ -93,7 +93,7 @@ void Bind2Backend::setupDNSSEC()
   d_dnssecdb->setLog(::arg().mustDo("query-logging"));
 }
 
-void Bind2Backend::createDNSSECDB(const string& fname)
+bool Bind2Backend::createDNSSECDB(const string& fname)
 {
   try {
     SSQLite3 db(fname, true); // create=ok
@@ -105,6 +105,7 @@ void Bind2Backend::createDNSSECDB(const string& fname)
   catch(SSqlException& se) {
     throw PDNSException("Error creating database in BIND backend: "+se.txtReason());
   }
+  return true;
 }
 
 bool Bind2Backend::doesDNSSEC()
index 0f9fea4aa6025e9d46893d83340e2ead1b9f2cfb..a1f4b0d570a962065b81b2eb546a1cd8c0d20616 100644 (file)
@@ -158,6 +158,8 @@ public:
   virtual bool deleteTSIGKey(const string& name) { return false; }
   virtual bool getTSIGKeys(std::vector< struct TSIGKey > &keys) { return false; }
 
+  virtual bool createDNSSECDB(const string& fname) { return false; }
+
   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;
index ef09fbdc714ed3103e8dcf7d605f92430da120f1..1d56ac387460fddc532faea7967555222b74dc99 100644 (file)
@@ -101,7 +101,7 @@ static int shorthand2algorithm(const string &algorithm)
   return -1;
 }
 
-void loadMainConfig(const std::string& configdir)
+void loadMainConfig(const std::string& configdir, bool launchBind)
 {
   ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=configdir;
   ::arg().set("pipebackend-abi-version","Version of the pipe backend ABI")="1";
@@ -135,7 +135,10 @@ void loadMainConfig(const std::string& configdir)
   ::arg().setSwitch("experimental-direct-dnskey","EXPERIMENTAL: fetch DNSKEY RRs from backend during DNSKEY synthesis")="no";
   ::arg().laxFile(configname.c_str());
 
-  BackendMakers().launch(::arg()["launch"]); // vrooooom!
+  if (launchBind)
+    BackendMakers().launch("bind");
+  else
+    BackendMakers().launch(::arg()["launch"]); // vrooooom!
   ::arg().laxFile(configname.c_str());    
   //cerr<<"Backend: "<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl;
 
@@ -1081,9 +1084,21 @@ try
     return 0;
   }
 
-  loadMainConfig(g_vm["config-dir"].as<string>());
+  loadMainConfig(g_vm["config-dir"].as<string>(), cmds[0] == "create-bind-db");
   reportAllTypes();
 
+  if(cmds[0] == "create-bind-db") {
+    if(cmds.size() != 2) {
+      cerr << "Syntax: pdnssec create-bind-db fname"<<endl;
+      return 0;
+    }
+    UeberBackend B("default");
+    if (!B.createDNSSECDB(cmds[1]))
+      return 1;
+    else
+      return 0;
+  }
+
   DNSSECKeeper dk;
 
   if (cmds[0] == "test-schema") {
index fb27c53dcc1edd713f9ef0e330f1738209096792..6c8a6ef74e5f7afa792ad891cc2c5bc757f11999 100644 (file)
@@ -216,6 +216,13 @@ bool UeberBackend::getTSIGKeys(std::vector< struct TSIGKey > &keys)
   return true;
 }
 
+bool UeberBackend::createDNSSECDB(const string& fname)
+{
+  BOOST_FOREACH(DNSBackend* db, backends) {
+    db->createDNSSECDB(fname);
+  }
+  return true;
+}
 
 void UeberBackend::reload()
 {
index 3c29cff0b77c4533e4b0721c6d18d7ed04b6b5f4..72e5a7b40b964a03798b70b39d43db354d28f6b8 100644 (file)
@@ -140,6 +140,8 @@ public:
   bool deleteTSIGKey(const string& name);
   bool getTSIGKeys(std::vector< struct TSIGKey > &keys);
 
+  bool createDNSSECDB(const string& fname);
+
   void alsoNotifies(const string &domain, set<string> *ips); 
   void rediscover(string* status=0);
   void reload();