From: Peter van Dijk Date: Sun, 28 Jun 2015 18:29:39 +0000 (+0200) Subject: implement backend-cmd in pdnssec and gsqlbackend X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~77^2~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fc8bd15c5edb2e81c04f9fc57dac611e88d08e6;p=thirdparty%2Fpdns.git implement backend-cmd in pdnssec and gsqlbackend --- diff --git a/docs/manpages/pdnssec.1.md b/docs/manpages/pdnssec.1.md index 414033fe02..6569eb83a5 100644 --- a/docs/manpages/pdnssec.1.md +++ b/docs/manpages/pdnssec.1.md @@ -192,5 +192,11 @@ test-schema *ZONE* unset-presigned *ZONE* : Disables presigned operation for *ZONE*. +## DEBUGGING TOOLS + +backend-cmd *BACKEND* *CMD* [*CMD..*] +: Send a text command to a backend for execution. GSQL backends will take SQL + commands, other backends may take different things. Be careful! + # SEE ALSO pdns_server (1), pdns_control (1) diff --git a/docs/markdown/authoritative/dnssec.md b/docs/markdown/authoritative/dnssec.md index cffa434cd0..39d610188a 100644 --- a/docs/markdown/authoritative/dnssec.md +++ b/docs/markdown/authoritative/dnssec.md @@ -208,6 +208,7 @@ The following pdnssec commands are available: * `activate-zone-key ZONE KEY-ID`: Activate a key with id KEY-ID within a zone called ZONE. * `add-zone-key ZONE [ksk|zsk] [bits] [rsasha1|rsasha256|rsasha512|gost|ecdsa256|ecdsa384]`: Create a new key for zone ZONE, and make it a KSK or a ZSK, with the specified algorithm. +* `backend-cmd BACKEND CMD [CMD..]`: Send a text command to a backend for execution. GSQL backends will take SQL commands, other backends may take different things. Be careful! * `check-zone ZONE`: Check a zone for DNSSEC correctness. Main goals is to check if the auth flag is set correctly. * `check-all-zones`: Check all zones for DNSSEC correctness. Added in 3.1. * `deactivate-zone-key ZONE KEY-ID`: Deactivate a key with id KEY-ID within a zone called ZONE. diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index ced4e1675b..bd0a6ef262 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -1502,6 +1502,32 @@ bool GSQLBackend::replaceComments(const uint32_t domain_id, const string& qname, return true; } +string GSQLBackend::directBackendCmd(const string &query) +{ + try { + ostringstream out; + + unique_ptr stmt(d_db->prepare(query,0)); + + stmt->execute(); + + SSqlStatement::row_t row; + + while(stmt->hasNextRow()) { + stmt->nextRow(row); + for(const auto &col: row) + out<<"\'"<& comments); + string directBackendCmd(const string &query); private: string d_qname; diff --git a/pdns/dnsbackend.hh b/pdns/dnsbackend.hh index f729622bba..8a69715e6c 100644 --- a/pdns/dnsbackend.hh +++ b/pdns/dnsbackend.hh @@ -384,6 +384,11 @@ public: return false; } + virtual string directBackendCmd(const string &query) + { + return "directBackendCmd not supported for this backend\n"; + } + const string& getPrefix() { return d_prefix; }; protected: bool mustDo(const string &key); diff --git a/pdns/namespaces.hh b/pdns/namespaces.hh index 165f47334c..84f95d44c5 100644 --- a/pdns/namespaces.hh +++ b/pdns/namespaces.hh @@ -40,6 +40,7 @@ using std::string; using boost::lexical_cast; using boost::tie; using std::shared_ptr; +using std::unique_ptr; using boost::shared_array; using boost::scoped_array; using boost::tuple; diff --git a/pdns/pdnssec.cc b/pdns/pdnssec.cc index e2a870465a..606f921bea 100644 --- a/pdns/pdnssec.cc +++ b/pdns/pdnssec.cc @@ -1293,6 +1293,7 @@ try cerr<<"add-zone-key ZONE zsk|ksk [bits] [active|passive]"<getPrefix() == cmds[1]) db = b; + } + + if (!db) { + cerr<<"Unknown backend '"<directBackendCmd(*i); + } + return 0; } else { cerr<<"Unknown command '"<