From: Kees Monshouwer Date: Thu, 24 Oct 2013 16:22:18 +0000 (+0200) Subject: move create dnssec db from backend to pdnssec X-Git-Tag: rec-3.6.0-rc1~363^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2b0e9b5535a922208dd007a708f0b7551ab4201;p=pdns move create dnssec db from backend to pdnssec --- diff --git a/modules/bindbackend/bindbackend2.hh b/modules/bindbackend/bindbackend2.hh index 9df82ff95..e55478723 100644 --- a/modules/bindbackend/bindbackend2.hh +++ b/modules/bindbackend/bindbackend2.hh @@ -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 diff --git a/modules/bindbackend/binddnssec.cc b/modules/bindbackend/binddnssec.cc index 866285443..a9e32351d 100644 --- a/modules/bindbackend/binddnssec.cc +++ b/modules/bindbackend/binddnssec.cc @@ -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 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; diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index a1f4b0d57..0f9fea4aa 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -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!"< #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"] <<"'" <(), cmds[0] == "create-bind-db"); + loadMainConfig(g_vm["config-dir"].as()); reportAllTypes(); if(cmds[0] == "create-bind-db") { +#ifdef HAVE_SQLITE3 if(cmds.size() != 2) { cerr << "Syntax: pdnssec create-bind-db fname"< 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"< &keys) return true; } -bool UeberBackend::createDNSSECDB(const string& fname) -{ - BOOST_FOREACH(DNSBackend* db, backends) { - db->createDNSSECDB(fname); - } - return true; -} void UeberBackend::reload() { diff --git a/pdns/ueberbackend.hh b/pdns/ueberbackend.hh index 72e5a7b40..ba061c9c0 100644 --- a/pdns/ueberbackend.hh +++ b/pdns/ueberbackend.hh @@ -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 *ips); void rediscover(string* status=0);