]> granicus.if.org Git - pdns/commitdiff
move create dnssec db from backend to pdnssec
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 24 Oct 2013 16:22:18 +0000 (18:22 +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 9df82ff9541ed335a8f583168a49a5af89e3a4b0..e55478723b7948bef153389a68b161b9f72cef39 100644 (file)
@@ -163,7 +163,6 @@ 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);
-  virtual bool createDNSSECDB(const string& fname);
   virtual bool doesDNSSEC();
   // end of DNSSEC 
 
index 8662854433f375315eee2bc64e4d4ce80277d7ed..a9e32351df16b2c4a9db8dec098afb1306eda22e 100644 (file)
@@ -33,9 +33,6 @@ void Bind2Backend::setupDNSSEC()
     throw runtime_error("bind-dnssec-db requires building PowerDNS with SQLite3");
 }
 
-void Bind2Backend::createDNSSECDB(const string& fname)
-{ return false; }
-
 bool Bind2Backend::doesDNSSEC()
 { return false; }
 
@@ -93,21 +90,6 @@ void Bind2Backend::setupDNSSEC()
   d_dnssecdb->setLog(::arg().mustDo("query-logging"));
 }
 
-bool Bind2Backend::createDNSSECDB(const string& fname)
-{
-  try {
-    SSQLite3 db(fname, true); // create=ok
-    vector<string> statements;
-    stringtok(statements, sqlCreate, ";");
-    BOOST_FOREACH(const string& statement, statements)
-      db.doCommand(statement);
-  }
-  catch(SSqlException& se) {
-    throw PDNSException("Error creating database in BIND backend: "+se.txtReason());
-  }
-  return true;
-}
-
 bool Bind2Backend::doesDNSSEC()
 {
   return true;
index a1f4b0d570a962065b81b2eb546a1cd8c0d20616..0f9fea4aa6025e9d46893d83340e2ead1b9f2cfb 100644 (file)
@@ -158,8 +158,6 @@ 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 1d56ac387460fddc532faea7967555222b74dc99..73ae638514ed6da31dfdb0a91e41242a6da82655 100644 (file)
 #include "signingpipe.hh"
 #include <boost/scoped_ptr.hpp>
 #include "dns_random.hh"
+#ifdef HAVE_SQLITE3
+#include "ssqlite3.hh"
+#include "../modules/bindbackend/bind-dnssec.schema.sqlite3.sql.h"
+#endif
 
 StatBag S;
 PacketCache PC;
@@ -101,7 +105,7 @@ static int shorthand2algorithm(const string &algorithm)
   return -1;
 }
 
-void loadMainConfig(const std::string& configdir, bool launchBind)
+void loadMainConfig(const std::string& configdir)
 {
   ::arg().set("config-dir","Location of configuration directory (pdns.conf)")=configdir;
   ::arg().set("pipebackend-abi-version","Version of the pipe backend ABI")="1";
@@ -135,10 +139,7 @@ void loadMainConfig(const std::string& configdir, bool launchBind)
   ::arg().setSwitch("experimental-direct-dnskey","EXPERIMENTAL: fetch DNSKEY RRs from backend during DNSKEY synthesis")="no";
   ::arg().laxFile(configname.c_str());
 
-  if (launchBind)
-    BackendMakers().launch("bind");
-  else
-    BackendMakers().launch(::arg()["launch"]); // vrooooom!
+  BackendMakers().launch(::arg()["launch"]); // vrooooom!
   ::arg().laxFile(configname.c_str());    
   //cerr<<"Backend: "<<::arg()["launch"]<<", '" << ::arg()["gmysql-dbname"] <<"'" <<endl;
 
@@ -1084,19 +1085,30 @@ try
     return 0;
   }
 
-  loadMainConfig(g_vm["config-dir"].as<string>(), cmds[0] == "create-bind-db");
+  loadMainConfig(g_vm["config-dir"].as<string>());
   reportAllTypes();
 
   if(cmds[0] == "create-bind-db") {
+#ifdef HAVE_SQLITE3
     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;
+    try {
+      SSQLite3 db(cmds[1], true); // create=ok
+      vector<string> statements;
+      stringtok(statements, sqlCreate, ";");
+      BOOST_FOREACH(const string& statement, statements)
+        db.doCommand(statement);
+    }
+    catch(SSqlException& se) {
+      throw PDNSException("Error creating database in BIND backend: "+se.txtReason());
+    }
+    return 0;
+#else
+    cerr<<"bind-dnssec-db requires build PowerDNS with SQLite3"<<endl;
+    return 1;
+#endif
   }
 
   DNSSECKeeper dk;
index 6c8a6ef74e5f7afa792ad891cc2c5bc757f11999..fb27c53dcc1edd713f9ef0e330f1738209096792 100644 (file)
@@ -216,13 +216,6 @@ 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 72e5a7b40b964a03798b70b39d43db354d28f6b8..ba061c9c07439686f6628a1fefdb4e9931e97e2e 100644 (file)
@@ -140,7 +140,6 @@ 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);