From: Kees Monshouwer Date: Wed, 18 Sep 2019 11:41:13 +0000 (+0200) Subject: auth: remove the oracle backends X-Git-Tag: dnsdist-1.4.0-rc3~35^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ce1cbb787fb9c5e05e8f95550fde58bc5c695cf;p=pdns auth: remove the oracle backends --- diff --git a/builder-support/debian/authoritative/debian-jessie/copyright b/builder-support/debian/authoritative/debian-jessie/copyright index 36fd485f7..c45339f92 100644 --- a/builder-support/debian/authoritative/debian-jessie/copyright +++ b/builder-support/debian/authoritative/debian-jessie/copyright @@ -65,12 +65,6 @@ Files: modules/luabackend/* Copyright: 2011 Fredrik Danerklint License: GPL-2 with OpenSSL Exception -Files: modules/oraclebackend/* -Copyright: 2010 - 2011 Maik Zumstrull - Steinbuch Centre for Computing, - Karlsruhe Institute of Technology -License: Expat - Files: modules/opendbxbackend/* Copyright: 2005-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception diff --git a/builder-support/debian/authoritative/debian-stretch/copyright b/builder-support/debian/authoritative/debian-stretch/copyright index 36fd485f7..c45339f92 100644 --- a/builder-support/debian/authoritative/debian-stretch/copyright +++ b/builder-support/debian/authoritative/debian-stretch/copyright @@ -65,12 +65,6 @@ Files: modules/luabackend/* Copyright: 2011 Fredrik Danerklint License: GPL-2 with OpenSSL Exception -Files: modules/oraclebackend/* -Copyright: 2010 - 2011 Maik Zumstrull - Steinbuch Centre for Computing, - Karlsruhe Institute of Technology -License: Expat - Files: modules/opendbxbackend/* Copyright: 2005-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception diff --git a/builder-support/debian/authoritative/ubuntu-trusty/copyright b/builder-support/debian/authoritative/ubuntu-trusty/copyright index 36fd485f7..c45339f92 100644 --- a/builder-support/debian/authoritative/ubuntu-trusty/copyright +++ b/builder-support/debian/authoritative/ubuntu-trusty/copyright @@ -65,12 +65,6 @@ Files: modules/luabackend/* Copyright: 2011 Fredrik Danerklint License: GPL-2 with OpenSSL Exception -Files: modules/oraclebackend/* -Copyright: 2010 - 2011 Maik Zumstrull - Steinbuch Centre for Computing, - Karlsruhe Institute of Technology -License: Expat - Files: modules/opendbxbackend/* Copyright: 2005-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception diff --git a/configure.ac b/configure.ac index 912361bc6..5efd2c4b1 100644 --- a/configure.ac +++ b/configure.ac @@ -173,10 +173,6 @@ AS_IF([test x"$dynmodules" = "xno"], [dynmodules=""]) for a in $modules $dynmodules; do case "$a" in - oracle|goracle) - PDNS_WITH_ORACLE - needoracle=yes - ;; godbc) PDNS_WITH_UNIXODBC ;; @@ -234,8 +230,6 @@ PDNS_WITH_PROTOBUF PDNS_WITH_LUA_RECORDS -AM_CONDITIONAL([ORACLE], [test "x$needoracle" = "xyes"]) - AM_CONDITIONAL([LDAP], [test "x$needldap" = "xyes"]) PDNS_CHECK_SQLITE3 @@ -340,7 +334,6 @@ AC_CONFIG_FILES([ modules/geoipbackend/Makefile modules/gmysqlbackend/Makefile modules/godbcbackend/Makefile - modules/goraclebackend/Makefile modules/gpgsqlbackend/Makefile modules/gsqlite3backend/Makefile modules/ldapbackend/Makefile @@ -349,7 +342,6 @@ AC_CONFIG_FILES([ modules/lua2backend/Makefile modules/mydnsbackend/Makefile modules/opendbxbackend/Makefile - modules/oraclebackend/Makefile modules/pipebackend/Makefile modules/randombackend/Makefile modules/remotebackend/Makefile diff --git a/docs/appendices/FAQ.rst b/docs/appendices/FAQ.rst index cc2c4b21c..e464cd0c8 100644 --- a/docs/appendices/FAQ.rst +++ b/docs/appendices/FAQ.rst @@ -89,7 +89,7 @@ Which backend should I use? There are so many! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ If you have no external constraints, the :doc:`../backends/generic-mysql`, :doc:`../backends/generic-postgresql` and :doc:`../backends/generic-sqlite3` ones are probably the most used and complete. -The Oracle backend also has happy users, the BIND backend is pretty capable too in fact, but many prefer a relational database. +The bindbackend is also pretty capable too in fact, but many prefer a relational database. Can I launch multiple backends simultaneously? ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/backends/generic-odbc.rst b/docs/backends/generic-odbc.rst index 6c6b3997a..2b1400ae6 100644 --- a/docs/backends/generic-odbc.rst +++ b/docs/backends/generic-odbc.rst @@ -20,7 +20,7 @@ to the databases supported by said drivers. .. warning:: When there is a more specific generic sql backend (like - goracle or gmysql), it is highly recommended to use that backend + gmysql or gsqlite3), it is highly recommended to use that backend instead! Enabling the backend diff --git a/docs/backends/index.rst b/docs/backends/index.rst index 4969e2c03..597ff97d5 100644 --- a/docs/backends/index.rst +++ b/docs/backends/index.rst @@ -12,8 +12,6 @@ The following table describes the supported backends and some of their capabilit +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Generic ODBC ` | Yes | Yes | Yes | Yes | Yes | ``godbc`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ -| :doc:`Generic Oracle ` | Yes | Yes | Yes | Yes | Yes | ``goracle`` | -+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Generic Postgresql ` | Yes | Yes | Yes | Yes | Yes | ``gpgsql`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Generic SQLite3 ` | Yes | Yes | Yes | Yes | Yes | ``gsqlite3`` | @@ -32,8 +30,6 @@ The following table describes the supported backends and some of their capabilit +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`OpenDBX ` | Yes | Yes | Yes | Yes | No | ``opendbx`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ -| :doc:`Oracle ` | Yes | Yes | Yes | Yes | Yes | ``oracle`` | -+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Pipe ` | Yes | No | No | No | Partial | ``pipe`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Random ` | Yes | No | No | No | Partial | ``random`` | @@ -54,7 +50,6 @@ These backends have :doc:`features unique ` to the generic SQL back generic-sql generic-mysql generic-odbc - generic-oracle generic-postgresql generic-sqlite3 geoip @@ -64,7 +59,6 @@ These backends have :doc:`features unique ` to the generic SQL back lua2 mydns opendbx - oracle pipe random remote diff --git a/docs/conf.py b/docs/conf.py index 9849a691c..d400b7e63 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -93,7 +93,7 @@ changelog_render_pullreq = "https://github.com/PowerDNS/pdns/pull/%s" changelog_render_changeset = "https://github.com/PowerDNS/pdns/commit/%s" changelog_sections = ['New Features', 'Removed Features', 'Improvements', 'Bug Fixes'] -changelog_inner_tag_sort = ['Internals', 'API', 'Tools', 'ALIAS', 'DNSUpdate', 'BIND', 'MySQL', 'Postgresql', 'Oracle', 'LDAP', 'GeoIP', 'Remote'] +changelog_inner_tag_sort = ['Internals', 'API', 'Tools', 'ALIAS', 'DNSUpdate', 'BIND', 'MySQL', 'Postgresql', 'LDAP', 'GeoIP', 'Remote'] changelog_render_tags = False diff --git a/docs/dnsupdate.rst b/docs/dnsupdate.rst index 301358fe2..e539fb47d 100644 --- a/docs/dnsupdate.rst +++ b/docs/dnsupdate.rst @@ -16,7 +16,6 @@ support DNS update: - :doc:`gmysql ` - :doc:`gpgsql ` - :doc:`gsqlite3 ` -- :doc:`goracle ` - :doc:`godbc ` .. _dnsupdate-configuration-options: diff --git a/docs/index.rst b/docs/index.rst index f20a95668..086287c9c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -7,7 +7,7 @@ zone files or be more dynamic in nature. PowerDNS has the concepts of 'backends'. A backend is a datastore that the server will consult that contains DNS records (and some metadata). -The backends range from database backends (:doc:`MySQL `, :doc:`PostgreSQL `, :doc:`Oracle `) +The backends range from database backends (:doc:`MySQL `, :doc:`PostgreSQL `) and :doc:`BIND zone files ` to :doc:`co-processes ` and :doc:`JSON API's `. Multiple backends can be enabled in the configuration by using the diff --git a/docs/manpages/zone2sql.1.rst b/docs/manpages/zone2sql.1.rst index 0cb197278..e3240748b 100644 --- a/docs/manpages/zone2sql.1.rst +++ b/docs/manpages/zone2sql.1.rst @@ -19,7 +19,7 @@ For backends supporting slave operation there is also an option to keep slave zones as slaves, and not convert them to native operation. :program:`zone2sql` can generate SQL for the Generic MySQL, Generic PostgreSQL, -Generic SQLite3 and Generic Oracle backends. +Generic SQLite3 backend. Options ------- @@ -44,14 +44,8 @@ BACKENDS --gsqlite Output in format suitable for the default configuration of the Generic SQLite3 backend. ---goracle - Output in format suitable for the default configuration of the - Generic Oracle backend. --mydns Output in a format suitable for the MyDNS backend. ---oracle - Output in format suitable for the default configuration of the - Oracle backend. OUTPUT Options -------------- diff --git a/docs/modes-of-operation.rst b/docs/modes-of-operation.rst index 0e0d8e3e9..d2f6aabe0 100644 --- a/docs/modes-of-operation.rst +++ b/docs/modes-of-operation.rst @@ -17,8 +17,7 @@ them. PowerDNS assumes that the backend is taking care of replication unaided. MySQL replication has proven to be very robust and well suited, even -over transatlantic connections between badly peering ISPs. Other -PowerDNS users employ Oracle replication which also works very well. +over transatlantic connections between badly peering ISPs. To use native replication, configure your backend storage to do the replication and do not configure PowerDNS to do so. @@ -132,7 +131,7 @@ updated and if so, retransfering it. All backends which implement this feature must make sure that they can handle transactions so as to not leave the zone in a half updated state. MySQL configured with either BerkeleyDB or InnoDB meets this -requirement, as do PostgreSQL and Oracle. The BIND backend implements +requirement, as do PostgreSQL. The BIND backend implements transaction semantics by renaming files if and only if they have been retrieved completely and parsed correctly. diff --git a/m4/pdns_with_oracle.m4 b/m4/pdns_with_oracle.m4 deleted file mode 100644 index 0f16fbd0d..000000000 --- a/m4/pdns_with_oracle.m4 +++ /dev/null @@ -1,62 +0,0 @@ -AC_DEFUN([PDNS_WITH_ORACLE],[ - AC_ARG_WITH(oracle_includes, AS_HELP_STRING([--with-oracle-includes=],[instantclient sdk include dir])) - AC_ARG_WITH(oracle_libs, AS_HELP_STRING([--with-oracle-libs=],[instantclient oracle library dir])) - - if test x"$with_oracle_includes" = "x"; then - # check possible locations - for p1 in /usr/include/oracle /usr/local/include/oracle; do - for p2 in $p1/*/client*; do - if test -d "$p2"; then - with_oracle_includes=$p2 - fi - done - done - fi - - if test x"$with_oracle_includes" = x && test "$ORACLE_HOME/rdbms/public" != "/rdbms/public"; then - if test -d $ORACLE_HOME/rdbms/public; then - with_oracle_includes=$ORACLE_HOME/rdbms/public - fi - fi - - # test header - old_CXXFLAGS="$CXXFLAGS" - old_CFLAGS="$CFLAGS" - CXXFLAGS="$CXXFLAGS -I$with_oracle_includes" - CPPFLAGS="$CPPFLAGS -I$with_oracle_includes" - AC_CHECK_HEADER([oci.h], ORACLE_CFLAGS="-I$with_oracle_includes", AC_MSG_ERROR([Could not find oci.h])) - CXXFLAGS="$old_CXXFLAGS" - CPPFLAGS="$old_CPPFLAGS" - AC_SUBST([ORACLE_CFLAGS]) - AC_SUBST([ORACLE_LIBS]) - - if test x"$with_oracle_libs" = "x"; then - # check possible locations - for p1 in /usr/lib/oracle /usr/local/lib/oracle; do - for p2 in $p1/*/client*/lib; do - if test -d "$p2"; then - with_oracle_libs=$p2 - fi - done - done - fi - - if test x"$with_oracle_libs" = x && test "$ORACLE_HOME/lib" != "/lib"; then - if test -d $ORACLE_HOME/lib; then - with_oracle_libs=$ORACLE_HOME/lib - fi - fi - - # we have to check for client9 as well... - # test -lclntsh - old_LDFLAGS="$LDFLAGS" - LDFLAGS="-L$with_oracle_libs -locci" - AC_CHECK_LIB([clntsh],[OCIEnvInit], - [ORACLE_LIBS="-L$with_oracle_libs -lclntsh -locci"], - AC_CHECK_LIB([client9], [OCIEnvInit], - [ORACLE_LIBS="-L$with_oracle_libs -lclient9 -lclntsh9"], - [AC_MSG_ERROR([Could not find client libraries])] - ) - ) - LDFLAGS="$old_LDFLAGS" -]) diff --git a/modules/Makefile.am b/modules/Makefile.am index 65887fbc7..f3701b767 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -5,7 +5,6 @@ DIST_SUBDIRS = \ geoipbackend \ gmysqlbackend \ godbcbackend \ - goraclebackend \ gpgsqlbackend \ gsqlite3backend \ ldapbackend \ @@ -14,7 +13,6 @@ DIST_SUBDIRS = \ lua2backend \ mydnsbackend \ opendbxbackend \ - oraclebackend \ pipebackend \ randombackend \ remotebackend \ diff --git a/modules/goraclebackend/Makefile.am b/modules/goraclebackend/Makefile.am deleted file mode 100644 index f4fdf9247..000000000 --- a/modules/goraclebackend/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -AM_CPPFLAGS += $(ORACLE_CFLAGS) - -pkglib_LTLIBRARIES = libgoraclebackend.la - -EXTRA_DIST = \ - OBJECTFILES \ - OBJECTLIBS \ - drop-schema.goracle.sql \ - schema.goracle.sql - -dist_doc_DATA = \ - drop-schema.goracle.sql \ - schema.goracle.sql - -libgoraclebackend_la_SOURCES = \ - goraclebackend.cc goraclebackend.hh \ - soracle.cc soracle.hh - -libgoraclebackend_la_LDFLAGS = -module -avoid-version -libgoraclebackend_la_LIBADD = $(ORACLE_LIBS) diff --git a/modules/goraclebackend/OBJECTFILES b/modules/goraclebackend/OBJECTFILES deleted file mode 100644 index 4ea82a04c..000000000 --- a/modules/goraclebackend/OBJECTFILES +++ /dev/null @@ -1 +0,0 @@ -goraclebackend.lo soracle.lo diff --git a/modules/goraclebackend/OBJECTLIBS b/modules/goraclebackend/OBJECTLIBS deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/goraclebackend/drop-schema.goracle.sql b/modules/goraclebackend/drop-schema.goracle.sql deleted file mode 100644 index 2edd3088e..000000000 --- a/modules/goraclebackend/drop-schema.goracle.sql +++ /dev/null @@ -1,19 +0,0 @@ -DROP TABLE records; -DROP SEQUENCE records_id_sequence; - -DROP TABLE supermasters; - -DROP TABLE comments; -DROP SEQUENCE comments_id_sequence; - -DROP TABLE domainmetadata; -DROP SEQUENCE domainmetadata_id_sequence; - -DROP TABLE cryptokeys; -DROP SEQUENCE cryptokeys_id_sequence; - -DROP TABLE tsigkeys; -DROP SEQUENCE tsigkeys_id_sequence; - -DROP TABLE domains; -DROP SEQUENCE domains_id_sequence; diff --git a/modules/goraclebackend/goraclebackend.cc b/modules/goraclebackend/goraclebackend.cc deleted file mode 100644 index f18c47630..000000000 --- a/modules/goraclebackend/goraclebackend.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include "pdns/namespaces.hh" -#include "pdns/dns.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/dnspacket.hh" -#include "pdns/pdnsexception.hh" -#include "pdns/logger.hh" -#include "pdns/arguments.hh" -#include "pdns/lock.hh" -#include "goraclebackend.hh" -#include "soracle.hh" -#include - -static OCIEnv* d_environmentHandle = 0; -static pthread_mutex_t s_goracle_lock=PTHREAD_MUTEX_INITIALIZER; - -gOracleBackend::gOracleBackend(const string &mode, const string &suffix) : GSQLBackend(mode, suffix) -{ - Lock gl(&s_goracle_lock); - if (d_environmentHandle == 0) { - setenv("ORACLE_HOME", getArg("home").c_str(), 1); - setenv("ORACLE_SID", getArg("sid").c_str(), 1); - setenv("NLS_LANG", getArg("nls-lang").c_str(), 1); - - int err = OCIEnvCreate(&d_environmentHandle, OCI_THREADED, NULL, NULL, NULL, NULL, 0, NULL); - - if (err) { - throw PDNSException("OCIEnvCreate failed"); - } - } - - try { - // set Oracle environment variables - setDB(new SOracle(getArg("tnsname"), - getArg("user"), - getArg("password"), - mustDo("release-statements"), - d_environmentHandle)); - } - - catch (SSqlException &e) { - g_log< :ordername || ' ' and domain_id=:domain_id and ordername is not null"); - declare(suffix, "get-order-last-query", "DNSSEC Ordering Query, last", "select * from (select trim(ordername), name from records where disabled=0 and ordername != ' ' and domain_id=:domain_id and ordername is not null order by ordername desc) where rownum=1"); - - declare(suffix, "update-ordername-and-auth-query", "DNSSEC update ordername and auth for a qname query", "update records set ordername=:ordername || ' ',auth=:auth where domain_id=:domain_id and name=:qname and disabled=0"); - declare(suffix, "update-ordername-and-auth-type-query", "DNSSEC update ordername and auth for a rrset query", "update records set ordername=:ordername || ' ',auth=:auth where domain_id=:domain_id and name=:qname and type=:qtype and disabled=0"); - declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth for a qname query", "update records set ordername=NULL,auth=:auth where domain_id=:domain_id and name=:qname and disabled=0"); - declare(suffix, "nullify-ordername-and-update-auth-type-query", "DNSSEC nullify ordername and update auth for a rrset query", "update records set ordername=NULL,auth=:auth where domain_id=:domain_id and name=:qname and type=:qtype and disabled=0"); - - declare(suffix, "update-master-query", "", "update domains set master=:master where name=:domain"); - declare(suffix, "update-kind-query", "", "update domains set type=:kind where name=:domain"); - declare(suffix, "update-account-query", "", "update domains set account=:account where name=:domain"); - declare(suffix, "update-serial-query", "", "update domains set notified_serial=:serial where id=:domain_id"); - declare(suffix, "update-lastcheck-query", "", "update domains set last_check=:last_check where id=:domain_id"); - declare(suffix, "info-all-master-query", "", "select id,name,master,last_check,notified_serial,type from domains where type='MASTER'"); - declare(suffix, "delete-domain-query","", "delete from domains where name=:domain"); - declare(suffix, "delete-zone-query", "", "delete from records where domain_id=:domain_id"); - declare(suffix, "delete-rrset-query", "", "delete from records where domain_id=:domain_id and name=:qname and type=:qtype"); - declare(suffix, "delete-names-query", "", "delete from records where domain_id=:domain_id and name=:qname"); - - declare(suffix, "add-domain-key-query","", "insert into cryptokeys (id, domain_id, flags, active, content) select cryptokeys_id_sequence.nextval, id, :flags,:active, :content from domains where name=:domain"); - declare(suffix, "get-last-inserted-key-id-query", "", "select cryptokeys_id_sequence.currval from DUAL"); - declare(suffix, "list-domain-keys-query","", "select cryptokeys.id, flags, active, content from domains, cryptokeys where cryptokeys.domain_id=domains.id and name=:domain"); - declare(suffix, "get-all-domain-metadata-query","", "select kind,content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name=:domain"); - declare(suffix, "get-domain-metadata-query","", "select content from domains, domainmetadata where domainmetadata.domain_id=domains.id and name=:domain and domainmetadata.kind=:kind"); - declare(suffix, "clear-domain-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name=:domain) and domainmetadata.kind=:kind"); - declare(suffix, "clear-domain-all-metadata-query","", "delete from domainmetadata where domain_id=(select id from domains where name=:domain)"); - declare(suffix, "set-domain-metadata-query","", "insert into domainmetadata (id, domain_id, kind, content) select domainmetadata_id_sequence.nextval, id, :kind, :content from domains where name=:domain"); - declare(suffix, "activate-domain-key-query","", "update cryptokeys set active=1 where domain_id=(select id from domains where name=:domain) and cryptokeys.id=:key_id"); - declare(suffix, "deactivate-domain-key-query","", "update cryptokeys set active=0 where domain_id=(select id from domains where name=:domain) and cryptokeys.id=:key_id"); - declare(suffix, "remove-domain-key-query","", "delete from cryptokeys where domain_id=(select id from domains where name=:domain) and cryptokeys.id=:key_id"); - declare(suffix, "clear-domain-all-keys-query","", "delete from cryptokeys where domain_id=(select id from domains where name=:domain)"); - declare(suffix, "get-tsig-key-query","", "select algorithm, secret from tsigkeys where name=:key_name"); - declare(suffix, "set-tsig-key-query","", "merge into tsigkeys tk using dual on (name = :key_name and algorithm = :algorithm) when not matched then insert (id, name, algorithm, secret) values(tsigkeys_id_sequence.nextval, :key_name, :algorithm, :content) when matched then update set secret = :content"); - declare(suffix, "delete-tsig-key-query","", "delete from tsigkeys where name=:key_name"); - declare(suffix, "get-tsig-keys-query","", "select name,algorithm, secret from tsigkeys"); - - declare(suffix, "get-all-domains-query", "Retrieve all domains", "select domains.id, domains.name, records.content, domains.type, domains.master, domains.notified_serial, domains.last_check, domain.account from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name WHERE records.disabled=0 OR records.disabled=:include_disabled"); - - declare(suffix, "list-comments-query", "", "SELECT domain_id,name,type,modified_at,account,\"comment\" FROM comments WHERE domain_id=:domain_id"); - declare(suffix, "insert-comment-query", "", "INSERT INTO comments (id, domain_id, name, type, modified_at, account, \"comment\") VALUES (comments_id_sequence.nextval, :domain_id, :qname, :qtype, :modified_at, :account, :content)"); - declare(suffix, "delete-comment-rrset-query", "", "DELETE FROM comments WHERE domain_id=:domain_id AND name=:qname AND type=:qtype"); - declare(suffix, "delete-comments-query", "", "DELETE FROM comments WHERE domain_id=:domain_id"); - declare(suffix, "search-records-query", "", record_query+" name LIKE :value OR content LIKE :value2 LIMIT :limit"); - declare(suffix, "search-comments-query", "", "SELECT domain_id,name,type,modified_at,account,comment FROM comments WHERE name LIKE :value OR comment LIKE :value2 LIMIT :limit"); - - } - - DNSBackend* make(const string &suffix="") { - return new gOracleBackend(d_mode,suffix); - } - -private: - const string d_mode; -}; - - -//! Magic class that is activated when the dynamic library is loaded -class gOracleLoader -{ -public: - //! This reports us to the main UeberBackend class - gOracleLoader() { - BackendMakers().report(new gOracleFactory("goracle")); - g_log << Logger::Info << "[goraclebackend] This is the goracle backend version " VERSION -#ifndef REPRODUCIBLE - << " (" __DATE__ " " __TIME__ ")" -#endif - << " reporting" << endl; - } -}; - -//! Reports the backendloader to the UeberBackend. -static gOracleLoader goracleloader; diff --git a/modules/goraclebackend/goraclebackend.hh b/modules/goraclebackend/goraclebackend.hh deleted file mode 100644 index c41de3292..000000000 --- a/modules/goraclebackend/goraclebackend.hh +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef PDNS_GORACLEBACKEND_HH -#define PDNS_GORACLEBACKEND_HH - -#include -#include -#include "pdns/backends/gsql/gsqlbackend.hh" - -#include "pdns/namespaces.hh" - -/** The gOracleBackend is a DNSBackend that can answer DNS related questions. It looks up data - in PostgreSQL */ -class gOracleBackend : public GSQLBackend -{ -public: - gOracleBackend(const string &mode, const string &suffix); //!< Makes our connection to the database. Throws an exception if it fails. -}; - -#endif /* PDNS_GORACLEBACKEND_HH */ diff --git a/modules/goraclebackend/schema.goracle.sql b/modules/goraclebackend/schema.goracle.sql deleted file mode 100644 index c2f9016db..000000000 --- a/modules/goraclebackend/schema.goracle.sql +++ /dev/null @@ -1,93 +0,0 @@ -CREATE TABLE domains ( - id INTEGER NOT NULL, - name VARCHAR2(255) NOT NULL, - master VARCHAR2(128) DEFAULT NULL, - last_check INTEGER DEFAULT NULL, - type VARCHAR2(6) NOT NULL, - notified_serial NUMBER(10,0) DEFAULT NULL, - account VARCHAR2(40) DEFAULT NULL, - PRIMARY KEY (id) -); - -CREATE SEQUENCE domains_id_sequence; -CREATE INDEX domains$name ON domains (name); - - -CREATE TABLE records ( - id INTEGER NOT NULL, - domain_id INTEGER DEFAULT NULL REFERENCES domains (id) ON DELETE CASCADE, - name VARCHAR2(255) DEFAULT NULL, - type VARCHAR2(10) DEFAULT NULL, - content VARCHAR2(4000) DEFAULT NULL, - ttl INTEGER DEFAULT NULL, - prio INTEGER DEFAULT NULL, - disabled NUMBER(1,0) DEFAULT 0 NOT NULL, - ordername VARCHAR2(255) DEFAULT NULL, - auth NUMBER(1,0) DEFAULT 1 NOT NULL, - PRIMARY KEY (id) -) pctfree 40; - -CREATE SEQUENCE records_id_sequence; -CREATE INDEX records$nametype ON records (name, type); -CREATE INDEX records$domain_id ON records (domain_id); -CREATE INDEX records$recordorder ON records (domain_id, ordername); - - -CREATE TABLE supermasters ( - ip VARCHAR2(64) NOT NULL, - nameserver VARCHAR2(255) NOT NULL, - account VARCHAR2(40) NOT NULL, - PRIMARY KEY (ip, nameserver) -); - - -CREATE TABLE comments ( - id INTEGER NOT NULL, - domain_id INTEGER NOT NULL REFERENCES domains (id) ON DELETE CASCADE, - name VARCHAR2(255) NOT NULL, - type VARCHAR2(10) NOT NULL, - modified_at INTEGER NOT NULL, - account VARCHAR2(40) NOT NULL, - "comment" VARCHAR2(4000) NOT NULL -); -CREATE SEQUENCE comments_id_sequence; -CREATE INDEX comments$nametype ON comments (name, type); -CREATE INDEX comments$domain_id ON comments (domain_id); -CREATE INDEX comments$order ON comments (domain_id, modified_at); - - -CREATE TABLE domainmetadata ( - id INTEGER NOT NULL, - domain_id INTEGER NOT NULL, - kind VARCHAR2(32), - content VARCHAR2(4000), - PRIMARY KEY (id) -); - -CREATE SEQUENCE domainmetadata_id_sequence; -CREATE INDEX domainmetadata$domain_id ON domainmetadata (domain_id); - - -CREATE TABLE cryptokeys ( - id INTEGER NOT NULL, - domain_id INTEGER NOT NULL, - flags INTEGER NOT NULL, - active INTEGER NOT NULL, - content VARCHAR2(4000), - PRIMARY KEY (id) -); - -CREATE SEQUENCE cryptokeys_id_sequence; -CREATE INDEX cryptokeys$domain_id ON cryptokeys (domain_id); - - -CREATE TABLE tsigkeys ( - id INTEGER NOT NULL, - name VARCHAR2(255), - algorithm VARCHAR2(50), - secret VARCHAR2(255), - PRIMARY KEY (id) -); - -CREATE SEQUENCE tsigkeys_id_sequence; -CREATE UNIQUE INDEX tsigkeys$namealgo ON tsigkeys (name, algorithm); diff --git a/modules/goraclebackend/soracle.cc b/modules/goraclebackend/soracle.cc deleted file mode 100644 index 5442b174c..000000000 --- a/modules/goraclebackend/soracle.cc +++ /dev/null @@ -1,554 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "soracle.hh" -#include -#include -#include "pdns/misc.hh" -#include "pdns/logger.hh" -#include "pdns/dns.hh" -#include "pdns/namespaces.hh" -#include "pdns/digests.hh" - -static AtomicCounter s_txid; - -bool SOracle::s_dolog; - -class SOracleStatement: public SSqlStatement { -public: - SOracleStatement(const string& query, bool dolog, int nparams, OCIEnv *ctx, OCISvcCtx *svc_ctx, bool release_stmt) { - d_query = query; - d_ctx = ctx; - d_svcctx = svc_ctx; - d_dolog = dolog; - d_res = NULL; - d_bind = NULL; - d_stmt = NULL; - d_err = NULL; - d_queryResult = OCI_NO_DATA; - d_paridx = d_parnum = d_resnum = d_residx = 0; - d_release_stmt = release_stmt; - d_non_null_ind = 0; - d_null_ind = -1; - d_init = false; - d_prepared = false; - d_parnum = nparams; - // create a key - string key = pdns_md5sum(d_query); - d_stmt_keysize = std::min(key.size()*2, sizeof(d_stmt_key)); - for(string::size_type i = 0; i < key.size() && i*2 < d_stmt_keysize; i++) - snprintf((char*)&(d_stmt_key[i*2]), 3, "%02x", (unsigned char)key[i]); - d_stmt_key[d_stmt_keysize] = 0; - } - - SSqlStatement* bind(const string& name, bool value) - { - return bind(name, (int)value); - } - SSqlStatement* bind(const string& name, int value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val4 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), &(d_bind[d_paridx].val4), sizeof(sb4), SQLT_INT, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, uint32_t value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val4 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (ub4*)&(d_bind[d_paridx].val4), sizeof(ub4), SQLT_UIN, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, long value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val4 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (ub4*)&(d_bind[d_paridx].val4), sizeof(sb4), SQLT_INT, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, unsigned long value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val4 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (ub4*)&(d_bind[d_paridx].val4), sizeof(ub4), SQLT_UIN, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, long long value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val8 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (orasb8*)&(d_bind[d_paridx].val8), sizeof(orasb8), SQLT_INT, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, unsigned long long value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].val8 = value; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (oraub8*)&(d_bind[d_paridx].val8), sizeof(oraub8), SQLT_UIN, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bind(const string& name, const std::string& value) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - d_bind[d_paridx].vals = new text[value.size()+1]; - memset(d_bind[d_paridx].vals, 0, value.size()+1); - value.copy((char*)d_bind[d_paridx].vals, value.size()); - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), (text*)d_bind[d_paridx].vals, value.size()+1, SQLT_STR, &d_non_null_ind,0,0,0,0,OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_paridx++; - return this; - } - SSqlStatement* bindNull(const string& name) - { - if (d_paridx >= d_parnum) - throw SSqlException("Attempt to bind more parameters than query has: " + d_query); - prepareStatement(); - string zName = string(":") + name; - if (OCIBindByName(d_stmt, &(d_bind[d_paridx].handle), d_err, (text*)zName.c_str(), zName.size(), NULL, 0, SQLT_STR, &d_null_ind, 0, 0, 0, 0, OCI_DEFAULT) != OCI_SUCCESS) { - throw SSqlException(string("Cannot bind parameter ") + name + string(": ") + OCIErrStr()); - } - d_bind[d_paridx].release = true; // remember to free this - d_paridx++; - return this; - } - SSqlStatement* execute() - { - if (d_query.size() == 0) return this; // do not execute empty queries - prepareStatement(); - - if (d_dolog) - g_log< 0) { - ub2 o_attrtype; - OCIParam *parms = NULL; - d_res = new struct oresult[d_fnum]; - memset(d_res, 0, sizeof(struct oresult)*d_fnum); - - for(int i=0; i < d_fnum; i++) { - if (OCIParamGet(d_stmt, OCI_HTYPE_STMT, d_err, (dvoid**)&parms, (ub4)i+1) != OCI_SUCCESS) { - throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr()); - } - - if (OCIAttrGet(parms, OCI_DTYPE_PARAM, (dvoid*)&(d_res[i].colsize), 0, OCI_ATTR_DATA_SIZE, d_err) != OCI_SUCCESS) { - throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr()); - } - - if (d_res[i].colsize == 0) { - if (OCIAttrGet(parms, OCI_DTYPE_PARAM, (dvoid*)&o_attrtype, 0, OCI_ATTR_DATA_TYPE, d_err) != OCI_SUCCESS) { - throw SSqlException("Cannot get statement result column information: " + d_query + string(": ") + OCIErrStr()); - } - - // oracle 11g returns 0 for integer fields - we know oracle should return 22. - if (o_attrtype == OCI_TYPECODE_INTEGER || - o_attrtype == OCI_TYPECODE_SMALLINT || - o_attrtype == OCI_TYPECODE_REAL || - o_attrtype == OCI_TYPECODE_DOUBLE || - o_attrtype == OCI_TYPECODE_FLOAT || - o_attrtype == OCI_TYPECODE_NUMBER || - o_attrtype == OCI_TYPECODE_DECIMAL) d_res[i].colsize = 22; - } - d_res[i].content = new char[d_res[i].colsize+1]; - } - } - - if (d_fnum > 0) { - for(int i=0;i=0) { - row.push_back(d_res[i].content); - } else { - row.push_back(""); - } - } - - d_queryResult = OCIStmtFetch2(d_stmt, d_err, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - d_residx++; - return this; - } - - SSqlStatement* getResult(result_t& result) { - row_t row; - - result.reserve(d_resnum); - while(hasNextRow()) { - nextRow(row); - result.push_back(row); - } - - return this; - } - - SSqlStatement* reset() { - d_paridx = 0; - d_residx = d_resnum = 0; - - if (d_bind) { - for(int i=0;i SOracle::prepare(const string& query, int nparams) { - return std::unique_ptr(new SOracleStatement(query, s_dolog, nparams, d_environmentHandle, d_serviceContextHandle, d_release_stmt)); -} - -void SOracle::execute(const string& query) { - SOracleStatement(query, s_dolog, 0, d_environmentHandle, d_serviceContextHandle, true).execute(); -} - -string SOracle::getOracleError() -{ - string mReason = "ORA-UNKNOWN"; - if (d_errorHandle != NULL) { - text msg[512]; - sb4 errcode = 0; - memset(msg, 0, 512); - OCIErrorGet((dvoid*) d_errorHandle,1, NULL, &errcode, msg, sizeof(msg), OCI_HTYPE_ERROR); - if (errcode) { - char* p = (char*) msg; - while (*p++ != 0x00) { - if (*p == '\n' || *p == '\r') { - *p = ';'; - } - } - mReason = (char*) msg; - } - } - return mReason; -} diff --git a/modules/goraclebackend/soracle.hh b/modules/goraclebackend/soracle.hh deleted file mode 100644 index 2abae2b1c..000000000 --- a/modules/goraclebackend/soracle.hh +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef SORACLE_HH -#define SORACLE_HH - -#include "pdns/backends/gsql/ssql.hh" -#include "pdns/utility.hh" -#include -#include -#include "pdns/misc.hh" - -#ifndef dsword -typedef sb4 dsword; -#endif - -class SOracle : public SSql -{ -public: - SOracle(const string &database, - const string &user="", - const string &password="", - bool releaseStatements=false, - OCIEnv* oraenv=NULL); - - ~SOracle(); - - SSqlException sPerrorException(const string &reason); - void setLog(bool state); - std::unique_ptr prepare(const string& query, int nparams); - void execute(const string& query); - - void startTransaction(); - void commit(); - void rollback(); -private: - OCIEnv* d_environmentHandle; - OCIError* d_errorHandle; - OCISvcCtx* d_serviceContextHandle; - - string getOracleError(); - static bool s_dolog; - bool d_release_stmt; -}; - -#endif /* SSORACLE_HH */ diff --git a/modules/oraclebackend/ChangeLog b/modules/oraclebackend/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/oraclebackend/INSTALL b/modules/oraclebackend/INSTALL deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/oraclebackend/Makefile.am b/modules/oraclebackend/Makefile.am deleted file mode 100644 index 84c476ddb..000000000 --- a/modules/oraclebackend/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -AM_CPPFLAGS += $(ORACLE_CFLAGS) - -pkglib_LTLIBRARIES = liboraclebackend.la - -EXTRA_DIST = \ - OBJECTFILES \ - OBJECTLIBS \ - drop-schema.oracle.sql \ - schema.oracle.sql - -dist_doc_DATA = \ - schema.oracle.sql \ - drop-schema.oracle.sql - -liboraclebackend_la_SOURCES = oraclebackend.cc oraclebackend.hh -liboraclebackend_la_LDFLAGS = -module -avoid-version -liboraclebackend_la_LIBADD = $(ORACLE_LIBS) -lclntsh diff --git a/modules/oraclebackend/OBJECTFILES b/modules/oraclebackend/OBJECTFILES deleted file mode 100644 index 570c62efd..000000000 --- a/modules/oraclebackend/OBJECTFILES +++ /dev/null @@ -1 +0,0 @@ -oraclebackend.lo diff --git a/modules/oraclebackend/OBJECTLIBS b/modules/oraclebackend/OBJECTLIBS deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/oraclebackend/README b/modules/oraclebackend/README deleted file mode 100644 index 5ae864b3f..000000000 --- a/modules/oraclebackend/README +++ /dev/null @@ -1,43 +0,0 @@ -An Oracle Database backend was originally contributed to PowerDNS in -2002 by Stefan Arentz. - -A new version amounting to a complete rewrite was contributed in 2011 by -Maik Zumstrull , then at the Steinbuch Centre for -Computing at the Karlsruhe Institute of -Technology . - ---- - -Licensing - -Any contributions submitted to PowerDNS.COM BV by Maik Zumstrull / SCC are -released under the conditions of the MIT license. Note that additional or -different licensing terms may apply to code as redistributed by -PowerDNS.COM BV. The terms of the license are found below. - ---- - -The MIT License - -Copyright (c) 2010-2011 - Maik Zumstrull - Steinbuch Centre for Computing - Karlsruhe Institute of Technology - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/modules/oraclebackend/TODO b/modules/oraclebackend/TODO deleted file mode 100644 index db61fa592..000000000 --- a/modules/oraclebackend/TODO +++ /dev/null @@ -1,6 +0,0 @@ - -Oracle Backend - -todo Clean up our stuff in the destructor - write configure.in stuff - diff --git a/modules/oraclebackend/drop-schema.oracle.sql b/modules/oraclebackend/drop-schema.oracle.sql deleted file mode 100644 index 1e4997f41..000000000 --- a/modules/oraclebackend/drop-schema.oracle.sql +++ /dev/null @@ -1,23 +0,0 @@ -DROP PROCEDURE get_hashed_prev_next; -DROP PROCEDURE get_canonical_prev_next; - -DROP FUNCTION dnsname_to_hashname; -DROP FUNCTION base32hex_encode; -DROP FUNCTION dnsname_to_raw; -DROP FUNCTION label_reverse; - -DROP TABLE Records; -DROP SEQUENCE records_id_seq; -DROP TABLE AccessControlList; -DROP TABLE TSIGKeys; -DROP TABLE ZoneDNSKeys; -DROP SEQUENCE zonednskeys_id_seq; -DROP TABLE ZoneMetadata; -DROP TABLE Supermasters; -DROP SEQUENCE supermasters_id_seq; -DROP TABLE Zonemasters; -DROP TABLE ZoneAlsoNotify; -DROP TABLE Zones; -DROP SEQUENCE zones_id_seq; - --- vi: set sw=2 et : -- diff --git a/modules/oraclebackend/oraclebackend.cc b/modules/oraclebackend/oraclebackend.cc deleted file mode 100644 index b0abaa41e..000000000 --- a/modules/oraclebackend/oraclebackend.cc +++ /dev/null @@ -1,2259 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * originally authored by Maik Zumstrull - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include - -#include "pdns/namespaces.hh" - -#include "pdns/dns.hh" -#include "pdns/dnsbackend.hh" -#include "oraclebackend.hh" -#include "pdns/logger.hh" -#include "pdns/arguments.hh" -#include "pdns/lock.hh" - -#include - -static const char *basicQueryKey = "PDNS_Basic_Query"; -static const char *basicQueryDefaultAuthSQL = - "SELECT fqdn, ttl, type, content, zone_id, auth " - "FROM Records " - "WHERE type = :type AND fqdn = lower(:name)"; - -static const char *basicQueryDefaultSQL = "SELECT fqdn, ttl, type, content, zone_id, " - "FROM Records " - "WHERE type = :type AND fqdn = lower(:name)"; - -static const char *basicIdQueryKey = "PDNS_Basic_Id_Query"; -static const char *basicIdQueryDefaultAuthSQL = - "SELECT fqdn, ttl, type, content, zone_id, auth " - "FROM Records " - "WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid"; - -static const char *basicIdQueryDefaultSQL = - "SELECT fqdn, ttl, type, content, zone_id, " - "FROM Records " - "WHERE type = :type AND fqdn = lower(:name) AND zone_id = :zoneid"; - -static const char *anyQueryKey = "PDNS_ANY_Query"; -static const char *anyQueryDefaultAuthSQL = - "SELECT fqdn, ttl, type, content, zone_id, auth " - "FROM Records " - "WHERE fqdn = lower(:name)" - " AND type IS NOT NULL " - "ORDER BY type"; - -static const char *anyQueryDefaultSQL = - "SELECT fqdn, ttl, type, content, zone_id, " - "FROM Records " - "WHERE fqdn = lower(:name)" - " AND type IS NOT NULL " - "ORDER BY type"; - -static const char *anyIdQueryKey = "PDNS_ANY_Id_Query"; -static const char *anyIdQueryDefaultAuthSQL = - "SELECT fqdn, ttl, type, content, zone_id, auth " - "FROM Records " - "WHERE fqdn = lower(:name)" - " AND zone_id = :zoneid" - " AND type IS NOT NULL " - "ORDER BY type"; - -static const char *anyIdQueryDefaultSQL = - "SELECT fqdn, ttl, type, content, zone_id, " - "FROM Records " - "WHERE fqdn = lower(:name)" - " AND zone_id = :zoneid" - " AND type IS NOT NULL " - "ORDER BY type"; - - -static const char *listQueryKey = "PDNS_List_Query"; -static const char *listQueryDefaultAuthSQL = - "SELECT fqdn, ttl, type, content, zone_id, auth " - "FROM Records " - "WHERE zone_id = :zoneid" - " AND type IS NOT NULL " - "ORDER BY fqdn, type"; - -static const char *listQueryDefaultSQL = - "SELECT fqdn, ttl, type, content, zone_id, " - "FROM Records " - "WHERE zone_id = :zoneid" - " AND type IS NOT NULL " - "ORDER BY fqdn, type"; - - -static const char *zoneInfoQueryKey = "PDNS_Zone_Info_Query"; -static const char *zoneInfoQueryDefaultSQL = - "SELECT id, name, type, last_check, serial, notified_serial " - "FROM Zones " - "WHERE name = lower(:name)"; - -static const char *alsoNotifyQueryKey = "PDNS_Also_Notify_Query"; -static const char *alsoNotifyQueryDefaultSQL = - "SELECT an.hostaddr " - "FROM Zones z JOIN ZoneAlsoNotify an ON z.id = an.zone_id " - "WHERE z.name = lower(:name)"; - -static const char *zoneMastersQueryKey = "PDNS_Zone_Masters_Query"; -static const char *zoneMastersQueryDefaultSQL = - "SELECT master " - "FROM Zonemasters " - "WHERE zone_id = :zoneid"; - -static const char *deleteZoneQueryKey = "PDNS_Delete_Zone_Query"; -static const char *deleteZoneQueryDefaultSQL = - "DELETE FROM Records WHERE zone_id = :zoneid"; - -static const char *zoneSetLastCheckQueryKey = "PDNS_Zone_Set_Last_Check_Query"; -static const char *zoneSetLastCheckQueryDefaultSQL = - "UPDATE Zones SET last_check = :lastcheck WHERE id = :zoneid"; - -static const char *zoneSetNotifiedSerialQueryKey = "PDNS_Zone_Set_NSerial_Query"; -static const char *zoneSetNotifiedSerialQueryDefaultSQL = - "UPDATE Zones SET notified_serial = :serial WHERE id = :zoneid"; - -static const char *insertRecordQueryKey = "PDNS_Insert_Record_Query"; -static const char *insertRecordQueryDefaultSQL = - "INSERT INTO Records (id, fqdn, zone_id, ttl, type, content) " - "VALUES (records_id_seq.NEXTVAL, lower(:name), :zoneid, :ttl, :type, :content)"; - -static const char *finalizeAXFRQueryKey = "PDNS_Finalize_AXFR"; -static const char *finalizeAXFRQueryDefaultSQL = - "DECLARE\n" - " zone_id INTEGER := :zoneid;\n" - "BEGIN\n" - " NULL;\n" - "END;"; - -static const char *unfreshZonesQueryKey = "PDNS_Unfresh_Zones_Query"; -static const char *unfreshZonesQueryDefaultSQL = - "SELECT z.id, z.name, z.last_check, z.serial, zm.master " - "FROM Zones z JOIN Zonemasters zm ON z.id = zm.zone_id " - "WHERE z.type = 'SLAVE' " - " AND (z.last_check IS NULL OR z.last_check + z.refresh < :ts)" - "ORDER BY z.id"; - -static const char *updatedMastersQueryKey = "PDNS_Updated_Masters_Query"; -static const char *updatedMastersQueryDefaultSQL = - "SELECT id, name, serial, notified_serial " - "FROM Zones " - "WHERE type = 'MASTER' " - "AND (notified_serial IS NULL OR notified_serial < serial)"; - -static const char *acceptSupernotificationQueryKey = "PDNS_Accept_Supernotification_Query"; -static const char *acceptSupernotificationQueryDefaultSQL = - "SELECT name " - "FROM Supermasters " - "WHERE ip = :ip AND nameserver = lower(:ns)"; - -static const char *insertSlaveQueryKey = "PDNS_Insert_Slave_Query"; -static const char *insertSlaveQueryDefaultSQL = - "INSERT INTO Zones (id, name, type) " - "VALUES (zones_id_seq.NEXTVAL, lower(:zone), 'SLAVE') " - "RETURNING id INTO :zoneid"; - -static const char *insertMasterQueryKey = "PDNS_Insert_Master_Query"; -static const char *insertMasterQueryDefaultSQL = - "INSERT INTO Zonemasters (zone_id, master) " - "VALUES (:zoneid, :ip)"; - -static const char *prevNextNameQueryKey = "PDNS_Prev_Next_Name_Query"; -static const char *prevNextNameQueryDefaultSQL = - "BEGIN\n" - " get_canonical_prev_next(:zoneid, :name, :prev, :next);\n" - "END;"; - -static const char *prevNextHashQueryKey = "PDNS_Prev_Next_Hash_Query"; -static const char *prevNextHashQueryDefaultSQL = - "BEGIN\n" - " get_hashed_prev_next(:zoneid, :hash, :unhashed, :prev, :next);\n" - "END;"; - -static const char *getAllZoneMetadataQueryKey = "PDNS_Get_All_Zone_Metadata"; -static const char *getAllZoneMetadataQueryDefaultSQL = - "SELECT md.meta_type, md.meta_content " - "FROM Zones z JOIN ZoneMetadata md ON z.id = md.zone_id " - "WHERE z.name = lower(:name) " - "ORDER BY md.meta_ind"; - -static const char *getZoneMetadataQueryKey = "PDNS_Get_Zone_Metadata"; -static const char *getZoneMetadataQueryDefaultSQL = - "SELECT md.meta_content " - "FROM Zones z JOIN ZoneMetadata md ON z.id = md.zone_id " - "WHERE z.name = lower(:name) AND md.meta_type = :kind " - "ORDER BY md.meta_ind"; - -static const char *delZoneMetadataQueryKey = "PDNS_Del_Zone_Metadata"; -static const char *delZoneMetadataQueryDefaultSQL = - "DELETE FROM ZoneMetadata md " - "WHERE zone_id = (SELECT id FROM Zones z WHERE z.name = lower(:name)) " - " AND md.meta_type = :kind"; - -static const char *setZoneMetadataQueryKey = "PDNS_Set_Zone_Metadata"; -static const char *setZoneMetadataQueryDefaultSQL = - "INSERT INTO ZoneMetadata (zone_id, meta_type, meta_ind, meta_content) " - "VALUES (" - " (SELECT id FROM Zones WHERE name = lower(:name))," - " :kind, :i, :content" - ")"; - -static const char *getTSIGKeyQueryKey = "PDNS_Get_TSIG_Key"; -static const char *getTSIGKeyQueryDefaultSQL = - "SELECT algorithm, secret " - "FROM TSIGKeys " - "WHERE name = :name"; - -static const char *delTSIGKeyQueryKey = "PDNS_Del_TSIG_Key"; -static const char *delTSIGKeyQueryDefaultSQL = - "DELETE FROM TSIGKeys " - "WHERE name = :name"; - -static const char *setTSIGKeyQueryKey = "PDNS_Set_TSIG_Key"; -static const char *setTSIGKeyQueryDefaultSQL = - "INSERT INTO TSIGKeys (name, algorithm, secret) " - "VALUES (:name, :algorithm, :secret)"; - -static const char *getTSIGKeysQueryKey = "PDNS_Get_TSIG_Keys"; -static const char *getTSIGKeysQueryDefaultSQL = - "SELECT name, algorithm, secret " - "FROM TSIGKeys"; - -static const char *getZoneKeysQueryKey = "PDNS_Get_Zone_Keys"; -static const char *getZoneKeysQueryDefaultSQL = - "SELECT k.id, k.flags, k.active, k.keydata " - "FROM ZoneDNSKeys k JOIN Zones z ON z.id = k.zone_id " - "WHERE z.name = lower(:name)"; - -static const char *delZoneKeyQueryKey = "PDNS_Del_Zone_Key"; -static const char *delZoneKeyQueryDefaultSQL = - "DELETE FROM ZoneDNSKeys WHERE id = :keyid"; - -static const char *addZoneKeyQueryKey = "PDNS_Add_Zone_Key"; -static const char *addZoneKeyQueryDefaultSQL = - "INSERT INTO ZoneDNSKeys (id, zone_id, flags, active, keydata) " - "VALUES (" - " zonednskeys_id_seq.NEXTVAL," - " (SELECT id FROM Zones WHERE name = lower(:name))," - " :flags," - " :active," - " :content" - ") RETURNING id INTO :keyid"; - -static const char *setZoneKeyStateQueryKey = "PDNS_Set_Zone_Key_State"; -static const char *setZoneKeyStateQueryDefaultSQL = - "UPDATE ZoneDNSKeys SET active = :active WHERE id = :keyid"; - - -static void -string_to_cbuf (char *buf, const string& s, size_t bufsize) -{ - if (s.size() >= bufsize) { - throw std::overflow_error("OracleBackend: string does not fit into char buffer"); - } - strncpy(buf, s.c_str(), bufsize); -} - -static void -DNSName_to_cbuf (char *buf, const DNSName& n, size_t bufsize) -{ - string s = toLower(n.toStringNoDot()); - if (s.size() >= bufsize) { - throw std::overflow_error("OracleBackend: DNSName does not fit into char buffer"); - } - strncpy(buf, s.c_str(), bufsize); -} - -OracleBackend::OracleBackend (const string &suffix, OCIEnv *envh, - char *poolname) -{ - setArgPrefix(string("oracle") + suffix); - sword err; - - // Initialize everything in a known state - oraenv = envh; - oraerr = NULL; - pooledSvcCtx = NULL; - masterAuthHandle = NULL; - masterSvcCtx = NULL; - curStmtHandle = NULL; - openTransactionZoneID = -1; - - try - { - d_dnssecQueries = mustDo("dnssec"); - } - catch (ArgException e) - { - d_dnssecQueries = false; - } - - // Process configuration options - string_to_cbuf(myServerName, getArg("nameserver-name"), sizeof(myServerName)); - - if (d_dnssecQueries) { - basicQuerySQL = getArg("basic-query-auth"); - basicIdQuerySQL = getArg("basic-id-query-auth"); - anyQuerySQL = getArg("any-query-auth"); - anyIdQuerySQL = getArg("any-id-query-auth"); - listQuerySQL = getArg("list-query-auth"); - } else { - basicQuerySQL = getArg("basic-query"); - basicIdQuerySQL = getArg("basic-id-query"); - anyQuerySQL = getArg("any-query"); - anyIdQuerySQL = getArg("any-id-query"); - listQuerySQL = getArg("list-query"); - } - - zoneInfoQuerySQL = getArg("zone-info-query"); - alsoNotifyQuerySQL = getArg("also-notify-query"); - zoneMastersQuerySQL = getArg("zone-masters-query"); - deleteZoneQuerySQL = getArg("delete-zone-query"); - zoneSetLastCheckQuerySQL = getArg("zone-set-last-check-query"); - insertRecordQuerySQL = getArg("insert-record-query"); - finalizeAXFRQuerySQL = getArg("finalize-axfr-query"); - unfreshZonesQuerySQL = getArg("unfresh-zones-query"); - updatedMastersQuerySQL = getArg("updated-masters-query"); - acceptSupernotificationQuerySQL = getArg("accept-supernotification-query"); - insertSlaveQuerySQL = getArg("insert-slave-query"); - insertMasterQuerySQL = getArg("insert-master-query"); - zoneSetNotifiedSerialQuerySQL = getArg("zone-set-notified-serial-query"); - prevNextNameQuerySQL = getArg("prev-next-name-query"); - prevNextHashQuerySQL = getArg("prev-next-hash-query"); - getAllZoneMetadataQuerySQL = getArg("get-all-zone-metadata-query"); - getZoneMetadataQuerySQL = getArg("get-zone-metadata-query"); - delZoneMetadataQuerySQL = getArg("del-zone-metadata-query"); - setZoneMetadataQuerySQL = getArg("set-zone-metadata-query"); - getTSIGKeyQuerySQL = getArg("get-tsig-key-query"); - delTSIGKeyQuerySQL = getArg("del-tsig-key-query"); - setTSIGKeyQuerySQL = getArg("set-tsig-key-query"); - getTSIGKeysQuerySQL = getArg("get-tsig-keys-query"); - getZoneKeysQuerySQL = getArg("get-zone-keys-query"); - delZoneKeyQuerySQL = getArg("del-zone-key-query"); - addZoneKeyQuerySQL = getArg("add-zone-key-query"); - setZoneKeyStateQuerySQL = getArg("set-zone-key-state-query"); - - // Allocate an error handle - err = OCIHandleAlloc(oraenv, (void**) &oraerr, - OCI_HTYPE_ERROR, 0, NULL); - if (err == OCI_ERROR) { - throw OracleException("OCIHandleAlloc"); - } - - // Logon to the database - err = OCISessionGet(oraenv, oraerr, &pooledSvcCtx, NULL, (OraText*) poolname, strlen(poolname), NULL, 0, NULL, NULL, NULL, OCI_SESSGET_SPOOL); - - if (err == OCI_ERROR) { - throw OracleException("Opening Oracle session", oraerr); - } -} - -void -OracleBackend::openMasterConnection () -{ - sword err; - - if (masterSvcCtx == NULL) { - err = OCIHandleAlloc(oraenv, (void**) &masterAuthHandle, OCI_HTYPE_AUTHINFO, 0, NULL); - if (err == OCI_ERROR) { - throw OracleException("openMasterConnection: allocating auth handle"); - } - - string database = getArg("master-database"); - string username = getArg("master-username"); - string password = getArg("master-password"); - - err = OCIAttrSet(masterAuthHandle, OCI_HTYPE_AUTHINFO, (void*)username.c_str(), username.size(), OCI_ATTR_USERNAME, oraerr); - if (err == OCI_ERROR) { - throw OracleException("openMasterConnection: setting username"); - } - - err = OCIAttrSet(masterAuthHandle, OCI_HTYPE_AUTHINFO, (void*)password.c_str(), password.size(), OCI_ATTR_PASSWORD, oraerr); - if (err == OCI_ERROR) { - throw OracleException("openMasterConnection: setting password"); - } - - err = OCISessionGet(oraenv, oraerr, &masterSvcCtx, masterAuthHandle, - (OraText*)database.c_str(), database.size(), - NULL, 0, NULL, NULL, NULL, OCI_SESSGET_STMTCACHE); - if (err == OCI_ERROR) { - throw OracleException("openMasterConnection OCISessionGet"); - } - } -} - -OracleBackend::~OracleBackend () -{ - Cleanup(); -} - -void -OracleBackend::lookup (const QType &qtype, const DNSName& qname, - DNSPacket *p, int zoneId) -{ - sword rc; - - if (qtype.getCode() != QType::ANY) { - if (zoneId < 0) { - if (curStmtHandle != NULL) throw OracleException("Invalid state"); - curStmtHandle = prepare_query(pooledSvcCtx, basicQuerySQL, basicQueryKey); - curStmtKey = basicQueryKey; - define_fwd_query(curStmtHandle); - bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); - bind_str(curStmtHandle, ":type", mQueryType, sizeof(mQueryType)); - } else { - if (curStmtHandle != NULL) throw OracleException("Invalid state"); - curStmtHandle = prepare_query(pooledSvcCtx, basicIdQuerySQL, basicIdQueryKey); - curStmtKey = basicIdQueryKey; - define_fwd_query(curStmtHandle); - bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); - bind_str(curStmtHandle, ":type", mQueryType, sizeof(mQueryType)); - bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); - } - } else { - if (zoneId < 0) { - if (curStmtHandle != NULL) throw OracleException("Invalid state"); - curStmtHandle = prepare_query(pooledSvcCtx, anyQuerySQL, anyQueryKey); - curStmtKey = anyQueryKey; - define_fwd_query(curStmtHandle); - bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); - } else { - if (curStmtHandle != NULL) throw OracleException("Invalid state"); - curStmtHandle = prepare_query(pooledSvcCtx, anyIdQuerySQL, anyIdQueryKey); - curStmtKey = anyIdQueryKey; - define_fwd_query(curStmtHandle); - bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_str(curStmtHandle, ":name", mQueryName, sizeof(mQueryName)); - bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); - } - } - - DNSName_to_cbuf(mQueryName, qname, sizeof(mQueryName)); - string_to_cbuf(mQueryType, qtype.getName(), sizeof(mQueryType)); - mQueryZoneId = zoneId; - - rc = OCIStmtExecute(pooledSvcCtx, curStmtHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle Lookup", oraerr); - } - - if (rc == OCI_NO_DATA) { - release_query(curStmtHandle, curStmtKey); - curStmtHandle = NULL; - } -} - -bool -OracleBackend::getBeforeAndAfterNames ( - uint32_t zoneId, const DNSName& zone, - const DNSName& name, DNSName& before, DNSName& after) -{ - if(!d_dnssecQueries) - return -1; - - sword rc; - OCIStmt *stmt; - - (void)zone; - - stmt = prepare_query(pooledSvcCtx, prevNextNameQuerySQL, prevNextNameQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str_ind(stmt, ":prev", mResultPrevName, sizeof(mResultPrevName), &mResultPrevNameInd); - bind_str_ind(stmt, ":next", mResultNextName, sizeof(mResultNextName), &mResultNextNameInd); - bind_uint32(stmt, ":zoneid", &zoneId); - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - mResultPrevNameInd = -1; - mResultNextNameInd = -1; - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "Oracle getBeforeAndAfterNames", oraerr - ); - } - - check_indicator(mResultPrevNameInd, false); - check_indicator(mResultNextNameInd, false); - - before = DNSName(mResultPrevName); - after = DNSName(mResultNextName); - - release_query(stmt, prevNextNameQueryKey); - return true; -} - -bool -OracleBackend::getBeforeAndAfterNamesAbsolute(uint32_t zoneId, - const DNSName& name, DNSName& unhashed, DNSName& before, DNSName& after) -{ - if(!d_dnssecQueries) - return -1; - - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, prevNextHashQuerySQL, prevNextHashQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":hash", mQueryName, sizeof(mQueryName)); - bind_str_ind(stmt, ":unhashed", mResultName, sizeof(mResultName), &mResultNameInd); - bind_str_ind(stmt, ":prev", mResultPrevName, sizeof(mResultPrevName), &mResultPrevNameInd); - bind_str_ind(stmt, ":next", mResultNextName, sizeof(mResultNextName), &mResultNextNameInd); - bind_uint32(stmt, ":zoneid", &zoneId); - string_to_cbuf(mQueryName, name.labelReverse().toString(" ", false)), sizeof(mQueryName)); - mResultNameInd = -1; - mResultPrevNameInd = -1; - mResultNextNameInd = -1; - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "Oracle getBeforeAndAfterNamesAbsolute", oraerr - ); - } - - check_indicator(mResultNameInd, false); - check_indicator(mResultPrevNameInd, false); - check_indicator(mResultNextNameInd, false); - - unhashed = DNSName(mResultName); - before = DNSName(boost::replace_all_copy(mResultPrevName," ",".")).labelReverse(); - after = DNSName(boost::replace_all_copy(mResultNextName," ",".")).labelReverse(); - - release_query(stmt, prevNextHashQueryKey); - return true; -} - -vector -OracleBackend::getDomainMasters (const DNSName& domain, int zoneId) -{ - sword rc; - OCIStmt *stmt; - - (void)domain; - - vector masters; - char master[512]; - sb2 master_ind; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, zoneMastersQuerySQL, zoneMastersQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":zoneid", &mQueryZoneId); - - mQueryZoneId = zoneId; - define_output_str(stmt, 1, &master_ind, master, sizeof(master)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle getDomainMasters", oraerr); - } - - while (rc != OCI_NO_DATA) { - check_indicator(master_ind, false); - - masters.push_back(master); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "OracleBackend, fetching next zone master", oraerr - ); - } - } - - release_query(stmt, zoneMastersQueryKey); - - return masters; -} - -bool -OracleBackend::getDomainInfo (const DNSName& domain, DomainInfo &di) -{ - sword rc; - OCIStmt *stmt; - - int zone_id; - sb2 zone_id_ind; - int last_check; - sb2 last_check_ind; - uint32_t serial; - sb2 serial_ind; - uint32_t notified_serial; - sb2 notified_serial_ind; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, zoneInfoQuerySQL, zoneInfoQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - define_output_int(stmt, 1, &zone_id_ind, &zone_id); - define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); - define_output_str(stmt, 3, &mResultTypeInd, mResultType, sizeof(mResultType)); - define_output_int(stmt, 4, &last_check_ind, &last_check); - define_output_uint32(stmt, 5, &serial_ind, &serial); - define_output_uint32(stmt, 6, ¬ified_serial_ind, ¬ified_serial); - - DNSName_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); - bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle getDomainInfo", oraerr); - } - - if (rc == OCI_NO_DATA) { - release_query(stmt, zoneInfoQueryKey); - return false; - } - - check_indicator(zone_id_ind, false); - check_indicator(mResultNameInd, false); - check_indicator(serial_ind, true); - - if (zone_id < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); - - di.id = zone_id; - di.zone = DNSName(mResultName); - di.serial = serial; - di.backend = this; - - check_indicator(mResultTypeInd, false); - if (strcasecmp(mResultType, "NATIVE") == 0) { - di.kind = DomainInfo::Native; - } else if (strcasecmp(mResultType, "MASTER") == 0) { - di.kind = DomainInfo::Master; - check_indicator(notified_serial_ind, false); - di.notified_serial = notified_serial; - } else if (strcasecmp(mResultType, "SLAVE") == 0) { - di.kind = DomainInfo::Slave; - check_indicator(last_check_ind, true); - di.last_check = last_check; - di.masters = getDomainMasters(DNSName(mResultName), zone_id); - } else { - throw OracleException("Unknown zone type in Oracle backend"); - } - - di.kind = DomainInfo::Native; - - release_query(stmt, zoneInfoQueryKey); - return true; -} - -void OracleBackend::alsoNotifies(const DNSName& domain, set *addrs) -{ - sword rc; - OCIStmt *stmt; - - char hostaddr[512]; - sb2 hostaddr_ind; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, alsoNotifyQuerySQL, alsoNotifyQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":name", mQueryZone, sizeof(mQueryZone)); - - DNSName_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); - - define_output_str(stmt, 1, &hostaddr_ind, hostaddr, sizeof(hostaddr)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle alsoNotifies", oraerr); - } - - while (rc != OCI_NO_DATA) { - check_indicator(hostaddr_ind, false); - - addrs->insert(hostaddr); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "OracleBackend alsoNotifies fetch", oraerr - ); - } - } - - release_query(stmt, alsoNotifyQueryKey); -} - -void -OracleBackend::getUnfreshSlaveInfos (vector* domains) -{ - sword rc; - OCIStmt *stmt; - - struct timeval now; - gettimeofday(&now, NULL); - mQueryTimestamp = now.tv_sec; - - int last_check; - sb2 last_check_ind; - uint32_t serial; - sb2 serial_ind; - char master[512]; - sb2 master_ind; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, unfreshZonesQuerySQL, unfreshZonesQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":ts", &mQueryTimestamp); - define_output_int(stmt, 1, &mResultZoneIdInd, &mResultZoneId); - define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); - define_output_int(stmt, 3, &last_check_ind, &last_check); - define_output_uint32(stmt, 4, &serial_ind, &serial); - define_output_str(stmt, 5, &master_ind, master, sizeof(master)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle getUnfreshSlaveInfos", oraerr); - } - - while (rc != OCI_NO_DATA) { - check_indicator(mResultZoneIdInd, false); - check_indicator(mResultNameInd, false); - check_indicator(serial_ind, true); - check_indicator(last_check_ind, true); - int zoneId = mResultZoneId; - - if (mResultZoneId < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); - - DomainInfo di; - di.id = mResultZoneId; - di.zone = DNSName(mResultName); - di.last_check = last_check; - di.kind = DomainInfo::Slave; - di.backend = this; - if (serial_ind == 0) { - di.serial = serial; - } - - while (rc != OCI_NO_DATA && zoneId == mResultZoneId) { - check_indicator(master_ind, false); - di.masters.push_back(master); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "OracleBackend, fetching next unfresh slave master", oraerr - ); - } - - check_indicator(mResultZoneIdInd, false); - } - - domains->push_back(di); - } - - release_query(stmt, unfreshZonesQueryKey); -} - -void -OracleBackend::getUpdatedMasters (vector* domains) -{ - sword rc; - OCIStmt *stmt; - - uint32_t serial; - sb2 serial_ind; - uint32_t notified_serial; - sb2 notified_serial_ind; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, updatedMastersQuerySQL, updatedMastersQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - define_output_int(stmt, 1, &mResultZoneIdInd, &mResultZoneId); - define_output_str(stmt, 2, &mResultNameInd, mResultName, sizeof(mResultName)); - define_output_uint32(stmt, 3, &serial_ind, &serial); - define_output_uint32(stmt, 4, ¬ified_serial_ind, ¬ified_serial); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle getUpdatedMasters", oraerr); - } - - while (rc != OCI_NO_DATA) { - check_indicator(mResultZoneIdInd, false); - check_indicator(mResultNameInd, false); - check_indicator(serial_ind, false); - check_indicator(notified_serial_ind, true); - - if (mResultZoneId < 0) throw std::underflow_error("OracleBackend: Zone ID < 0 when writing into uint32_t"); - - DomainInfo di; - di.id = mResultZoneId; - di.zone = DNSName(mResultName); - di.serial = serial; - di.notified_serial = notified_serial; - di.kind = DomainInfo::Master; - di.backend = this; - - domains->push_back(di); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "OracleBackend, fetching next updated master", oraerr - ); - } - } - - release_query(stmt, updatedMastersQueryKey); -} - -void -OracleBackend::setFresh (uint32_t zoneId) -{ - sword rc; - OCIStmt *stmt; - - mQueryZoneId = zoneId; - - struct timeval now; - gettimeofday(&now, NULL); - mQueryTimestamp = now.tv_sec; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setFresh BEGIN", oraerr); - } - - stmt = prepare_query(masterSvcCtx, zoneSetLastCheckQuerySQL, zoneSetLastCheckQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":zoneid", &mQueryZoneId); - bind_int(stmt, ":lastcheck", &mQueryTimestamp); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setFresh", oraerr); - } - - release_query(stmt, zoneSetLastCheckQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc) { - throw OracleException("Oracle setFresh COMMIT", oraerr); - } -} - -void -OracleBackend::setNotified (uint32_t zoneId, uint32_t serial) -{ - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setNotified BEGIN", oraerr); - } - - stmt = prepare_query(masterSvcCtx, zoneSetNotifiedSerialQuerySQL, zoneSetNotifiedSerialQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_uint32(stmt, ":serial", &serial); - bind_uint32(stmt, ":zoneid", &zoneId); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setNotified", oraerr); - } - - release_query(stmt, zoneSetNotifiedSerialQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc) { - throw OracleException("Oracle setNotified COMMIT", oraerr); - } -} - -bool -OracleBackend::list (const DNSName& domain, int zoneId, bool include_disabled) -{ - sword rc; - - // This is only for backends that cannot lookup by zoneId, - // we can discard - (void)domain; - - if (curStmtHandle != NULL) throw OracleException("Invalid state"); - curStmtHandle = prepare_query(pooledSvcCtx, listQuerySQL, listQueryKey); - curStmtKey = listQueryKey; - define_fwd_query(curStmtHandle); - bind_str_failokay(curStmtHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_int(curStmtHandle, ":zoneid", &mQueryZoneId); - - mQueryZoneId = zoneId; - - rc = OCIStmtExecute(pooledSvcCtx, curStmtHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle List", oraerr); - } - - if (rc == OCI_SUCCESS || rc == OCI_SUCCESS_WITH_INFO) { - return true; - } - - if (rc == OCI_NO_DATA) { - release_query(curStmtHandle, curStmtKey); - curStmtHandle = NULL; - } - - return false; -} - -bool OracleBackend::get (DNSResourceRecord &rr) -{ - sword rc; - - if (curStmtHandle == NULL) { - return false; - } - - check_indicator(mResultNameInd, false); - check_indicator(mResultTTLInd, false); - check_indicator(mResultTypeInd, true); - check_indicator(mResultContentInd, true); - check_indicator(mResultZoneIdInd, false); - check_indicator(mResultLastChangeInd, false); - if (d_dnssecQueries) - check_indicator(mResultIsAuthInd, false); - - rr.qname = DNSName(mResultName); - rr.ttl = mResultTTL; - rr.qtype = mResultType; - rr.content = mResultContent; - rr.domain_id = mResultZoneId; - rr.last_modified = mResultLastChange; - if (d_dnssecQueries) - rr.auth = mResultIsAuth > 0; - else - rr.auth = 1; - - rc = OCIStmtFetch2(curStmtHandle, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("OracleBackend, fetching next row", oraerr); - } - - if (rc == OCI_NO_DATA) { - release_query(curStmtHandle, curStmtKey); - curStmtHandle = NULL; - } - - return true; -} - -bool -OracleBackend::startTransaction (const DNSName& domain, int zoneId) -{ - sword rc; - OCIStmt *stmt; - - (void)domain; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle startTransaction", oraerr); - } - - if (zoneId >= 0) { - if (openTransactionZoneID >= 0) { - throw OracleException("Attempt to start AXFR during AXFR"); - } - - mQueryZoneId = openTransactionZoneID = zoneId; - - stmt = prepare_query(masterSvcCtx, deleteZoneQuerySQL, deleteZoneQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":zoneid", &mQueryZoneId); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle startTransaction deleteZone", oraerr); - } - - release_query(stmt, deleteZoneQueryKey); - } - - return true; -} - -bool -OracleBackend::feedRecord (const DNSResourceRecord &rr, const DNSName ordername) -{ - sword rc; - OCIStmt *stmt; - - uint32_t ttl; - - stmt = prepare_query(masterSvcCtx, insertRecordQuerySQL, insertRecordQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":zoneid", &mQueryZoneId); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":type", mQueryType, sizeof(mQueryType)); - bind_uint32(stmt, ":ttl", &ttl); - bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); - - mQueryZoneId = rr.domain_id; - DNSName_to_cbuf(mQueryName, rr.qname, sizeof(mQueryName)); - ttl = rr.ttl; - string_to_cbuf(mQueryType, rr.qtype.getName(), sizeof(mQueryType)); - string_to_cbuf(mQueryContent, rr.content, sizeof(mQueryContent)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle feedRecord", oraerr); - } - - release_query(stmt, insertRecordQueryKey); - - return true; -} - -bool -OracleBackend::commitTransaction () -{ - sword rc; - OCIStmt *stmt; - - if (openTransactionZoneID >= 0) { - stmt = prepare_query(masterSvcCtx, finalizeAXFRQuerySQL, finalizeAXFRQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_int(stmt, ":zoneid", &openTransactionZoneID); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle commitTransaction finalizeAXFR", oraerr); - } - - release_query(stmt, finalizeAXFRQueryKey); - - openTransactionZoneID = -1; - } - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc) { - throw OracleException("Oracle commitTransaction", oraerr); - } - - return true; -} - -bool -OracleBackend::abortTransaction () -{ - sword err; - - err = OCITransRollback(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (err) { - throw OracleException("Oracle abortTransaction", oraerr); - } - - return true; -} - -bool -OracleBackend::superMasterBackend (const string &ip, const DNSName& domain, - const vector &nsset, - string *nameserver, string *account, - DNSBackend **backend) -{ - sword rc; - OCIStmt *stmt; - - bool result = false; - - (void)domain; - - string_to_cbuf(mQueryAddr, ip, sizeof(mQueryAddr)); - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, acceptSupernotificationQuerySQL, acceptSupernotificationQueryKey); - define_output_str(stmt, 1, &mResultNameInd, mResultName, sizeof(mResultName)); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":ns", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":ip", mQueryAddr, sizeof(mQueryAddr)); - - for (vector::const_iterator i=nsset.begin(); i != nsset.end(); ++i) { - string_to_cbuf(mQueryName, i->content, sizeof(mQueryName)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle superMasterBackend", oraerr); - } - - if (rc != OCI_NO_DATA) { - *account = mResultName; - *backend = this; - result = true; - break; - } - } - - release_query(stmt, acceptSupernotificationQueryKey); - - return result; -} - -bool -OracleBackend::createSlaveDomain(const string &ip, const DNSName& domain, - const string &nameserver, const string &account) -{ - sword rc; - OCIStmt *insertSlaveQueryHandle; - OCIStmt *insertMasterQueryHandle; - - DNSName_to_cbuf(mQueryZone, domain, sizeof(mQueryZone)); - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle createSlaveDomain BEGIN", oraerr); - } - - insertSlaveQueryHandle = prepare_query(masterSvcCtx, insertSlaveQuerySQL, insertSlaveQueryKey); - bind_str_failokay(insertSlaveQueryHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_int(insertSlaveQueryHandle, ":zoneid", &mQueryZoneId); - bind_str(insertSlaveQueryHandle, ":zone", mQueryZone, sizeof(mQueryZone)); - - insertMasterQueryHandle = prepare_query(masterSvcCtx, insertMasterQuerySQL, insertMasterQueryKey); - bind_str_failokay(insertMasterQueryHandle, ":nsname", myServerName, sizeof(myServerName)); - bind_int(insertMasterQueryHandle, ":zoneid", &mQueryZoneId); - bind_str(insertMasterQueryHandle, ":ip", mQueryAddr, sizeof(mQueryAddr)); - - rc = OCIStmtExecute(masterSvcCtx, insertSlaveQueryHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "Oracle createSlaveDomain insertSlave", oraerr); - } - - string_to_cbuf(mQueryAddr, ip, sizeof(mQueryAddr)); - - rc = OCIStmtExecute(masterSvcCtx, insertMasterQueryHandle, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException( - "Oracle createSlaveDomain insertMaster", oraerr); - } - - release_query(insertSlaveQueryHandle, insertSlaveQueryKey); - release_query(insertMasterQueryHandle, insertMasterQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc) { - throw OracleException("Oracle createSlaveDomain COMMIT", oraerr); - } - - return true; -} - -bool -OracleBackend::getAllDomainMetadata (const DNSName& name, std::map >& meta) -{ - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, getAllZoneMetadataQuerySQL, getAllZoneMetadataQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - - define_output_str(stmt, 1, &mResultTypeInd, mResultType, sizeof(mResultType)); - define_output_str(stmt, 2, &mResultContentInd, mResultContent, sizeof(mResultContent)); - - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - while (rc != OCI_NO_DATA) { - if (rc == OCI_ERROR) { - throw OracleException("Oracle getAllDomainMetadata", oraerr); - } - check_indicator(mResultTypeInd, true); - check_indicator(mResultContentInd, true); - - string kind = mResultType; - string content = mResultContent; - if (!isDnssecDomainMetadata(content)) - meta[kind].push_back(content); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - } - - release_query(stmt, getAllZoneMetadataQueryKey); - return true; -} - -bool -OracleBackend::getDomainMetadata (const DNSName& name, const string& kind, - vector& meta) -{ - if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) - return -1; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, getZoneMetadataQuerySQL, getZoneMetadataQueryKey); - bind_str_failokay(stmt, ":nsname", myServerName, sizeof(myServerName)); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); - define_output_str(stmt, 1, &mResultContentInd, mResultContent, sizeof(mResultContent)); - - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - while (rc != OCI_NO_DATA) { - if (rc == OCI_ERROR) { - throw OracleException("Oracle getDomainMetadata", oraerr); - } - - check_indicator(mResultContentInd, true); - - string content = mResultContent; - meta.push_back(content); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - } - - release_query(stmt, getZoneMetadataQueryKey); - return true; -} - -bool -OracleBackend::setDomainMetadata(const DNSName& name, const string& kind, - const vector& meta) -{ - if(!d_dnssecQueries && isDnssecDomainMetadata(kind)) - return -1; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainMetadata BEGIN", oraerr); - } - - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - string_to_cbuf(mQueryType, kind, sizeof(mQueryType)); - - stmt = prepare_query(masterSvcCtx, delZoneMetadataQuerySQL, delZoneMetadataQueryKey); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainMetadata DELETE", oraerr); - } - - release_query(stmt, delZoneMetadataQueryKey); - - stmt = prepare_query(masterSvcCtx, setZoneMetadataQuerySQL, setZoneMetadataQueryKey); - - int i = 0; - - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":kind", mQueryType, sizeof(mQueryType)); - bind_int(stmt, ":i", &i); - bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); - - for (vector::const_iterator it = meta.begin(); it != meta.end(); ++it) { - string_to_cbuf(mQueryContent, *it, sizeof(mQueryContent)); - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainMetadata INSERT", oraerr); - } - i++; - } - - release_query(stmt, setZoneMetadataQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainMetadata COMMIT", oraerr); - } - - return true; -} - -bool -OracleBackend::getTSIGKey (const DNSName& name, DNSName* algorithm, string* content) -{ - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, getTSIGKeyQuerySQL, getTSIGKeyQueryKey); - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - - define_output_str(stmt, 1, &mResultTypeInd, mResultType, sizeof(mResultType)); - define_output_str(stmt, 2, &mResultContentInd, mResultContent, sizeof(mResultContent)); - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - content->clear(); - while (rc != OCI_NO_DATA) { - - if (rc == OCI_ERROR) { - throw OracleException("Oracle getTSIGKey", oraerr); - } - - check_indicator(mResultTypeInd, false); - check_indicator(mResultContentInd, false); - - if(algorithm->empty() || *algorithm==DNSName(mResultType)) { - *algorithm = DNSName(mResultType); - *content = mResultContent; - } - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - } - - release_query(stmt, getTSIGKeyQueryKey); - return !content->empty(); -} - -bool -OracleBackend::delTSIGKey(const DNSName& name) -{ - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - stmt = prepare_query(masterSvcCtx, delTSIGKeyQuerySQL, delTSIGKeyQueryKey); - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle delTSIGKey", oraerr); - } - - release_query(stmt, setTSIGKeyQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - if (rc == OCI_ERROR) { - throw OracleException("Oracle delTSIGKey COMMIT", oraerr); - } - return true; -} - -bool -OracleBackend::setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) -{ - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setTSIGKey BEGIN", oraerr); - } - - stmt = prepare_query(masterSvcCtx, delTSIGKeyQuerySQL, delTSIGKeyQueryKey); - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setTSIGKey DELETE", oraerr); - } - - release_query(stmt, delTSIGKeyQueryKey); - - stmt = prepare_query(masterSvcCtx, setTSIGKeyQuerySQL, setTSIGKeyQueryKey); - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - DNSName_to_cbuf(mQueryType, algorithm, sizeof(mQueryType)); - string_to_cbuf(mQueryContent, content, sizeof(mQueryContent)); - - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_str(stmt, ":algorithm", mQueryType, sizeof(mQueryType)); - bind_str(stmt, ":secret", mQueryContent, sizeof(mQueryContent)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setTSIGKey INSERT", oraerr); - } - - release_query(stmt, setTSIGKeyQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setTSIGKey COMMIT", oraerr); - } - - return true; -} - -bool -OracleBackend::getTSIGKeys(std::vector< struct TSIGKey > &keys) -{ - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, getTSIGKeysQuerySQL, getTSIGKeysQueryKey); - define_output_str(stmt, 1, &mResultNameInd, mResultName, sizeof(mResultName)); - define_output_str(stmt, 2, &mResultTypeInd, mResultType, sizeof(mResultType)); - define_output_str(stmt, 3, &mResultContentInd, mResultContent, sizeof(mResultContent)); - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - while (rc != OCI_NO_DATA) { - if (rc == OCI_ERROR) { - throw OracleException("Oracle getDomainMetadata", oraerr); - } - - check_indicator(mResultNameInd, true); - check_indicator(mResultTypeInd, true); - check_indicator(mResultContentInd, true); - - struct TSIGKey key; - - key.name = DNSName(mResultName); - key.algorithm = DNSName(mResultType); - key.key = mResultContent; - keys.push_back(key); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - } - - release_query(stmt, getTSIGKeyQueryKey); - return true; -} - -bool -OracleBackend::getDomainKeys (const DNSName& name, vector& keys) -{ - if(!d_dnssecQueries) - return -1; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - stmt = prepare_query(pooledSvcCtx, getZoneKeysQuerySQL, getZoneKeysQueryKey); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - - sb2 key_id_ind = 0; - unsigned int key_id = 0; - sb2 key_flags_ind = 0; - uint16_t key_flags = 0; - sb2 key_active_ind = 0; - int key_active = 0; - - define_output_uint(stmt, 1, &key_id_ind, &key_id); - define_output_uint16(stmt, 2, &key_flags_ind, &key_flags); - define_output_int(stmt, 3, &key_active_ind, &key_active); - define_output_str(stmt, 4, &mResultContentInd, mResultContent, sizeof(mResultContent)); - - rc = OCIStmtExecute(pooledSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - while (rc != OCI_NO_DATA) { - if (rc == OCI_ERROR) { - throw OracleException("Oracle getDomainKeys", oraerr); - } - - check_indicator(key_id_ind, false); - check_indicator(key_flags_ind, false); - check_indicator(key_active_ind, false); - check_indicator(mResultContentInd, false); - - KeyData kd; - kd.id = key_id; - kd.flags = key_flags; - kd.active = key_active; - kd.content = mResultContent; - keys.push_back(kd); - - rc = OCIStmtFetch2(stmt, oraerr, 1, OCI_FETCH_NEXT, 0, OCI_DEFAULT); - } - - release_query(stmt, getZoneKeysQueryKey); - return true; -} - -bool -OracleBackend::removeDomainKey (const DNSName& name, unsigned int id) -{ - if(!d_dnssecQueries) - return -1; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle removeDomainKey BEGIN", oraerr); - } - - stmt = prepare_query(masterSvcCtx, delZoneKeyQuerySQL, delZoneKeyQueryKey); - bind_uint(stmt, ":keyid", &id); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle removeDomainKey DELETE", oraerr); - } - - release_query(stmt, delZoneKeyQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle removeDomainKey COMMIT", oraerr); - } - - return true; -} - -bool -OracleBackend::addDomainKey (const DNSName& name, const KeyData& key, int64_t& id) -{ - if(!d_dnssecQueries) - return false; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - int key_id = -1; - uint16_t key_flags = key.flags; - int key_active = key.active; - - openMasterConnection(); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle addDomainKey BEGIN", oraerr); - } - - DNSName_to_cbuf(mQueryName, name, sizeof(mQueryName)); - string_to_cbuf(mQueryContent, key.content, sizeof(mQueryContent)); - - stmt = prepare_query(masterSvcCtx, addZoneKeyQuerySQL, addZoneKeyQueryKey); - - bind_int(stmt, ":keyid", &key_id); - bind_str(stmt, ":name", mQueryName, sizeof(mQueryName)); - bind_uint16(stmt, ":flags", &key_flags); - bind_int(stmt, ":active", &key_active); - bind_str(stmt, ":content", mQueryContent, sizeof(mQueryContent)); - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle addDomainKey INSERT", oraerr); - } - - release_query(stmt, addZoneKeyQueryKey); - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle addDomainKey COMMIT", oraerr); - } - - id = key_id; - return key_id >= 0; -} - -bool -OracleBackend::setDomainKeyState (const DNSName& name, unsigned int id, int active) -{ - if(!d_dnssecQueries) - return -1; - DomainInfo di; - if (getDomainInfo(name, di) == false) return false; - - sword rc; - OCIStmt *stmt; - - openMasterConnection(); - - stmt = prepare_query(masterSvcCtx, setZoneKeyStateQuerySQL, setZoneKeyStateQueryKey); - bind_uint(stmt, ":keyid", &id); - bind_int(stmt, ":active", &active); - - rc = OCITransStart(masterSvcCtx, oraerr, 60, OCI_TRANS_NEW); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainKeyState BEGIN", oraerr); - } - - rc = OCIStmtExecute(masterSvcCtx, stmt, oraerr, 1, 0, NULL, NULL, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainKeyState UPDATE", oraerr); - } - - rc = OCITransCommit(masterSvcCtx, oraerr, OCI_DEFAULT); - - if (rc == OCI_ERROR) { - throw OracleException("Oracle setDomainKeyState COMMIT", oraerr); - } - - release_query(stmt, setZoneKeyStateQueryKey); - return true; -} - -bool -OracleBackend::activateDomainKey (const DNSName& name, unsigned int id) -{ - return setDomainKeyState(name, id, 1); -} - -bool -OracleBackend::deactivateDomainKey (const DNSName& name, unsigned int id) -{ - return setDomainKeyState(name, id, 0); -} - -void -OracleBackend::Cleanup () -{ - sword err; - - if (masterSvcCtx != NULL) { - err = OCITransRollback(masterSvcCtx, oraerr, OCI_DEFAULT); - // No error check, we don't care if ROLLBACK failed - err = OCISessionRelease(masterSvcCtx, oraerr, NULL, 0, OCI_DEFAULT); - if (err == OCI_ERROR) { - throw OracleException("Oracle cleanup, OCISessionRelease (master)", oraerr); - } - masterSvcCtx = NULL; - OCIHandleFree(masterAuthHandle, OCI_HTYPE_AUTHINFO); - masterAuthHandle = NULL; - } - - if (pooledSvcCtx != NULL) { - err = OCITransRollback(pooledSvcCtx, oraerr, OCI_DEFAULT); - // No error check, we don't care if ROLLBACK failed - err = OCISessionRelease(pooledSvcCtx, oraerr, NULL, 0, OCI_DEFAULT); - if (err == OCI_ERROR) { - throw OracleException("Oracle cleanup, OCISessionRelease (pooled)", oraerr); - } - pooledSvcCtx = NULL; - } - - if (oraerr != NULL) { - OCIHandleFree(oraerr, OCI_HTYPE_ERROR); - oraerr = NULL; - } -} - -OCIStmt* -OracleBackend::prepare_query (OCISvcCtx *orasvc, string& code, const char *key) -{ - sword err; - - OCIStmt *handle = NULL; - - err = OCIStmtPrepare2(orasvc, &handle, oraerr, (OraText*) code.c_str(), code.length(), (OraText*) key, strlen(key), OCI_NTV_SYNTAX, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Preparing Oracle statement", oraerr); - } - - return handle; -} - -void -OracleBackend::release_query (OCIStmt *stmt, const char *key) -{ - sword err; - - err = OCIStmtRelease(stmt, oraerr, (OraText*)key, strlen(key), OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Releasing Oracle statement", oraerr); - } -} - -void -OracleBackend::define_output_str (OCIStmt *s, ub4 pos, sb2 *ind, - char *buf, sb4 buflen) -{ - sword err; - OCIDefine *handle = NULL; - - err = OCIDefineByPos(s, &handle, oraerr, pos, buf, buflen, SQLT_STR, - ind, NULL, NULL, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Defining output for Oracle statement", oraerr); - } -} - -void -OracleBackend::define_output_int (OCIStmt *s, ub4 pos, sb2 *ind, int *buf) -{ - sword err; - OCIDefine *handle = NULL; - - err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(int), - SQLT_INT, ind, NULL, NULL, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Defining output for Oracle statement", oraerr); - } -} - -void -OracleBackend::define_output_uint (OCIStmt *s, ub4 pos, sb2 *ind, unsigned int *buf) -{ - sword err; - OCIDefine *handle = NULL; - - err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(unsigned int), - SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Defining output for Oracle statement", oraerr); - } -} - -void -OracleBackend::define_output_uint16 (OCIStmt *s, ub4 pos, sb2 *ind, - uint16_t *buf) -{ - sword err; - OCIDefine *handle = NULL; - - err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(uint16_t), - SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Defining output for Oracle statement", oraerr); - } -} - -void -OracleBackend::define_output_uint32 (OCIStmt *s, ub4 pos, sb2 *ind, - uint32_t *buf) -{ - sword err; - OCIDefine *handle = NULL; - - err = OCIDefineByPos(s, &handle, oraerr, pos, buf, sizeof(uint32_t), - SQLT_UIN, ind, NULL, NULL, OCI_DEFAULT); - - if (err == OCI_ERROR) { - throw OracleException("Defining output for Oracle statement", oraerr); - } -} - -void -OracleBackend::check_indicator (sb2 ind, bool null_okay) -{ - if ((!null_okay) && (ind == -1)) { - throw OracleException("Received NULL where a value was expected"); - } - - if ((ind < -1) || (ind > 0)) { - throw OracleException("Return value truncated"); - } -} - -void -OracleBackend::define_fwd_query (OCIStmt *s) -{ - const ub4 n = 100; - sword err = OCIAttrSet(s, OCI_HTYPE_STMT, (void*) &n, sizeof(ub4), - OCI_ATTR_PREFETCH_ROWS, oraerr); - - if (err == OCI_ERROR) { - throw OracleException("Activating row prefetching", oraerr); - } - - define_output_str(s, 1, &mResultNameInd, - mResultName, sizeof(mResultName)); - define_output_uint32(s, 2, &mResultTTLInd, &mResultTTL); - define_output_str(s, 3, &mResultTypeInd, - mResultType, sizeof(mResultType)); - define_output_str(s, 4, &mResultContentInd, - mResultContent, sizeof(mResultContent)); - define_output_int(s, 5, &mResultZoneIdInd, &mResultZoneId); - define_output_int(s, 6, &mResultLastChangeInd, &mResultLastChange); - if (d_dnssecQueries) - define_output_int(s, 7, &mResultIsAuthInd, &mResultIsAuth); -} - -void -OracleBackend::bind_str (OCIStmt *s, const char *name, char *buf, sb4 buflen) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, buflen, SQLT_STR, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_str (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_str_failokay (OCIStmt *s, const char *name, - char *buf, sb4 buflen) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, buflen, SQLT_STR, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - (void)err; -} - -void -OracleBackend::bind_str_ind (OCIStmt *s, const char *name, - char *buf, sb4 buflen, sb2 *ind) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, buflen, SQLT_STR, - ind, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_str_ind (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_int (OCIStmt *s, const char *name, int *buf) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, sizeof(int), SQLT_INT, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_int (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_uint (OCIStmt *s, const char *name, unsigned int *buf) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, sizeof(unsigned int), SQLT_UIN, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_uint (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_uint16 (OCIStmt *s, const char *name, uint16_t *buf) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, sizeof(uint16_t), SQLT_UIN, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_uint16 (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_uint16_ind (OCIStmt *s, const char *name, uint16_t *buf, - sb2 *ind) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, sizeof(uint16_t), SQLT_UIN, - ind, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_uint16_ind (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - -void -OracleBackend::bind_uint32 (OCIStmt *s, const char *name, uint32_t *buf) -{ - sword err; - OCIBind *handle = NULL; - - err = OCIBindByName(s, &handle, oraerr, - (OraText*) name, strlen(name), - buf, sizeof(uint32_t), SQLT_UIN, - NULL, NULL, NULL, 0, NULL, - OCI_DEFAULT); - - if (err == OCI_ERROR) { - string msg; - msg.append("Oracle bind_uint32 (\""); - msg.append(name); - msg.append("\")"); - throw OracleException(msg, oraerr); - } -} - - -class OracleFactory : public BackendFactory -{ -private: - pthread_mutex_t factoryLock; - OCIEnv *oraenv; - OCIError *oraerr; - OCISPool *mSessionPoolHandle; - text *mSessionPoolName; - ub4 mSessionPoolNameLen; - - void CreateSessionPool () - { - sword err; - - try { - // set some environment variables - setenv("ORACLE_HOME", arg()["oracle-home"].c_str(), 1); - setenv("ORACLE_SID", arg()["oracle-sid"].c_str(), 1); - setenv("NLS_LANG", arg()["oracle-nls-lang"].c_str(), 1); - - // Initialize and create the environment - err = OCIEnvCreate(&oraenv, OCI_THREADED, NULL, NULL, - NULL, NULL, 0, NULL); - if (err == OCI_ERROR) { - throw OracleException("OCIEnvCreate"); - } - // Allocate an error handle - err = OCIHandleAlloc(oraenv, (void**) &oraerr, - OCI_HTYPE_ERROR, 0, NULL); - if (err == OCI_ERROR) { - throw OracleException("OCIHandleAlloc"); - } - - const char *dbname = arg()["oracle-pool-database"].c_str(); - const char *dbuser = arg()["oracle-pool-username"].c_str(); - const char *dbpass = arg()["oracle-pool-password"].c_str(); - - ub4 sess_min = arg().asNum("oracle-session-min"); - ub4 sess_max = arg().asNum("oracle-session-max"); - ub4 sess_inc = arg().asNum("oracle-session-inc"); - ub4 get_mode = OCI_SPOOL_ATTRVAL_NOWAIT; - - // Create a session pool - err = OCIHandleAlloc(oraenv, (void**) &mSessionPoolHandle, - OCI_HTYPE_SPOOL, 0, NULL); - if (err == OCI_ERROR) { - throw OracleException("OCIHandleAlloc"); - } - err = OCISessionPoolCreate(oraenv, oraerr, - mSessionPoolHandle, - (OraText **) &mSessionPoolName, - &mSessionPoolNameLen, - (OraText *) dbname, strlen(dbname), - sess_min, sess_max, sess_inc, - (OraText *) dbuser, strlen(dbuser), - (OraText *) dbpass, strlen(dbpass), - OCI_SPC_STMTCACHE | OCI_SPC_HOMOGENEOUS); - if (err == OCI_ERROR) { - throw OracleException("Creating Oracle session pool", oraerr); - } - - // Set session pool NOWAIT - err = OCIAttrSet(mSessionPoolHandle, OCI_HTYPE_SPOOL, &get_mode, 0, OCI_ATTR_SPOOL_GETMODE, oraerr); - if (err == OCI_ERROR) { - throw OracleException("Setting session pool get mode", oraerr); - } - } catch (OracleException &theException) { - g_log << Logger::Critical << "OracleFactory: " - << theException.reason << endl; - Cleanup(); - throw theException; - } - } - - void Cleanup () - { - sword err; - - if (mSessionPoolHandle != NULL) { - try { - err = OCISessionPoolDestroy(mSessionPoolHandle, oraerr, - OCI_SPD_FORCE); - OCIHandleFree(mSessionPoolHandle, OCI_HTYPE_SPOOL); - mSessionPoolHandle = NULL; - if (err == OCI_ERROR) { - throw OracleException("OCISessionPoolDestroy", oraerr); - } - } catch (OracleException &theException) { - g_log << Logger::Error << "Failed to destroy Oracle session pool: " - << theException.reason << endl; - } - } - - if (oraerr != NULL) { - OCIHandleFree(oraerr, OCI_HTYPE_ERROR); - oraerr = NULL; - } - - if (oraenv != NULL) { - OCIHandleFree(oraenv, OCI_HTYPE_ENV); - oraenv = NULL; - } - } - -public: - -OracleFactory () : BackendFactory("oracle") { - pthread_mutex_init(&factoryLock, NULL); - oraenv = NULL; - oraerr = NULL; - mSessionPoolHandle = NULL; - mSessionPoolName = NULL; - mSessionPoolNameLen = 0; - } - - ~OracleFactory () { - Cleanup(); - pthread_mutex_destroy(&factoryLock); - } - - void declareArguments (const string & suffix = "") { - declare(suffix,"home", "Oracle home path", ""); - declare(suffix,"sid", "Oracle sid", "XE"); - declare(suffix,"nls-lang", "Oracle language", "AMERICAN_AMERICA.AL32UTF8"); - - declare(suffix, "pool-database", "Database to connect to for the session pool", "powerdns"); - declare(suffix, "pool-username", "Username to connect as for the session pool", "powerdns"); - declare(suffix, "pool-password", "Password to connect with for the session pool", ""); - declare(suffix, "session-min", "Number of sessions to open at startup", "4"); - declare(suffix, "session-inc", "Number of sessions to open when growing", "2"); - declare(suffix, "session-max", "Max number of sessions to have open", "20"); - declare(suffix, "master-database", "Database to connect to for write access", "powerdns"); - declare(suffix, "master-username", "Username to connect as for write access", "powerdns"); - declare(suffix, "master-password", "Password to connect with for write access", ""); - declare(suffix, "dnssec", "Assume DNSSEC Schema is in place", "no"); - declare(suffix, "nameserver-name", "", ""); - - declare(suffix, "basic-query", "", basicQueryDefaultSQL); - declare(suffix, "basic-query-auth", "", basicQueryDefaultAuthSQL); - declare(suffix, "basic-id-query", "", basicIdQueryDefaultSQL); - declare(suffix, "basic-id-query-auth", "", basicIdQueryDefaultAuthSQL); - declare(suffix, "any-query", "", anyQueryDefaultSQL); - declare(suffix, "any-query-auth", "", anyQueryDefaultAuthSQL); - declare(suffix, "any-id-query", "", anyIdQueryDefaultSQL); - declare(suffix, "any-id-query-auth", "", anyIdQueryDefaultAuthSQL); - declare(suffix, "list-query", "", listQueryDefaultSQL); - declare(suffix, "list-query-auth", "", listQueryDefaultAuthSQL); - declare(suffix, "zone-info-query", "", zoneInfoQueryDefaultSQL); - declare(suffix, "also-notify-query", "", alsoNotifyQueryDefaultSQL); - declare(suffix, "zone-masters-query", "", zoneMastersQueryDefaultSQL); - declare(suffix, "delete-zone-query", "", deleteZoneQueryDefaultSQL); - declare(suffix, "zone-set-last-check-query", "", zoneSetLastCheckQueryDefaultSQL); - declare(suffix, "zone-set-notified-serial-query", "", zoneSetNotifiedSerialQueryDefaultSQL); - declare(suffix, "insert-record-query", "", insertRecordQueryDefaultSQL); - declare(suffix, "finalize-axfr-query", "", finalizeAXFRQueryDefaultSQL); - declare(suffix, "unfresh-zones-query", "", unfreshZonesQueryDefaultSQL); - declare(suffix, "updated-masters-query", "", updatedMastersQueryDefaultSQL); - declare(suffix, "accept-supernotification-query", "", acceptSupernotificationQueryDefaultSQL); - declare(suffix, "insert-slave-query", "", insertSlaveQueryDefaultSQL); - declare(suffix, "insert-master-query", "", insertMasterQueryDefaultSQL); - declare(suffix, "prev-next-name-query", "", prevNextNameQueryDefaultSQL); - declare(suffix, "prev-next-hash-query", "", prevNextHashQueryDefaultSQL); - - declare(suffix, "get-all-zone-metadata-query", "", getAllZoneMetadataQueryDefaultSQL); - declare(suffix, "get-zone-metadata-query", "", getZoneMetadataQueryDefaultSQL); - declare(suffix, "del-zone-metadata-query", "", delZoneMetadataQueryDefaultSQL); - declare(suffix, "set-zone-metadata-query", "", setZoneMetadataQueryDefaultSQL); - - declare(suffix, "get-tsig-key-query", "", getTSIGKeyQueryDefaultSQL); - declare(suffix, "del-tsig-key-query", "", delTSIGKeyQueryDefaultSQL); - declare(suffix, "set-tsig-key-query", "", setTSIGKeyQueryDefaultSQL); - declare(suffix, "get-tsig-keys-query", "", getTSIGKeysQueryDefaultSQL); - - declare(suffix, "get-zone-keys-query", "", getZoneKeysQueryDefaultSQL); - declare(suffix, "del-zone-key-query", "", delZoneKeyQueryDefaultSQL); - declare(suffix, "add-zone-key-query", "", addZoneKeyQueryDefaultSQL); - declare(suffix, "set-zone-key-state-query", "", setZoneKeyStateQueryDefaultSQL); - } - - DNSBackend *make (const string & suffix = "") { - { - Lock l(&factoryLock); - if (oraenv == NULL) { - CreateSessionPool(); - } - } - return new OracleBackend(suffix, oraenv, - (char *) mSessionPoolName); - } - -}; - - -//! Magic class that is activated when the dynamic library is loaded -class OracleLoader -{ -public: - - OracleLoader() - { - BackendMakers().report(new OracleFactory); - g_log << Logger::Info << "[oraclebackend] This is the oracle backend version " VERSION -#ifndef REPRODUCIBLE - << " (" __DATE__ " " __TIME__ ")" -#endif - << " reporting" << endl; - } - -}; - -static OracleLoader loader; - -/* vi: set sw=2 et : */ diff --git a/modules/oraclebackend/oraclebackend.hh b/modules/oraclebackend/oraclebackend.hh deleted file mode 100644 index c846897c1..000000000 --- a/modules/oraclebackend/oraclebackend.hh +++ /dev/null @@ -1,219 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * originally authored by Maik Zumstrull - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * In addition, for the avoidance of any doubt, permission is granted to - * link this program with OpenSSL and to (re)distribute the binaries - * produced as the result of such linking. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef PDNS_ORACLEBACKEND_HH -#define PDNS_ORACLEBACKEND_HH - -#include -#include -#include - -#include - -#include "pdns/namespaces.hh" - -class OracleException : public DBException -{ -public: - - OracleException (string r) : DBException(r) {} - - OracleException (string context, OCIError *theErrorHandle) - : DBException(context + ": ORA-UNKNOWN") - { - if (theErrorHandle != NULL) { - char msg[2048]; - sb4 errcode = 0; - - msg[0] = '\0'; - - OCIErrorGet((void *) theErrorHandle, 1, NULL, &errcode, (OraText*) msg, - sizeof(msg), OCI_HTYPE_ERROR); - - reason = context + ": " + msg; - } - } - -}; - -class OracleBackend : public DNSBackend -{ -public: - - OracleBackend(const string &suffix = "", OCIEnv *envh = - NULL, char *poolname = NULL); - virtual ~OracleBackend(); - - void lookup(const QType &qtype, const DNSName& qname, DNSPacket *p = 0, - int zoneId = -1) override; - - bool getBeforeAndAfterNames(uint32_t zoneId, const DNSName& zone, - const DNSName& name, - DNSName& before, DNSName& after) override; - bool getBeforeAndAfterNamesAbsolute(uint32_t zoneId, - const DNSName& name, - DNSName& unhashed, - DNSName& before, - DNSName& after) override; - bool get(DNSResourceRecord &rr) override; - vector getDomainMasters(const DNSName& domain, int zoneId) override; - bool getDomainInfo(const DNSName& domain, DomainInfo &di) override; - void alsoNotifies(const DNSName& domain, set *addrs) override; - void getUnfreshSlaveInfos(vector* domains) override; - void getUpdatedMasters(vector* domains) override; - void setFresh(uint32_t zoneId) override; - void setNotified(uint32_t zoneId, uint32_t serial) override; - bool list(const DNSName& domain, int zoneId, bool include_disabled=false) override; - bool startTransaction(const DNSName& domain, int zoneId) override; - bool feedRecord(const DNSResourceRecord &rr, const DNSName ordername) override; - bool commitTransaction() override; - bool abortTransaction() override; - bool superMasterBackend(const string &ip, const DNSName& domain, - const vector &nsset, - string *account, string *nameserver, - DNSBackend **backend) override; - bool createSlaveDomain(const string &ip, const DNSName& domain, - const string &nameserver, const string &account) override; - - bool getAllDomainMetadata(const DNSName& name, std::map >& meta) override; - bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; - bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override; - - bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content) override; - bool delTSIGKey(const DNSName& name) override; - bool setTSIGKey(const DNSName& name, const DNSName& algorithm, const string& content) override; - bool getTSIGKeys(std::vector< struct TSIGKey > &keys) override; - - bool getDomainKeys(const DNSName& name, vector& keys) override; - bool removeDomainKey(const DNSName& name, unsigned int id) override; - bool addDomainKey(const DNSName& name, const KeyData& key, int64_t& id) override; - bool activateDomainKey(const DNSName& name, unsigned int id) override; - bool deactivateDomainKey(const DNSName& name, unsigned int id) override; - -private: - - OCIEnv *oraenv; - OCIError *oraerr; - OCISvcCtx *pooledSvcCtx; - OCIAuthInfo *masterAuthHandle; - OCISvcCtx *masterSvcCtx; - - string basicQuerySQL; - string basicIdQuerySQL; - string anyQuerySQL; - string anyIdQuerySQL; - string listQuerySQL; - - string zoneInfoQuerySQL; - string alsoNotifyQuerySQL; - string zoneMastersQuerySQL; - string deleteZoneQuerySQL; - string zoneSetLastCheckQuerySQL; - - string insertRecordQuerySQL; - string finalizeAXFRQuerySQL; - - string unfreshZonesQuerySQL; - string updatedMastersQuerySQL; - string acceptSupernotificationQuerySQL; - string insertSlaveQuerySQL; - string insertMasterQuerySQL; - string zoneSetNotifiedSerialQuerySQL; - - string prevNextNameQuerySQL; - string prevNextHashQuerySQL; - - string getAllZoneMetadataQuerySQL; - string getZoneMetadataQuerySQL; - string delZoneMetadataQuerySQL; - string setZoneMetadataQuerySQL; - - string getTSIGKeyQuerySQL; - string delTSIGKeyQuerySQL; - string setTSIGKeyQuerySQL; - string getTSIGKeysQuerySQL; - - string getZoneKeysQuerySQL; - string delZoneKeyQuerySQL; - string addZoneKeyQuerySQL; - string setZoneKeyStateQuerySQL; - - OCIStmt *curStmtHandle; - const char *curStmtKey; - int openTransactionZoneID; - - char myServerName[512]; - - char mQueryName[512]; - char mQueryType[64]; - char mQueryContent[4001]; - char mQueryZone[512]; - char mQueryAddr[64]; - int mQueryZoneId; - int mQueryTimestamp; - - char mResultName[512]; - sb2 mResultNameInd; - uint32_t mResultTTL; - sb2 mResultTTLInd; - char mResultType[64]; - sb2 mResultTypeInd; - char mResultContent[4001]; - sb2 mResultContentInd; - int mResultZoneId; - sb2 mResultZoneIdInd; - int mResultLastChange; - sb2 mResultLastChangeInd; - int mResultIsAuth; - sb2 mResultIsAuthInd; - char mResultPrevName[512]; - sb2 mResultPrevNameInd; - char mResultNextName[512]; - sb2 mResultNextNameInd; - bool d_dnssecQueries; - - void Cleanup(); - - void openMasterConnection(); - bool setDomainKeyState(const DNSName& name, unsigned int id, int active); - - OCIStmt* prepare_query (OCISvcCtx* orasvc, string& code, const char *key); - void release_query (OCIStmt *stmt, const char *key); - void define_output_str (OCIStmt *s, ub4 pos, sb2 *ind, char *buf, sb4 buflen); - void define_output_int (OCIStmt *s, ub4 pos, sb2 *ind, int *buf); - void define_output_uint (OCIStmt *s, ub4 pos, sb2 *ind, unsigned int *buf); - void define_output_uint16 (OCIStmt *s, ub4 pos, sb2 *ind, uint16_t *buf); - void define_output_uint32 (OCIStmt *s, ub4 pos, sb2 *ind, uint32_t *buf); - void check_indicator (sb2 ind, bool null_okay); - void define_fwd_query (OCIStmt *s); - void bind_str (OCIStmt *s, const char *name, char *buf, sb4 buflen); - void bind_str_failokay (OCIStmt *s, const char *name, char *buf, sb4 buflen); - void bind_str_ind (OCIStmt *s, const char *name, char *buf, sb4 buflen, sb2 *ind); - void bind_int (OCIStmt *s, const char *name, int *buf); - void bind_uint (OCIStmt *s, const char *name, unsigned int *buf); - void bind_uint16 (OCIStmt *s, const char *name, uint16_t *buf); - void bind_uint16_ind (OCIStmt *s, const char *name, uint16_t *buf, sb2 *ind); - void bind_uint32 (OCIStmt *s, const char *name, uint32_t *buf); - -}; - -#endif /* PDNS_ORACLEBACKEND_HH */ diff --git a/modules/oraclebackend/schema.oracle.sql b/modules/oraclebackend/schema.oracle.sql deleted file mode 100644 index 3b4f52014..000000000 --- a/modules/oraclebackend/schema.oracle.sql +++ /dev/null @@ -1,484 +0,0 @@ --- THIS IS NOT PRODUCTION-QUALITY CODE --- --- This database schema is meant to serve as documentation-by-example for how --- certain things might be done. It has also been used for early testing of the --- backend. It should not be deployed as-is. - -CREATE SEQUENCE zones_id_seq; - -CREATE TABLE Zones ( - id INTEGER CONSTRAINT pkey_zones PRIMARY KEY, - name VARCHAR2(512) NOT NULL, - type VARCHAR2(32) NOT NULL, - last_check INTEGER, - refresh NUMBER(10,0), - serial NUMBER(10,0) DEFAULT 0 NOT NULL, - notified_serial NUMBER(10,0), - CONSTRAINT chk_zones_name CHECK (name = lower(name)), - CONSTRAINT unq_zones_name UNIQUE (name), - CONSTRAINT chk_zones_type CHECK ( - type IN ('NATIVE', 'MASTER', 'SLAVE') - AND (type = 'SLAVE' OR last_check IS NULL) - ), - CONSTRAINT chk_zones_serial CHECK (serial BETWEEN 0 AND 4294967295), - CONSTRAINT chk_zones_nserial CHECK (notified_serial BETWEEN 0 AND 4294967295), - CONSTRAINT chk_zones_refresh CHECK (refresh BETWEEN 0 AND 4294967295), - CONSTRAINT chk_zones_master CHECK (type = 'MASTER' OR notified_serial IS NULL) -); - -CREATE INDEX zones_type_ind ON Zones (type); - - -CREATE TABLE Zonemasters ( - zone_id INTEGER NOT NULL CONSTRAINT fkey_zonemasters_zones REFERENCES Zones ON DELETE CASCADE, - master VARCHAR2(512) NOT NULL, - CONSTRAINT unq_zonemasters_zone_master UNIQUE (zone_id, master) -); - -CREATE INDEX zonemasters_zone_id_ind ON Zonemasters (zone_id); - - -CREATE TABLE ZoneAlsoNotify ( - zone_id INTEGER NOT NULL CONSTRAINT fkey_zonealsonotify_zones REFERENCES Zones ON DELETE CASCADE, - hostaddr VARCHAR2(512) NOT NULL, - CONSTRAINT unq_zonealsonotify_zone_host UNIQUE (zone_id, hostaddr) -); - -CREATE INDEX zonealsonotify_zone_id_ind ON ZoneAlsoNotify (zone_id); - - -CREATE SEQUENCE supermasters_id_seq; - -CREATE TABLE Supermasters ( - id INTEGER CONSTRAINT pkey_supermasters PRIMARY KEY, - name VARCHAR2(64) NOT NULL, - ip VARCHAR2(64) NOT NULL, - nameserver VARCHAR2(512) NOT NULL -); - -CREATE INDEX supermasters_ip_ind ON Supermasters (ip); - - -CREATE TABLE ZoneMetadata ( - zone_id INTEGER NOT NULL CONSTRAINT fkey_zonemetadata_zones REFERENCES Zones, - meta_type VARCHAR2(64) NOT NULL, - meta_ind INTEGER NOT NULL, - meta_content VARCHAR2(4000), - CONSTRAINT pkey_zonemetadata PRIMARY KEY (zone_id, meta_type, meta_ind) -); - - -CREATE SEQUENCE zonednskeys_id_seq; - -CREATE TABLE ZoneDNSKeys ( - id INTEGER CONSTRAINT pkey_zonednskeys PRIMARY KEY, - zone_id INTEGER NOT NULL CONSTRAINT fkey_zonednskeys_zones REFERENCES Zones, - flags NUMBER(5,0) NOT NULL, - active NUMBER(1,0) NOT NULL, - keydata VARCHAR2(4000) NOT NULL, - CONSTRAINT chk_zonednskeys_flags CHECK (flags BETWEEN 0 AND 65535), - CONSTRAINT chk_zonednskeys_active CHECK (active IN (0, 1)) -); - -CREATE INDEX zonednskeys_zone_ind ON ZoneDNSKeys (zone_id); - - -CREATE TABLE TSIGKeys ( - name VARCHAR2(256), - algorithm VARCHAR2(64) NOT NULL, - secret VARCHAR2(2048) NOT NULL, - CONSTRAINT chk_tsigkeys_name CHECK (name = lower(name)), - CONSTRAINT chk_tsigkeys_algorithm CHECK (algorithm = lower(algorithm)), - CONSTRAINT unq_tsigkeys_nav UNIQUE (name, algorithm, secret) -); - - -CREATE TABLE AccessControlList ( - acl_type VARCHAR2(64) NOT NULL, - acl_key VARCHAR2(256) NOT NULL, - acl_val VARCHAR2(2048), - CONSTRAINT chk_acl_type CHECK (acl_type = 'allow-axfr'), - CONSTRAINT unq_acl_tkv UNIQUE (acl_type, acl_key, acl_val) -); - -CREATE INDEX acl_tk ON AccessControlList (acl_type, acl_key); - - -CREATE SEQUENCE records_id_seq; - -CREATE TABLE Records ( - id INTEGER CONSTRAINT pkey_records PRIMARY KEY, - zone_id INTEGER NOT NULL CONSTRAINT fkey_records_zones REFERENCES Zones, - fqdn VARCHAR2(512) NOT NULL, - revfqdn VARCHAR2(512) NOT NULL, - fqdnhash VARCHAR2(512), - ttl NUMBER(10,0) NOT NULL, - type VARCHAR2(32), - content VARCHAR2(2048), - auth NUMBER(1,0) DEFAULT 1 NOT NULL, - CONSTRAINT chk_records_fqdn CHECK (fqdn = lower(fqdn)), - CONSTRAINT chk_records_ttl CHECK (ttl BETWEEN 0 AND 4294967295), - CONSTRAINT chk_records_type CHECK (type = upper(type)), - CONSTRAINT unq_records_zntc UNIQUE (zone_id, fqdn, type, content), - CONSTRAINT chk_records_tc CHECK ( - content IS NOT NULL OR - type IN('NS', 'CNAME') OR - type IS NULL - ), - CONSTRAINT chk_records_auth CHECK (auth IN (0, 1)) -); - -CREATE INDEX records_zone_id_ind ON Records (zone_id); -CREATE INDEX records_revfqdn_ind ON Records (zone_id, revfqdn); -CREATE INDEX records_fqdnhash_ind ON Records (zone_id, fqdnhash); -CREATE INDEX records_last_change_ind ON Records (last_change); - --- Only one SOA and NSEC3PARAM record per zone -CREATE UNIQUE INDEX records_zonesoa_unq_ind ON Records ( - CASE - WHEN type IN ('SOA', 'NSEC3PARAM') THEN zone_id - ELSE NULL - END, - CASE - WHEN type IN ('SOA', 'NSEC3PARAM') THEN type - ELSE NULL - END -); - - -CREATE FUNCTION label_reverse (dnsname IN VARCHAR2) RETURN VARCHAR2 AS - pattern VARCHAR2(32) := '[^.]+'; - match BINARY_INTEGER := 1; - label VARCHAR2(63); - out_dnsname VARCHAR2(512); -BEGIN - label := REGEXP_SUBSTR(dnsname, pattern, 1, match); - match := match + 1; - out_dnsname := label; - LOOP - label := REGEXP_SUBSTR(dnsname, pattern, 1, match); - EXIT WHEN label IS NULL; - out_dnsname := label || ' ' || out_dnsname; - match := match + 1; - END LOOP; - RETURN(out_dnsname); -END; -/ - -SHOW ERRORS - -CREATE FUNCTION dnsname_to_raw (in_dnsname IN VARCHAR2) RETURN RAW AS - dnsname VARCHAR2(512) := LOWER(in_dnsname); - rawname RAW(512); - - lpos BINARY_INTEGER := 1; - rpos BINARY_INTEGER; - label VARCHAR2(63); - - TYPE convarray IS VARRAY(64) OF RAW(1); - byteval convarray := convarray( - '00', '01', '02', '03', '04', '05', '06', '07', - '08', '09', '0A', '0B', '0C', '0D', '0E', '0F', - '10', '11', '12', '13', '14', '15', '16', '17', - '18', '19', '1A', '1B', '1C', '1D', '1E', '1F', - '20', '21', '22', '23', '24', '25', '26', '27', - '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', - '30', '31', '32', '33', '34', '35', '36', '37', - '38', '39', '3A', '3B', '3C', '3D', '3E', '3F' - ); -BEGIN - IF dnsname IS NULL THEN - RETURN('00'); - END IF; - - WHILE lpos <= LENGTH(dnsname) LOOP - rpos := INSTR(dnsname, '.', lpos); - IF rpos = 0 THEN - rpos := LENGTH(dnsname) + 1; - END IF; - label := SUBSTR(dnsname, lpos, rpos - lpos); - rawname := UTL_RAW.CONCAT( - rawname, - byteval(LENGTH(label) + 1), - UTL_I18N.STRING_TO_RAW(label, 'US7ASCII') - ); - lpos := rpos + 1; - END LOOP; - - IF rpos = LENGTH(dnsname) THEN - rawname := UTL_RAW.CONCAT(rawname, '00'); - END IF; - - RETURN(rawname); -END; -/ - -SHOW ERRORS - --- This is clearly terrible, though it appears to work. --- For real deployment, you could upload the dnsjava --- library into your database and use its facilities. -CREATE FUNCTION base32hex_encode ( - in_string RAW -) RETURN VARCHAR2 AS - off BINARY_INTEGER := 1; - out_string VARCHAR2(6554); - sub RAW(5); - num INTEGER; - TYPE convarray IS VARRAY(32) OF VARCHAR2(1); - digit convarray := convarray( - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v' - ); -BEGIN - - WHILE off + 4 <= UTL_RAW.LENGTH(in_string) LOOP - sub := UTL_RAW.SUBSTR(in_string, off, 2); - num := TO_NUMBER(sub, 'XXXX'); - out_string := out_string - || digit(FLOOR(num / 2048) + 1) - || digit(FLOOR(MOD(num / 64, 32)) + 1) - || digit(FLOOR(MOD(num / 2, 32)) + 1); - sub := UTL_RAW.SUBSTR(in_string, off + 1, 3); - num := TO_NUMBER(sub, 'XXXXXX'); - out_string := out_string - || digit(FLOOR(MOD(num / 4096, 32)) + 1) - || digit(FLOOR(MOD(num / 128, 32)) + 1) - || digit(FLOOR(MOD(num / 4, 32)) + 1); - sub := UTL_RAW.SUBSTR(in_string, off + 3, 2); - num := TO_NUMBER(sub, 'XXXX'); - out_string := out_string - || digit(FLOOR(MOD(num / 32, 32)) + 1) - || digit(FLOOR(MOD(num, 32)) + 1); - off := off + 5; - END LOOP; - - IF off <= UTL_RAW.LENGTH(in_string) THEN - sub := UTL_RAW.SUBSTR(in_string, off); - CASE UTL_RAW.LENGTH(sub) - WHEN 1 THEN - num := TO_NUMBER(sub, 'XX'); - out_string := out_string - || digit(FLOOR(num / 8) + 1) - || digit(FLOOR(MOD(num, 8)) * 4 + 1); - WHEN 2 THEN - num := TO_NUMBER(sub, 'XXXX'); - out_string := out_string - || digit(FLOOR(num / 2048) + 1) - || digit(FLOOR(MOD(num / 64, 32)) + 1) - || digit(FLOOR(MOD(num / 2, 32)) + 1) - || digit(FLOOR(MOD(num, 2)) * 16 + 1); - WHEN 3 THEN - num := TO_NUMBER(sub, 'XXXXXX'); - out_string := out_string - || digit(FLOOR(num / 524288) + 1) - || digit(FLOOR(MOD(num / 16384, 32)) + 1) - || digit(FLOOR(MOD(num / 512, 32)) + 1) - || digit(FLOOR(MOD(num / 16, 32)) + 1) - || digit(FLOOR(MOD(num, 16)) * 2 + 1); - WHEN 4 THEN - num := TO_NUMBER(sub, 'XXXXXXXX'); - out_string := out_string - || digit(FLOOR(num / 134217728) + 1) - || digit(FLOOR(MOD(num / 4194304, 32)) + 1) - || digit(FLOOR(MOD(num / 131072, 32)) + 1) - || digit(FLOOR(MOD(num / 4096, 32)) + 1) - || digit(FLOOR(MOD(num / 128, 32)) + 1) - || digit(FLOOR(MOD(num / 4, 32)) + 1) - || digit(FLOOR(MOD(num, 4)) * 8 + 1); - END CASE; - END IF; - - RETURN(out_string); -END; -/ - -SHOW ERRORS - -CREATE FUNCTION dnsname_to_hashname ( - in_dnsname IN VARCHAR2, - salt RAW, - itercnt BINARY_INTEGER -) RETURN VARCHAR2 AS - rawname RAW(512) := dnsname_to_raw(RTRIM(in_dnsname, '.') || '.'); - rawsalt RAW(32) := salt; - hashname RAW(64); - iter BINARY_INTEGER := 0; -BEGIN - hashname := UTL_RAW.CONCAT(rawname, rawsalt); - hashname := DBMS_CRYPTO.HASH(hashname, DBMS_CRYPTO.HASH_SH1); - WHILE iter < itercnt LOOP - hashname := UTL_RAW.CONCAT(hashname, rawsalt); - hashname := DBMS_CRYPTO.HASH(hashname, DBMS_CRYPTO.HASH_SH1); - iter := iter + 1; - END LOOP; - RETURN(base32hex_encode(hashname)); -END; -/ - -SHOW ERRORS - -CREATE PROCEDURE get_canonical_prev_next ( - in_zone_id INTEGER, - in_fqdn VARCHAR2, - out_prev OUT VARCHAR2, - out_next OUT VARCHAR2 -) AS -BEGIN - SELECT * INTO out_prev - FROM ( - SELECT fqdn - FROM Records - WHERE zone_id = in_zone_id - AND revfqdn <= label_reverse(LOWER(in_fqdn)) - AND auth = 1 - ORDER BY revfqdn DESC - ) WHERE ROWNUM = 1; - - BEGIN - SELECT * INTO out_next - FROM ( - SELECT fqdn - FROM Records - WHERE zone_id = in_zone_id - AND revfqdn > label_reverse(LOWER(in_fqdn)) - AND auth = 1 - ORDER BY revfqdn ASC - ) WHERE ROWNUM = 1; - EXCEPTION - WHEN NO_DATA_FOUND THEN - SELECT name INTO out_next - FROM Zones - WHERE id = in_zone_id; - END; -END; -/ - -SHOW ERRORS - -CREATE PROCEDURE get_hashed_prev_next ( - in_zone_id INTEGER, - in_fqdnhash VARCHAR2, - out_fqdn OUT VARCHAR2, - out_prev OUT VARCHAR2, - out_next OUT VARCHAR2 -) AS -BEGIN - BEGIN - SELECT * INTO out_prev, out_fqdn - FROM ( - SELECT fqdnhash, fqdn - FROM Records - WHERE zone_id = in_zone_id - AND fqdnhash <= in_fqdnhash - AND auth = 1 - ORDER BY fqdnhash DESC - ) WHERE ROWNUM = 1; - EXCEPTION - WHEN NO_DATA_FOUND THEN - SELECT * INTO out_prev, out_fqdn - FROM ( - SELECT fqdnhash, fqdn - FROM Records - WHERE zone_id = in_zone_id - AND auth = 1 - ORDER BY fqdnhash DESC - ) WHERE ROWNUM = 1; - END; - - BEGIN - SELECT * INTO out_next - FROM ( - SELECT fqdnhash - FROM Records - WHERE zone_id = in_zone_id - AND fqdnhash > in_fqdnhash - AND auth = 1 - ORDER BY fqdnhash ASC - ) WHERE ROWNUM = 1; - EXCEPTION - WHEN NO_DATA_FOUND THEN - SELECT * INTO out_next - FROM ( - SELECT fqdnhash - FROM Records - WHERE zone_id = in_zone_id - AND auth = 1 - ORDER BY fqdnhash ASC - ) WHERE ROWNUM = 1; - END; -END; -/ - -SHOW ERRORS - -CREATE TRIGGER records_fill_columns - BEFORE INSERT OR UPDATE ON Records - FOR EACH ROW -BEGIN - -- 'www.site.example' => 'example site www' for NSEC ordering - :NEW.revfqdn := label_reverse(LOWER(:NEW.fqdn)); - - -- Hash the FQDN for NSEC3 ordering - IF :NEW.type != 'RRSIG' THEN - DECLARE - nsec3param_string VARCHAR2(512); - nsec3param_pattern VARCHAR2(512) := '^(\d+) +(\d+) +(\d+) +([0-9A-Fa-f]+)'; - hashalgo BINARY_INTEGER; - itcount BINARY_INTEGER; - salt RAW(256); - BEGIN - SELECT meta_content INTO nsec3param_string - FROM ZoneMetadata - WHERE zone_id = :NEW.zone_id - AND meta_type = 'NSEC3PARAM'; - hashalgo := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 1); - IF hashalgo != 1 THEN - RAISE_APPLICATION_ERROR(-20000, 'NSEC3 hash is not SHA-1'); - END IF; - itcount := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 3); - salt := REGEXP_SUBSTR(nsec3param_string, nsec3param_pattern, 1, 1, '', 4); - :NEW.fqdnhash := dnsname_to_hashname(:NEW.fqdn, salt, itcount); - EXCEPTION - WHEN NO_DATA_FOUND THEN - NULL; - END; - END IF; -END; -/ - -SHOW ERRORS - -CREATE TRIGGER parse_zone_defining_records - AFTER INSERT OR UPDATE ON Records - FOR EACH ROW - WHEN (NEW.type IN ('SOA')) -BEGIN - CASE :NEW.type - WHEN 'SOA' THEN - DECLARE - pattern VARCHAR2(32) := '^[^ ]+ +[^ ]+ +(\d+) +(\d+)'; - serial_str VARCHAR2(32) := REGEXP_SUBSTR(:NEW.content, pattern, 1, 1, '', 1); - serial_num NUMBER(10,0) := TO_NUMBER(serial_str); - refresh_str VARCHAR2(32) := REGEXP_SUBSTR(:NEW.content, pattern, 1, 1, '', 2); - BEGIN - IF serial_num = 0 THEN - SELECT NVL(max(last_change), 0) INTO serial_num - FROM Records - WHERE zone_id = :NEW.zone_id; - END IF; - - UPDATE Zones - SET serial = serial_num, refresh = TO_NUMBER(refresh_str) - WHERE id = :NEW.zone_id; - END; - END CASE; -END; -/ - -SHOW ERRORS - --- End of schema --- vi: set sw=2 et : -- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index c1bbed005..32fd84538 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -268,10 +268,6 @@ pdns_server_SOURCES += ssqlite3.cc ssqlite3.hh pdns_server_LDADD += $(SQLITE3_LIBS) endif -if ORACLE -pdns_server_LDADD += $(ORACLE_LIBS) -endif - if PKCS11 pdns_server_SOURCES += pkcs11signers.cc pkcs11signers.hh pdns_server_LDADD += $(P11KIT1_LIBS) @@ -370,10 +366,6 @@ pdnsutil_SOURCES += ssqlite3.cc ssqlite3.hh pdnsutil_LDADD += $(SQLITE3_LIBS) endif -if ORACLE -pdnsutil_LDADD += $(ORACLE_LIBS) -endif - if PKCS11 pdnsutil_SOURCES += pkcs11signers.cc pkcs11signers.hh pdnsutil_LDADD += $(P11KIT1_LIBS) diff --git a/pdns/zone2json.cc b/pdns/zone2json.cc index 8a01a2115..512fe87c1 100644 --- a/pdns/zone2json.cc +++ b/pdns/zone2json.cc @@ -80,7 +80,7 @@ static Json::object emitRecord(const string& zoneName, const DNSName &DNSqname, } /* 2 modes of operation, either --named or --zone (the latter needs $ORIGIN) - 2 further modes: --mysql or --oracle + 1 further mode: --mysql */ ArgvMap &arg() diff --git a/pdns/zone2sql.cc b/pdns/zone2sql.cc index a87abadd1..2bcb7df14 100644 --- a/pdns/zone2sql.cc +++ b/pdns/zone2sql.cc @@ -50,7 +50,7 @@ StatBag S; -enum dbmode_t {MYSQL, GORACLE, POSTGRES, SQLITE, MYDNS, ORACLE}; +enum dbmode_t {MYSQL, POSTGRES, SQLITE, MYDNS}; static dbmode_t g_mode; static bool g_intransaction; static int g_numRecords; @@ -71,7 +71,7 @@ static string stripDotContent(const string& content) static string sqlstr(const string &name) { - if(g_mode == SQLITE || g_mode==GORACLE || g_mode==ORACLE) + if(g_mode == SQLITE) return "'"+boost::replace_all_copy(name, "'", "''")+"'"; string a; @@ -107,7 +107,7 @@ static void startNewTransaction() if(g_mode == MYSQL || g_mode == MYDNS) cout<<"BEGIN;"< *master if(g_mode==POSTGRES || g_mode==MYSQL || g_mode==SQLITE) { cout<<"insert into domains (name,type) values ("< *master else cout<<"insert into domains (name,type,master) values ("< goracle.log - echo "START ../modules/goraclebackend/schema.goracle.sql;" | $SQLPLUS -S $GORACLEUSER/$GORACLEPASSWD@xe >> goracle.log - tosql goracle | $SQLPLUS -S $GORACLEUSER/$GORACLEPASSWD@xe >> goracle.log - - cat > pdns-goracle.conf << __EOF__ -module-dir=./modules -launch=goracle -goracle-home=$ORACLE_HOME -goracle-sid=$ORACLE_SID -goracle-nls-lang=$NLS_LANG - -goracle-tnsname=xe -goracle-user=$GORACLEUSER -goracle-password=$GORACLEPASSWD -__EOF__ - - gsql_master goracle nodyndns - ;; - - *) - nocontext=yes -esac diff --git a/regression-tests/backends/goracle-slave b/regression-tests/backends/goracle-slave deleted file mode 100644 index 45549ec25..000000000 --- a/regression-tests/backends/goracle-slave +++ /dev/null @@ -1,68 +0,0 @@ -if [ "x$NLS_LANG" = "x" ]; then - NLS_LANG="AMERICAN_AMERICA.AL32UTF8" -fi - context=${context}-presigned-goracle - [ -z "$GORACLE2USER" ] && GORACLE2USER=pdns2 - [ -z "$GORACLE2PASSWD" ] && GORACLE2PASSWD=pdns - - echo "START ../modules/goraclebackend/drop-schema.goracle.sql;" | sqlplus -S $GORACLE2USER/$GORACLE2PASSWD@xe > goracle2.log - echo "START ../modules/goraclebackend/schema.goracle.sql;" | sqlplus -S $GORACLE2USER/$GORACLE2PASSWD@xe >> goracle2.log - - cat > pdns-goracle2.conf << __EOF__ -module-dir=./modules -launch=goracle -goracle-home=$ORACLE_HOME -goracle-sid=$ORACLE_SID -goracle-nls-lang=$NLS_LANG - -goracle-tnsname=xe -goracle-user=$GORACLE2USER -goracle-password=$GORACLE2PASSWD -__EOF__ - - if [[ $context != *nodnssec* ]] - then - echo "goracle-dnssec" >> pdns-goracle2.conf - fi - - for zone in $(grep 'zone ' named.conf | cut -f2 -d\" | perl -e 'print reverse ') - do - echo "INSERT INTO domains (id, name, type, master) VALUES(domains_id_sequence.nextval, '$zone', 'SLAVE', '127.0.0.1:$port');" | sqlplus -S $GORACLE2USER/$GORACLE2PASSWD@xe >> goracle2.log - done - - $PDNSUTIL --config-dir=. --config-name=goracle2 import-tsig-key test $ALGORITHM $KEY - $PDNSUTIL --config-dir=. --config-name=goracle2 activate-tsig-key tsig.com test slave - if [[ $skipreasons != *nolua* ]] - then - $PDNSUTIL --config-dir=. --config-name=goracle2 set-meta stest.com AXFR-SOURCE 127.0.0.2 - fi - - port=$((port+100)) - - $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \ - --config-name=goracle2 --socket-dir=./ --no-shuffle \ - --slave --retrieval-threads=4 \ - --slave-cycle-interval=300 --dname-processing & - - echo 'waiting for zones to be slaved' - loopcount=0 - while [ $loopcount -lt 30 ] - do - sleep 5 - todo=$(sqlplus -S $GORACLE2USER/$GORACLE2PASSWD@xe << __EOF__ -set pagesize 0 feedback off verify off heading off echo off; -SELECT COUNT(id) FROM domains WHERE last_check IS NULL; -exit; -__EOF__ -) - if [ $todo = 0 ] - then - break - fi - let loopcount=loopcount+1 - done - if [ $todo -ne 0 ] - then - echo "AXFR FAILED" >> failed_tests - exit - fi diff --git a/regression-tests/backends/oracle-master b/regression-tests/backends/oracle-master deleted file mode 100644 index 141f0f37b..000000000 --- a/regression-tests/backends/oracle-master +++ /dev/null @@ -1,70 +0,0 @@ -case $context in - oracle-nodnssec | oracle | oracle-nsec3) - [ -z "$ORACLEUSER" ] && ORACLEUSER=pdns - [ -z "$ORACLEPASSWD" ] && ORACLEPASSWD=pdns - - echo "START ../modules/oraclebackend/drop-schema.oracle.sql;" | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe > oracle.log - echo "START ../modules/oraclebackend/schema.oracle.sql;" | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe >> oracle.log - ../pdns/zone2sql --oracle | grep -v 'INSERT INTO Records' | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe >> oracle.log - ../pdns/zone2sql --oracle | grep " 'SOA', " | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe >> oracle.log - - cat > pdns-oracle.conf << __EOF__ -module-dir=./modules -launch=oracle -oracle-home=$ORACLE_HOME -oracle-sid=$ORACLE_SID -oracle-nls-lang=$NLS_LANG - -oracle-pool-database=xe -oracle-pool-username=$ORACLEUSER -oracle-pool-password=$ORACLEPASSWD -oracle-master-database=xe -oracle-master-username=$ORACLEUSER -oracle-master-password=$ORACLEPASSWD -__EOF__ - - if [ $context != oracle-nodnssec ] - then - echo "oracle-dnssec" >> pdns-oracle.conf - fi - - if [ $context != oracle-nodnssec ] - then - for zone in $(grep 'zone ' named.conf | cut -f2 -d\") - do - securezone $zone oracle - if [ $context = oracle-nsec3 ] - then - $PDNSUTIL --config-dir=. --config-name=oracle set-nsec3 $zone "1 0 1 abcd" 2>&1 - fi - done - fi - - echo "TRUNCATE TABLE records;" | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe >> oracle.log - ../pdns/zone2sql --oracle | grep -v 'INSERT INTO Zones' | sqlplus -S $ORACLEUSER/$ORACLEPASSWD@xe >> oracle.log - - $PDNSUTIL --config-dir=. --config-name=oracle import-tsig-key test $ALGORITHM $KEY - $PDNSUTIL --config-dir=. --config-name=oracle activate-tsig-key tsig.com test master - - $RUNWRAPPER $PDNS --daemon=no --local-address=$address --local-port=$port --config-dir=. \ - --config-name=oracle --socket-dir=./ --no-shuffle \ - --query-logging \ - --cache-ttl=$cachettl --dname-processing $lua_prequery & - - if [ $context = oracle-nsec3 ] - then - skipreasons="nodyndns oracle-nsec3 oracle-master-nsec3" - extracontexts="dnssec nsec3" - elif [ $context = oracle-nodnssec ] - then - skipreasons="nodyndns nodnssec" - else - skipreasons="nodyndns oracle-nsec oracle-master-nsec" - extracontexts="dnssec" - fi - skipreasons="$skipreasons noent noaxfr" # TODO add ent support to oracle backend - ;; - - *) - nocontext=yes -esac diff --git a/regression-tests/backends/oracle-slave b/regression-tests/backends/oracle-slave deleted file mode 100644 index d851043a3..000000000 --- a/regression-tests/backends/oracle-slave +++ /dev/null @@ -1,76 +0,0 @@ - context=${context}-presigned-oracle - [ -z "$ORACLE2USER" ] && ORACLE2USER=pdns2 - [ -z "$ORACLE2PASSWD" ] && ORACLE2PASSWD=pdns - - echo "START ../modules/oraclebackend/drop-schema.oracle.sql;" | sqlplus -S $ORACLE2USER/$ORACLE2PASSWD@xe > oracle2.log - echo "START ../modules/oraclebackend/schema.oracle.sql;" | sqlplus -S $ORACLE2USER/$ORACLE2PASSWD@xe >> oracle2.log - - cat > pdns-oracle2.conf << __EOF__ -module-dir=./modules -launch=oracle -oracle-home=$ORACLE_HOME -oracle-sid=$ORACLE_SID -oracle-nls-lang=$NLS_LANG - -oracle-pool-database=xe -oracle-pool-username=$ORACLE2USER -oracle-pool-password=$ORACLE2PASSWD -oracle-master-database=xe -oracle-master-username=$ORACLE2USER -oracle-master-password=$ORACLE2PASSWD -oracle-dnssec -__EOF__ - - for zone in $(grep 'zone ' named.conf | cut -f2 -d\" | perl -e 'print reverse ') - do - echo "INSERT ALL INTO zones (id, name, type) VALUES (zones_id_seq.nextval, name, 'SLAVE') INTO zonemasters (zone_id, master) VALUES (zones_id_seq.nextval, master) SELECT '$zone' AS name, '127.0.0.1:$port' AS master FROM dual;" | sqlplus -S $ORACLE2USER/$ORACLE2PASSWD@xe >> oracle2.log - done - - $PDNSUTIL --config-dir=. --config-name=oracle2 import-tsig-key test $ALGORITHM $KEY - $PDNSUTIL --config-dir=. --config-name=oracle2 activate-tsig-key tsig.com test slave - - set +e - echo $skipreasons | grep -q nolua - if [ $? -ne 0 ] - then - $PDNSUTIL --config-dir=. --config-name=oracle2 set-meta stest.com AXFR-SOURCE 127.0.0.2 - fi - set -e - - port=$((port+100)) - - $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \ - --config-name=oracle2 --socket-dir=./ --no-shuffle \ - --slave --retrieval-threads=4 \ - --slave-cycle-interval=300 --dname-processing & - echo 'waiting for zones to be slaved' - - loopcount=0 - while [ $loopcount -lt 40 ] - do - sleep 5 - todo=$(sqlplus -S $ORACLE2USER/$ORACLE2PASSWD@xe << __EOF__ -set pagesize 0 feedback off verify off heading off echo off; -SELECT COUNT(id) FROM zones WHERE last_check IS NULL; -exit; -__EOF__ -) - if [ $todo = 0 ] - then - break - fi - let loopcount=loopcount+1 - done - if [ $todo -ne 0 ] - then - echo "AXFR FAILED" >> failed_tests - fi - - if [[ $extracontexts = *nsec3* ]] - then - skipreasons="$skipreasons oracle-nsec3 oracle-slave-nsec3" - elif [[ $extracontexts = *dnssec* ]] - then - skipreasons="$skipreasons oracle-nsec oracle-slave-nsec" - fi - skipreasons="$skipreasons noent noaxfr" # TODO add ent support to oracle backend diff --git a/regression-tests/modules/libgoraclebackend.so b/regression-tests/modules/libgoraclebackend.so deleted file mode 120000 index 30b9d9653..000000000 --- a/regression-tests/modules/libgoraclebackend.so +++ /dev/null @@ -1 +0,0 @@ -../../modules/goraclebackend/.libs/libgoraclebackend.so \ No newline at end of file diff --git a/regression-tests/modules/liboraclebackend.so b/regression-tests/modules/liboraclebackend.so deleted file mode 120000 index e7aefdca8..000000000 --- a/regression-tests/modules/liboraclebackend.so +++ /dev/null @@ -1 +0,0 @@ -../../modules/oraclebackend/.libs/liboraclebackend.so \ No newline at end of file diff --git a/regression-tests/start-test-stop b/regression-tests/start-test-stop index 06431b762..389f42e6f 100755 --- a/regression-tests/start-test-stop +++ b/regression-tests/start-test-stop @@ -46,14 +46,12 @@ bind bind-dnssec bind-dnssec-nsec3 bind-dnssec-nsec3-optout bind-dnssec-nsec3-na geoip geoip-nsec3-narrow gmysql-nodnssec gmysql gmysql-nsec3 gmysql-nsec3-optout gmysql-nsec3-narrow godbc_mssql-nodnssec godbc_mssql godbc_mssql-nsec3 godbc_mssql-nsec3-optout godbc_mssql-nsec3-narrow -goracle-nodnssec goracle goracle-nsec3 goracle-nsec3-optout goracle-nsec3-narrow godbc_sqlite3-nodnssec godbc_sqlite3 godbc_sqlite3-nsec3 godbc_sqlite3-nsec3-optout godbc_sqlite3-narrow gpgsql-nodnssec gpgsql gpgsql-nsec3 gpgsql-nsec3-optout gpgsql-nsec3-narrow gsqlite3-nodnssec gsqlite3 gsqlite3-nsec3 gsqlite3-nsec3-optout gsqlite3-nsec3-narrow lmdb-nodnssec lmdb mydns opendbx-sqlite3 -oracle-nodnssec oracle oracle-nsec3 remotebackend-pipe remotebackend-unix remotebackend-http remotebackend-zeromq remotebackend-pipe-dnssec remotebackend-unix-dnssec remotebackend-http-dnssec remotebackend-zeromq-dnssec #remotebackend-pipe-nsec3 remotebackend-unix-nsec3 remotebackend-http-nsec3