From: Kees Monshouwer Date: Fri, 18 Oct 2019 10:51:02 +0000 (+0200) Subject: auth: remove opendbx backend X-Git-Tag: auth-4.3.0-alpha1~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8435%2Fhead;p=thirdparty%2Fpdns.git auth: remove opendbx backend --- diff --git a/build-scripts/test-auth b/build-scripts/test-auth index 8ea5de671d..095d6a8ee0 100755 --- a/build-scripts/test-auth +++ b/build-scripts/test-auth @@ -90,8 +90,6 @@ if [ -z "$context" ]; then ./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both || EXITCODE=1 ./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow || EXITCODE=1 - ./timestamp ./start-test-stop 5300 opendbx-sqlite3 || EXITCODE=1 - ./timestamp timeout 120s ./start-test-stop 5300 remotebackend-pipe || EXITCODE=1 ./timestamp timeout 120s ./start-test-stop 5300 remotebackend-pipe-dnssec || EXITCODE=1 ./timestamp timeout 120s ./start-test-stop 5300 remotebackend-unix || EXITCODE=1 diff --git a/build-scripts/travis.sh b/build-scripts/travis.sh index 5ff53e2cbe..35fbfebaa2 100755 --- a/build-scripts/travis.sh +++ b/build-scripts/travis.sh @@ -224,11 +224,6 @@ install_auth() { run "sudo apt-get -qq --no-install-recommends install \ liblmdb-dev" - # opendbx-backend - run "sudo apt-get -qq --no-install-recommends install \ - libopendbx1-dev \ - libopendbx1-sqlite3" - # remote-backend build requirements run "sudo apt-get -qq --no-install-recommends install \ libzmq3-dev" @@ -393,7 +388,7 @@ build_auth() { run "autoreconf -vi" run "./configure \ ${sanitizerflags} \ - --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 lmdb opendbx pipe random remote tinydns godbc lua2' \ + --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 lmdb pipe random remote tinydns godbc lua2' \ --with-modules='' \ --with-sqlite3 \ --with-libsodium \ @@ -531,8 +526,6 @@ test_auth() { # run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-optout-both" run "./timestamp ./start-test-stop 5300 gsqlite3-nsec3-narrow" - run "./timestamp ./start-test-stop 5300 opendbx-sqlite3" - run "./timestamp ./start-test-stop 5300 remotebackend-pipe" run "./timestamp ./start-test-stop 5300 remotebackend-pipe-dnssec" #run "./timestamp ./start-test-stop 5300 remotebackend-unix" diff --git a/builder-support/debian/authoritative/debian-buster/config/opendbx.conf b/builder-support/debian/authoritative/debian-buster/config/opendbx.conf deleted file mode 100644 index 3de13a9980..0000000000 --- a/builder-support/debian/authoritative/debian-buster/config/opendbx.conf +++ /dev/null @@ -1,22 +0,0 @@ -# OpenDBX Configuration -# -# The backend to use -# opendbx-backend= -# -# The database host to read from -# opendbx-host-read= -# -# The database host to write to -# opendbx-host-write= -# -# The port on which the database hosts listen -# opendbx-port= -# -# The name of the database -# opendbx-database= -# -# The username to connect to the database -# opendbx-username= -# -# The password to connect to the database -# opendbx-password diff --git a/builder-support/debian/authoritative/debian-buster/control b/builder-support/debian/authoritative/debian-buster/control index 3b79ddea5c..533352390f 100644 --- a/builder-support/debian/authoritative/debian-buster/control +++ b/builder-support/debian/authoritative/debian-buster/control @@ -27,7 +27,6 @@ Build-Depends: autoconf, liblmdb-dev, libluajit-5.1-dev, libmaxminddb-dev, - libopendbx1-dev, libp11-kit-dev, libpq-dev, libprotobuf-dev, @@ -257,22 +256,6 @@ Description: remote backend for PowerDNS This package contains the remote backend for PowerDNS. It is suitable for serving data acquired from an AF_UNIX, pipe, or HTTP connector. -Package: pdns-backend-opendbx -Architecture: any -Depends: pdns-server (= ${binary:Version}), - ${misc:Depends}, - ${shlibs:Depends} -Provides: pdns-backend -Description: OpenDBX backend for PowerDNS - PowerDNS is a versatile nameserver which supports a large number - of different backends ranging from simple zonefiles to relational - databases and load balancing/failover algorithms. - PowerDNS tries to emphasize speed and security. - . - This package contains the OpenDBX backend for PowerDNS. Please install - the libopendbx1-DATABASE package to allow OpenDBX to connect to - the chosen database. - Package: pdns-backend-tinydns Architecture: any Depends: pdns-server (= ${binary:Version}), diff --git a/builder-support/debian/authoritative/debian-buster/copyright b/builder-support/debian/authoritative/debian-buster/copyright index b3279e931f..c86a9f1881 100644 --- a/builder-support/debian/authoritative/debian-buster/copyright +++ b/builder-support/debian/authoritative/debian-buster/copyright @@ -52,10 +52,6 @@ Files: modules/ldapbackend/* pdns/zone2ldap.cc Copyright: 2003-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception -Files: modules/opendbxbackend/* -Copyright: 2005-2007 Norbert Sendetzky -License: GPL-2 with OpenSSL Exception - Files: ext/yahttp/* Copyright: 2014 Aki Tuomi License: Expat diff --git a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.examples b/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.examples deleted file mode 100644 index 1923d59a98..0000000000 --- a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.examples +++ /dev/null @@ -1 +0,0 @@ -debian/config/opendbx.conf diff --git a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.install b/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.install deleted file mode 100644 index bc796d1b09..0000000000 --- a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/pdns/libopendbxbackend.so* diff --git a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.postinst b/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.postinst deleted file mode 100644 index 1beff20037..0000000000 --- a/builder-support/debian/authoritative/debian-buster/pdns-backend-opendbx.postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -dpkg-trigger pdns-server - -#DEBHELPER# - -exit 0 diff --git a/builder-support/debian/authoritative/debian-buster/rules b/builder-support/debian/authoritative/debian-buster/rules index 676335dee4..fd44e41942 100755 --- a/builder-support/debian/authoritative/debian-buster/rules +++ b/builder-support/debian/authoritative/debian-buster/rules @@ -9,7 +9,7 @@ CXXFLAGS += -Wall export DEB_BUILD_MAINT_OPTIONS = hardening=+all # Backends -backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua2 remote random opendbx tinydns +backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua2 remote random tinydns # Disable systemd integration on non-linux archs ifeq ($(DEB_HOST_ARCH_OS),linux) diff --git a/builder-support/debian/authoritative/debian-jessie/config/opendbx.conf b/builder-support/debian/authoritative/debian-jessie/config/opendbx.conf deleted file mode 100644 index 3de13a9980..0000000000 --- a/builder-support/debian/authoritative/debian-jessie/config/opendbx.conf +++ /dev/null @@ -1,22 +0,0 @@ -# OpenDBX Configuration -# -# The backend to use -# opendbx-backend= -# -# The database host to read from -# opendbx-host-read= -# -# The database host to write to -# opendbx-host-write= -# -# The port on which the database hosts listen -# opendbx-port= -# -# The name of the database -# opendbx-database= -# -# The username to connect to the database -# opendbx-username= -# -# The password to connect to the database -# opendbx-password diff --git a/builder-support/debian/authoritative/debian-jessie/control b/builder-support/debian/authoritative/debian-jessie/control index 0b3cf231f8..dad4154985 100644 --- a/builder-support/debian/authoritative/debian-jessie/control +++ b/builder-support/debian/authoritative/debian-jessie/control @@ -25,7 +25,6 @@ Build-Depends: autoconf, libldap2-dev, libluajit-5.1-dev, libmysqlclient-dev, - libopendbx1-dev, libp11-kit-dev, libpq-dev, libprotobuf-dev, @@ -255,22 +254,6 @@ Description: remote backend for PowerDNS This package contains the remote backend for PowerDNS. It is suitable for serving data acquired from an AF_UNIX, pipe, or HTTP connector. -Package: pdns-backend-opendbx -Architecture: any -Depends: pdns-server (= ${binary:Version}), - ${misc:Depends}, - ${shlibs:Depends} -Provides: pdns-backend -Description: OpenDBX backend for PowerDNS - PowerDNS is a versatile nameserver which supports a large number - of different backends ranging from simple zonefiles to relational - databases and load balancing/failover algorithms. - PowerDNS tries to emphasize speed and security. - . - This package contains the OpenDBX backend for PowerDNS. Please install - the libopendbx1-DATABASE package to allow OpenDBX to connect to - the chosen database. - Package: pdns-backend-tinydns Architecture: any Depends: pdns-server (= ${binary:Version}), diff --git a/builder-support/debian/authoritative/debian-jessie/copyright b/builder-support/debian/authoritative/debian-jessie/copyright index b3279e931f..c86a9f1881 100644 --- a/builder-support/debian/authoritative/debian-jessie/copyright +++ b/builder-support/debian/authoritative/debian-jessie/copyright @@ -52,10 +52,6 @@ Files: modules/ldapbackend/* pdns/zone2ldap.cc Copyright: 2003-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception -Files: modules/opendbxbackend/* -Copyright: 2005-2007 Norbert Sendetzky -License: GPL-2 with OpenSSL Exception - Files: ext/yahttp/* Copyright: 2014 Aki Tuomi License: Expat diff --git a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.examples b/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.examples deleted file mode 100644 index 1923d59a98..0000000000 --- a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.examples +++ /dev/null @@ -1 +0,0 @@ -debian/config/opendbx.conf diff --git a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.install b/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.install deleted file mode 100644 index bc796d1b09..0000000000 --- a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/pdns/libopendbxbackend.so* diff --git a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.postinst b/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.postinst deleted file mode 100644 index 1beff20037..0000000000 --- a/builder-support/debian/authoritative/debian-jessie/pdns-backend-opendbx.postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -dpkg-trigger pdns-server - -#DEBHELPER# - -exit 0 diff --git a/builder-support/debian/authoritative/debian-jessie/rules b/builder-support/debian/authoritative/debian-jessie/rules index 6e2930a65a..95a38b4d16 100755 --- a/builder-support/debian/authoritative/debian-jessie/rules +++ b/builder-support/debian/authoritative/debian-jessie/rules @@ -4,7 +4,7 @@ DEB_HOST_ARCH_BITS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) # Backends -backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua2 remote random opendbx tinydns +backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua2 remote random tinydns # Disable systemd integration on non-linux archs ifeq ($(DEB_HOST_ARCH_OS),linux) diff --git a/builder-support/debian/authoritative/debian-stretch/config/opendbx.conf b/builder-support/debian/authoritative/debian-stretch/config/opendbx.conf deleted file mode 100644 index 3de13a9980..0000000000 --- a/builder-support/debian/authoritative/debian-stretch/config/opendbx.conf +++ /dev/null @@ -1,22 +0,0 @@ -# OpenDBX Configuration -# -# The backend to use -# opendbx-backend= -# -# The database host to read from -# opendbx-host-read= -# -# The database host to write to -# opendbx-host-write= -# -# The port on which the database hosts listen -# opendbx-port= -# -# The name of the database -# opendbx-database= -# -# The username to connect to the database -# opendbx-username= -# -# The password to connect to the database -# opendbx-password diff --git a/builder-support/debian/authoritative/debian-stretch/control b/builder-support/debian/authoritative/debian-stretch/control index 3b79ddea5c..533352390f 100644 --- a/builder-support/debian/authoritative/debian-stretch/control +++ b/builder-support/debian/authoritative/debian-stretch/control @@ -27,7 +27,6 @@ Build-Depends: autoconf, liblmdb-dev, libluajit-5.1-dev, libmaxminddb-dev, - libopendbx1-dev, libp11-kit-dev, libpq-dev, libprotobuf-dev, @@ -257,22 +256,6 @@ Description: remote backend for PowerDNS This package contains the remote backend for PowerDNS. It is suitable for serving data acquired from an AF_UNIX, pipe, or HTTP connector. -Package: pdns-backend-opendbx -Architecture: any -Depends: pdns-server (= ${binary:Version}), - ${misc:Depends}, - ${shlibs:Depends} -Provides: pdns-backend -Description: OpenDBX backend for PowerDNS - PowerDNS is a versatile nameserver which supports a large number - of different backends ranging from simple zonefiles to relational - databases and load balancing/failover algorithms. - PowerDNS tries to emphasize speed and security. - . - This package contains the OpenDBX backend for PowerDNS. Please install - the libopendbx1-DATABASE package to allow OpenDBX to connect to - the chosen database. - Package: pdns-backend-tinydns Architecture: any Depends: pdns-server (= ${binary:Version}), diff --git a/builder-support/debian/authoritative/debian-stretch/copyright b/builder-support/debian/authoritative/debian-stretch/copyright index b3279e931f..c86a9f1881 100644 --- a/builder-support/debian/authoritative/debian-stretch/copyright +++ b/builder-support/debian/authoritative/debian-stretch/copyright @@ -52,10 +52,6 @@ Files: modules/ldapbackend/* pdns/zone2ldap.cc Copyright: 2003-2007 Norbert Sendetzky License: GPL-2 with OpenSSL Exception -Files: modules/opendbxbackend/* -Copyright: 2005-2007 Norbert Sendetzky -License: GPL-2 with OpenSSL Exception - Files: ext/yahttp/* Copyright: 2014 Aki Tuomi License: Expat diff --git a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.examples b/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.examples deleted file mode 100644 index 1923d59a98..0000000000 --- a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.examples +++ /dev/null @@ -1 +0,0 @@ -debian/config/opendbx.conf diff --git a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.install b/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.install deleted file mode 100644 index bc796d1b09..0000000000 --- a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/pdns/libopendbxbackend.so* diff --git a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.postinst b/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.postinst deleted file mode 100644 index 1beff20037..0000000000 --- a/builder-support/debian/authoritative/debian-stretch/pdns-backend-opendbx.postinst +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -dpkg-trigger pdns-server - -#DEBHELPER# - -exit 0 diff --git a/builder-support/debian/authoritative/debian-stretch/rules b/builder-support/debian/authoritative/debian-stretch/rules index bd01e6f600..20c8df6e6a 100755 --- a/builder-support/debian/authoritative/debian-stretch/rules +++ b/builder-support/debian/authoritative/debian-stretch/rules @@ -4,7 +4,7 @@ DEB_HOST_ARCH_BITS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS) DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) # Backends -backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua2 remote random opendbx tinydns +backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua2 remote random tinydns # Disable systemd integration on non-linux archs ifeq ($(DEB_HOST_ARCH_OS),linux) diff --git a/configure.ac b/configure.ac index eeec215237..6020a85cfe 100644 --- a/configure.ac +++ b/configure.ac @@ -191,9 +191,6 @@ for a in $modules $dynmodules; do PDNS_CHECK_LDAP needldap=yes ;; - opendbx) - PDNS_CHECK_OPENDBX - ;; remote) AS_IF([test "x$enable_unit_tests" = "xyes"], [PDNS_CHECK_CURL_PROGRAM] @@ -342,7 +339,6 @@ AC_CONFIG_FILES([ modules/ldapbackend/Makefile modules/lmdbbackend/Makefile modules/lua2backend/Makefile - modules/opendbxbackend/Makefile modules/pipebackend/Makefile modules/randombackend/Makefile modules/remotebackend/Makefile diff --git a/docs/backends/index.rst b/docs/backends/index.rst index 91060250f4..3cb14fd810 100644 --- a/docs/backends/index.rst +++ b/docs/backends/index.rst @@ -24,8 +24,6 @@ The following table describes the supported backends and some of their capabilit +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Lua2 ` | Yes | Yes | No | No | Yes | ``lua2`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ -| :doc:`OpenDBX ` | Yes | Yes | Yes | Yes | No | ``opendbx`` | -+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Pipe ` | Yes | No | No | No | Partial | ``pipe`` | +------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+ | :doc:`Random ` | Yes | No | No | No | Partial | ``random`` | @@ -52,7 +50,6 @@ These backends have :doc:`features unique ` to the generic SQL back ldap lmdb lua2 - opendbx pipe random remote diff --git a/docs/backends/opendbx.rst b/docs/backends/opendbx.rst deleted file mode 100644 index 768bc28367..0000000000 --- a/docs/backends/opendbx.rst +++ /dev/null @@ -1,832 +0,0 @@ -OpenDBX Backend -=============== - -* Native: Yes -* Master: Yes -* Slave: Yes -* Superslave: Yes -* Autoserial: Yes -* DNSSEC: No -* Disabled data: No -* Comments: No -* Module name: opendbx -* Launch name: ``opendbx`` - -The OpenDBX backend allows the authoritative server to connect to any -backend supported by -`OpenDBX `__. - -This document contains a subset of the `full -documentation `__ -supplied by the author Norbert Sendetzky . This module is fully -supported (and tested) by PowerDNS. - -The OpenDBX backend has a mechanism to connect different database -servers for read and write actions. - -The domains table for the opendbx backend has a "status" column, when -set to "A", the domain is considered active and is actually served. - -Settings --------- - -.. _setting-opendbx-backend: - -``opendbx-backend`` -^^^^^^^^^^^^^^^^^^^ - -Name of the backend used to connect to the database server. Currently -mysql, pgsql, sqlite, sqlite3 and sybase are available. Default=mysql. - -.. _setting-opendbx-host-read: - -``opendbx-host-read`` -^^^^^^^^^^^^^^^^^^^^^ - -One or more host names or IP addresses of the database servers. These -hosts will be used for retrieving the records via SELECT queries. -Default=127.0.0.1 - -.. _setting-opendbx-host-write: - -``opendbx-host-write`` -^^^^^^^^^^^^^^^^^^^^^^ - -One or more host names or IP addresses of the database servers. These -hosts will be used for INSERT/UPDATE statements (mostly used by -zonetransfers). Default=127.0.0.1 - -.. _setting-opendbx-port: - -``opendbx-port`` -^^^^^^^^^^^^^^^^ - -TCP/IP port number where the database server is listening to. Most -databases will use their default port if you leave this empty. - -.. _setting-opendbx-database: - -``opendbx-database`` -^^^^^^^^^^^^^^^^^^^^ - -The database name where all domain and record entries are stored. -Default=powerdns - -.. _setting-opendbx-username: - -``opendbx-username`` -^^^^^^^^^^^^^^^^^^^^ - -Name of the user send to the DBMS for authentication. Default=powerdns. - -.. _setting-opendbx-password: - -``opendbx-password`` -^^^^^^^^^^^^^^^^^^^^ - -Clear text password for authentication in combination with the username. - -Queries -------- - -As with the :doc:`generic-sql`, queries -are configurable. Note: If you change one of the SELECT statements must -not change the order of the retrieved columns! To get the default -queries, run ``pdns_server --no-config --launch=opendbx --config``. The -following queries are configurable: - -- ``opendbx-sql-list``: Select records which will be returned to - clients asking for zone transfers (AXFR). -- ``opendbx-sql-lookup``: Retrieve DNS records by name. -- ``opendbx-sql-lookupid``: Retrieve DNS records by id and name. -- ``opendbx-sql-lookuptype``: Retrieve DNS records by name and type. -- ``opendbx-sql-lookuptypeid``: Retrieve DNS records by id, name and - type. -- ``opendbx-sql-lookupsoa``: Retrieve SOA record for domain. -- ``opendbx-sql-zonedelete``: Delete all records from zone before - inserting new ones via AXFR. -- ``opendbx-sql-zoneinfo``: Get stored information about a domain. -- ``opendbx-sql-transactbegin``: Start transaction before updating a - zone via AXFR. -- ``opendbx-sql-transactend``: Commit transaction after updating a zone - via AXFR. -- ``opendbx-sql-transactabort``: Undo changes if an error occurred - while updating a zone via AXFR. -- ``opendbx-sql-insert-slave``: Adds a new zone from the authoritative - DNS server which is currently retrieved via AXFR. -- ``opendbx-sql-insert-record``: Adds new records of a zone form the - authoritative DNS server which are currently retrieved via AXFR. -- ``opendbx-sql-update-serial``: Set zone serial to value of last - update. -- ``opendbx-sql-update-lastcheck``: Set time of last zone check. -- ``opendbx-sql-master``: Get master record for zone. -- ``opendbx-sql-supermaster``: Get supermaster info. -- ``opendbx-sql-infoslaves``: Get all unfresh slaves. -- ``opendbx-sql-infomasters``: Get all updates masters. - -Database schemas and information --------------------------------- - -Mysql -^^^^^ - -The file below also contains trigger definitions which are necessary for -``autoserial`` support, but they -are only available in MySQL 5 and later. If you are still using MySQL -4.x and don't want to utilize the automatically generated zone serials, -you can safely remove the "CREATE TRIGGER" statements from the file -before creating the database tables. - -.. code-block:: SQL - - SET SESSION sql_mode='ANSI'; - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL AUTO_INCREMENT, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) NOT NULL DEFAULT '', - "account" VARCHAR(40) NOT NULL DEFAULT '', - "last_check" INTEGER DEFAULT NULL, - "notified_serial" INTEGER DEFAULT NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) NOT NULL DEFAULT 'A', - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ) type=InnoDB; - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL AUTO_INCREMENT, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER DEFAULT NULL, - "prio" INTEGER DEFAULT NULL, - "content" VARCHAR(255) NOT NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON UPDATE CASCADE - ON DELETE CASCADE - ) type=InnoDB; - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) NOT NULL DEFAULT '' - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - - DELIMITER : - - CREATE TRIGGER "pdns_trig_records_insert" - AFTER INSERT ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = NEW."domain_id"; - END;: - - CREATE TRIGGER "pdns_trig_records_update" - AFTER UPDATE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = NEW."domain_id"; - END;: - - CREATE TRIGGER "pdns_trig_records_delete" - AFTER DELETE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = OLD."domain_id"; - END;: - - DELIMITER ; - -PostgreSQL -^^^^^^^^^^ - -.. code-block:: SQL - - CREATE TABLE "domains" ( - "id" SERIAL NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) NOT NULL DEFAULT '', - "account" VARCHAR(40) NOT NULL DEFAULT '', - "last_check" INTEGER DEFAULT NULL, - "notified_serial" INTEGER DEFAULT NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) NOT NULL DEFAULT 'A', - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" SERIAL NOT NULL, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER DEFAULT NULL, - "prio" INTEGER DEFAULT NULL, - "content" VARCHAR(255) NOT NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON UPDATE CASCADE - ON DELETE CASCADE - ); - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) NOT NULL DEFAULT '' - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "domains_id_seq" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - GRANT ALL ON "records_id_seq" TO "powerdns"; - - CREATE RULE "pdns_rule_records_insert" - AS ON INSERT TO "records" DO - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 WHERE "id" = NEW."domain_id"; - - CREATE RULE "pdns_rule_records_update" - AS ON UPDATE TO "records" DO - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 WHERE "id" = NEW."domain_id"; - - CREATE RULE "pdns_rule_records_delete" - AS ON DELETE TO "records" DO - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 WHERE "id" = OLD."domain_id"; - -SQLite and SQLite3 -^^^^^^^^^^^^^^^^^^ - -Supported without changes since OpenDBX 1.0.0 but requires to set -:ref:`setting-opendbx-host-read` to the path of the SQLite file -(including the trailing slash or backslash, depending on your operating -system) and opendbx-database to the name of the file. - -.. code-block:: ini - - opendbx-host-read = /path/to/file/ - opendbx-host-write = /path/to/file/ - opendbx-database = powerdns.sqlite - -SQLite Schema -~~~~~~~~~~~~~ - -.. code-block:: SQL - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL PRIMARY KEY, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) NOT NULL DEFAULT '', - "account" VARCHAR(40) NOT NULL DEFAULT '', - "last_check" INTEGER DEFAULT NULL, - "notified_serial" INTEGER DEFAULT NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) NOT NULL DEFAULT 'A', - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL PRIMARY KEY, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER DEFAULT NULL, - "prio" INTEGER DEFAULT NULL, - "content" VARCHAR(255) NOT NULL, - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON UPDATE CASCADE - ON DELETE CASCADE - ); - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) NOT NULL DEFAULT '' - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - CREATE TRIGGER "pdns_trig_records_insert" - AFTER INSERT ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_update" - AFTER UPDATE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_delete" - AFTER DELETE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = OLD."domain_id"; - END; - -SQLite3 Schema -~~~~~~~~~~~~~~ - -.. code-block:: SQL - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) NOT NULL DEFAULT '', - "account" VARCHAR(40) NOT NULL DEFAULT '', - "last_check" INTEGER DEFAULT NULL, - "notified_serial" INTEGER DEFAULT NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) NOT NULL DEFAULT 'A', - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER DEFAULT NULL, - "prio" INTEGER DEFAULT NULL, - "content" VARCHAR(255) NOT NULL, - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON UPDATE CASCADE - ON DELETE CASCADE - ); - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) NOT NULL DEFAULT '' - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - CREATE TRIGGER "pdns_trig_records_insert" - AFTER INSERT ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_update" - AFTER UPDATE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_delete" - AFTER DELETE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = OLD."domain_id"; - END; - -Firebird/Interbase -^^^^^^^^^^^^^^^^^^ - -Requires :ref:`setting-opendbx-database` set to the path of -the database file and doesn't support the default statement for starting -transactions. Please add the following lines to your pdns.conf: - -.. code-block:: ini - - opendbx-database = /var/lib/firebird2/data/powerdns.gdb - opendbx-sql-transactbegin = SET TRANSACTION - -When creating the database please make sure that you call the ``isql`` -tool with the parameter ``-page 4096``. Otherwise, you will get an error -(key size exceeds implementation restriction for index -"pdns\_unq\_domains\_name") when creating the tables. - -.. code-block:: SQL - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) DEFAULT '' NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL, - "last_check" INTEGER, - "notified_serial" INTEGER, - "auto_serial" INTEGER DEFAULT 0 NOT NULL, - "status" CHAR(1) DEFAULT 'A' NOT NULL, - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE GENERATOR "pdns_gen_domains_id"; - - SET TERM !!; - CREATE TRIGGER "pdns_trig_domains_id" FOR "domains" - ACTIVE BEFORE INSERT AS - BEGIN - IF (NEW."id" IS NULL) THEN - NEW."id" = GEN_ID("pdns_gen_domains_id",1); - END !! - SET TERM ;!! - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER DEFAULT NULL, - "prio" INTEGER DEFAULT NULL, - "content" VARCHAR(255) NOT NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON UPDATE CASCADE - ON DELETE CASCADE - ); - - CREATE GENERATOR "pdns_gen_records_id"; - - SET TERM !!; - CREATE TRIGGER "pdns_trig_records_id" FOR "records" - ACTIVE BEFORE INSERT AS - BEGIN - IF (NEW."id" IS NULL) THEN - NEW."id" = GEN_ID("pdns_gen_records_id",1); - END !! - SET TERM ;!! - - CREATE INDEX "idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - - SET TERM !!; - - CREATE TRIGGER "pdns_trig_records_insert" FOR "records" - ACTIVE AFTER INSERT AS - BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = NEW."domain_id"; - END !! - - CREATE TRIGGER "pdns_trig_records_update" FOR "records" - ACTIVE AFTER UPDATE AS - BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = NEW."domain_id"; - END !! - - CREATE TRIGGER "pdns_trig_records_delete" FOR "records" - ACTIVE AFTER DELETE AS - BEGIN - UPDATE "domains" d SET d."auto_serial" = d."auto_serial" + 1 - WHERE d."id" = OLD."domain_id"; - END !! - - SET TERM ;!! - -Microsoft SQL Server -^^^^^^^^^^^^^^^^^^^^ - -Supported using the FreeTDS library. It uses a different scheme for host -configuration (requires the name of the host section in the -configuration file of the dblib client library) and doesn't support the -default statement for starting transactions. Please add the following -lines to your pdns.conf: - -.. code-block:: ini - - opendbx-host-read = MSSQL2k - opendbx-host-write = MSSQL2k - opendbx-sql-transactbegin = BEGIN TRANSACTION - -.. code-block:: SQL - - SET quoted_identifier ON; - - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL IDENTITY, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) DEFAULT '' NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL, - "last_check" INTEGER NULL, - "notified_serial" INTEGER NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) DEFAULT 'A' NOT NULL, - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL IDENTITY, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER NULL, - "prio" INTEGER NULL, - "content" VARCHAR(255) NOT NULL, - "change_date" INTEGER NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ); - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL - ); - - CREATE INDEX "pdns_idx_smip_smns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - - CREATE TRIGGER "pdns_trig_records_insert" - ON "records" FOR INSERT AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT i."domain_id" FROM "inserted" i GROUP BY i."domain_id" - ); - - CREATE TRIGGER "pdns_trig_records_update" - ON "records" FOR UPDATE AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT i."domain_id" FROM "inserted" i GROUP BY i."domain_id" - ); - - CREATE TRIGGER "pdns_trig_records_delete" - ON "records" FOR DELETE AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT d."domain_id" FROM "deleted" d GROUP BY d."domain_id" - ); - -Sybase ASE -^^^^^^^^^^ - -Supported using the native Sybase ctlib or the FreeTDS library. It uses -a different scheme for host configuration (requires the name of the host -section in the configuration file of the ctlib client library) and -doesn't support the default statement for starting transactions. Please -add the following lines to your pdns.conf: - -.. code-block:: ini - - opendbx-host-read = SYBASE - opendbx-host-write = SYBASE - opendbx-sql-transactbegin = BEGIN TRANSACTION - -.. code-block:: SQL - - SET quoted_identifier ON; - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL IDENTITY, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) DEFAULT '' NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL, - "last_check" INTEGER NULL, - "notified_serial" INTEGER NULL, - "auto_serial" INTEGER NOT NULL DEFAULT 0, - "status" CHAR(1) DEFAULT 'A' NOT NULL, - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL IDENTITY, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER NULL, - "prio" INTEGER NULL, - "content" VARCHAR(255) NOT NULL, - "change_date" INTEGER NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ); - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) DEFAULT '' NOT NULL - ); - - CREATE INDEX "pdns_idx_smip_smns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - - CREATE TRIGGER "pdns_trig_records_insert" - ON "records" FOR INSERT AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT i."domain_id" FROM "inserted" i GROUP BY i."domain_id" - ); - - CREATE TRIGGER "pdns_trig_records_update" - ON "records" FOR UPDATE AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT i."domain_id" FROM "inserted" i GROUP BY i."domain_id" - ); - - CREATE TRIGGER "pdns_trig_records_delete" - ON "records" FOR DELETE AS - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = ANY ( - SELECT d."domain_id" FROM "deleted" d GROUP BY d."domain_id" - ); - -Oracle -^^^^^^ - -Uses a different syntax for transactions and requires the following -additional line in your pdns.conf: - -.. code-block:: ini - - opendbx-sql-transactbegin = SET TRANSACTION NAME 'AXFR' - -.. code-block:: SQL - - CREATE TABLE "domains" ( - "id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "master" VARCHAR(40) DEFAULT '', - "account" VARCHAR(40) DEFAULT '', - "last_check" INTEGER, - "notified_serial" INTEGER, - "auto_serial" INTEGER DEFAULT 0, - "status" CHAR(1) DEFAULT 'A', - CONSTRAINT "pdns_pk_domains_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_unq_domains_name" - UNIQUE ("name") - ); - - CREATE SEQUENCE "pdns_seq_domains_id" START WITH 1 INCREMENT BY 1; - - CREATE TRIGGER "pdns_trig_domains_id" - BEFORE INSERT ON "domains" - FOR EACH ROW - BEGIN - SELECT "pdns_seq_domains_id".nextval INTO :NEW."id" FROM dual; - END; - - CREATE INDEX "pdns_idx_domains_status_type" ON "domains" ("status","type"); - - CREATE TABLE "records" ( - "id" INTEGER NOT NULL, - "domain_id" INTEGER NOT NULL, - "name" VARCHAR(255) NOT NULL, - "type" VARCHAR(6) NOT NULL, - "ttl" INTEGER NULL, - "prio" INTEGER NULL, - "content" VARCHAR(255) NOT NULL, - "change_date" INTEGER NULL, - CONSTRAINT "pdns_pk_records_id" - PRIMARY KEY ("id"), - CONSTRAINT "pdns_fk_records_domainid" - FOREIGN KEY ("domain_id") - REFERENCES "domains" ("id") - ON DELETE CASCADE - ); - - CREATE SEQUENCE "pdns_seq_records_id" START WITH 1 INCREMENT BY 1; - - CREATE TRIGGER "pdns_trig_records_id" - BEFORE INSERT ON "records" - FOR EACH ROW - BEGIN - SELECT "pdns_seq_records_id".nextval INTO :NEW."id" FROM dual; - END; - - CREATE INDEX "pdns_idx_records_name_type" ON "records" ("name","type"); - CREATE INDEX "pdns_idx_records_type" ON "records" ("type"); - - CREATE TABLE "supermasters" ( - "ip" VARCHAR(40) NOT NULL, - "nameserver" VARCHAR(255) NOT NULL, - "account" VARCHAR(40) NOT NULL - ); - - CREATE INDEX "pdns_idx_smaster_ip_ns" ON "supermasters" ("ip","nameserver"); - - GRANT SELECT ON "supermasters" TO "powerdns"; - GRANT ALL ON "domains" TO "powerdns"; - GRANT ALL ON "records" TO "powerdns"; - - CREATE TRIGGER "pdns_trig_records_insert" - AFTER INSERT ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = :NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_update" - AFTER UPDATE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = :NEW."domain_id"; - END; - - CREATE TRIGGER "pdns_trig_records_delete" - AFTER DELETE ON "records" - FOR EACH ROW BEGIN - UPDATE "domains" SET "auto_serial" = "auto_serial" + 1 - WHERE "id" = :OLD."domain_id"; - END; diff --git a/m4/pdns_check_opendbx.m4 b/m4/pdns_check_opendbx.m4 deleted file mode 100644 index 66327ce699..0000000000 --- a/m4/pdns_check_opendbx.m4 +++ /dev/null @@ -1,14 +0,0 @@ -AC_DEFUN([PDNS_CHECK_OPENDBX], [ - PKG_CHECK_MODULES([OPENDBX], [opendbx], [], [ - AC_CHECK_HEADERS([odbx.h], [ - AC_CHECK_LIB([opendbx], [odbx_init], - [OPENDBX_LIBS="-lopendbx"], - [AC_MSG_ERROR([libopendbx not found])] - )], [ - AC_MSG_ERROR([opendbx header (odbx.h) not found]) - ] - ) - ]) - AC_SUBST([OPENDBX_LIBS]) -]) - diff --git a/modules/Makefile.am b/modules/Makefile.am index 4995934a16..bc4782ccad 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -10,7 +10,6 @@ DIST_SUBDIRS = \ ldapbackend \ lmdbbackend \ lua2backend \ - opendbxbackend \ pipebackend \ randombackend \ remotebackend \ diff --git a/modules/opendbxbackend/Makefile.am b/modules/opendbxbackend/Makefile.am deleted file mode 100644 index 494c99a3d8..0000000000 --- a/modules/opendbxbackend/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -pkglib_LTLIBRARIES = libopendbxbackend.la - -EXTRA_DIST = OBJECTFILES OBJECTLIBS - -libopendbxbackend_la_SOURCES = \ - odbxbackend.cc odbxbackend.hh \ - odbxprivate.cc - -libopendbxbackend_la_LDFLAGS = -module -avoid-version -libopendbxbackend_la_LIBADD = $(OPENDBX_LIBS) diff --git a/modules/opendbxbackend/OBJECTFILES b/modules/opendbxbackend/OBJECTFILES deleted file mode 100644 index f2a813e25d..0000000000 --- a/modules/opendbxbackend/OBJECTFILES +++ /dev/null @@ -1 +0,0 @@ -odbxbackend.lo odbxprivate.lo diff --git a/modules/opendbxbackend/OBJECTLIBS b/modules/opendbxbackend/OBJECTLIBS deleted file mode 100644 index ffc7f01782..0000000000 --- a/modules/opendbxbackend/OBJECTLIBS +++ /dev/null @@ -1 +0,0 @@ -$(OPENDBX_LIBS) diff --git a/modules/opendbxbackend/README b/modules/opendbxbackend/README deleted file mode 100644 index a4c39c6023..0000000000 --- a/modules/opendbxbackend/README +++ /dev/null @@ -1,2 +0,0 @@ -For more information, see -http://wiki.linuxnetworks.de/doc/index.php/PowerDNS_OpenDBX_Backend \ No newline at end of file diff --git a/modules/opendbxbackend/odbxbackend.cc b/modules/opendbxbackend/odbxbackend.cc deleted file mode 100644 index c0fc88a60c..0000000000 --- a/modules/opendbxbackend/odbxbackend.cc +++ /dev/null @@ -1,777 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * originally authored by Norbert Sendetzky - * - * 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 "odbxbackend.hh" - - - -inline string& strbind( const string& search, const string& replace, string& subject ) -{ - size_t pos = 0; - - while( ( pos = subject.find( search, pos ) ) != string::npos ) - { - subject.replace( pos, search.size(), replace ); - pos += replace.size(); - } - - return subject; -} - - - -OdbxBackend::OdbxBackend( const string& suffix ) -{ - vector hosts; - - - try - { - m_result = NULL; - m_handle[READ] = NULL; - m_handle[WRITE] = NULL; - m_myname = "[OpendbxBackend]"; - m_default_ttl = arg().asNum( "default-ttl" ); - m_qlog = arg().mustDo( "query-logging" ); - - setArgPrefix( "opendbx" + suffix ); - - if( getArg( "host" ).size() > 0 ) - { - g_log.log( m_myname + " WARNING: Using deprecated opendbx-host parameter", Logger::Warning ); - stringtok( m_hosts[READ], getArg( "host" ), ", " ); - m_hosts[WRITE] = m_hosts[READ]; - } - else - { - stringtok( m_hosts[READ], getArg( "host-read" ), ", " ); - stringtok( m_hosts[WRITE], getArg( "host-write" ), ", " ); - } - - if( !connectTo( m_hosts[READ], READ ) ) { throw( PDNSException( "Fatal: Connecting to server for reading failed" ) ); } - if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( PDNSException( "Fatal: Connecting to server for writing failed" ) ); } - } - catch( std::exception& e ) - { - g_log.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(), Logger::Error ); - throw( PDNSException( "Fatal: STL exception" ) ); - } -} - - - -OdbxBackend::~OdbxBackend() -{ - odbx_unbind( m_handle[WRITE] ); - odbx_unbind( m_handle[READ] ); - - odbx_finish( m_handle[WRITE] ); - odbx_finish( m_handle[READ] ); -} - - - -bool OdbxBackend::getDomainInfo( const DNSName& domain, DomainInfo& di, bool getSerial ) -{ - const char* tmp; - - - try - { - DLOG( g_log.log( m_myname + " getDomainInfo()", Logger::Debug ) ); - - string stmt = getArg( "sql-zoneinfo" ); - string& stmtref = strbind( ":name", escape( domain.makeLowerCase().toStringRootDot(), READ ), stmt ); - - if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } - if( !getRecord( READ ) ) { return false; } - - do - { - di.id = 0; - di.zone.clear(); - di.masters.clear(); - di.last_check = 0; - di.notified_serial = 0; - di.kind = DomainInfo::Native; - di.backend = this; - di.serial = 0; - - if( getSerial && ( tmp = odbx_field_value( m_result, 6 ) ) != NULL ) - { - SOAData sd; - - sd.serial = 0; - fillSOAData( string( tmp, odbx_field_length( m_result, 6 ) ), sd ); - - if( sd.serial == 0 && ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) - { - sd.serial = strtol( tmp, NULL, 10 ); - } - - di.serial = sd.serial; - } - - if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) - { - di.last_check = strtol( tmp, NULL, 10 ); - } - - if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) - { - vector masters; - stringtok(masters, string( tmp, odbx_field_length( m_result, 3 ) ), ", \t"); - for(const auto& m : masters) - { - di.masters.emplace_back(m, 53); - } - } - - if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) - { - if( !strncmp( tmp, "SLAVE", 5 ) ) - { - di.kind = DomainInfo::Slave; - } - else if( !strncmp( tmp, "MASTER", 6 ) ) - { - di.kind = DomainInfo::Master; - } - } - - if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) - { - di.zone = DNSName(string( tmp, odbx_field_length( m_result, 1 ) )); - } - - if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) - { - di.id = strtol( tmp, NULL, 10 ); - } - } - while( getRecord( READ ) ); - } - catch( std::exception& e ) - { - g_log.log( m_myname + " getDomainInfo: Caught STL std::exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd ) -{ - const char* tmp; - - - try - { - DLOG( g_log.log( m_myname + " getSOA()", Logger::Debug ) ); - - string stmt = getArg( "sql-lookupsoa" ); - string& stmtref = strbind( ":name", escape( domain.makeLowerCase().toStringRootDot(), READ ), stmt ); - - if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } - if( !getRecord( READ ) ) { return false; } - - do - { - sd.qname = domain; - sd.serial = 0; - sd.ttl = m_default_ttl; - - if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) - { - fillSOAData( string( tmp, odbx_field_length( m_result, 3 ) ), sd ); - } - - if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) - { - sd.ttl = strtoul( tmp, NULL, 10 ); - } - - if( sd.serial == 0 && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) - { - sd.serial = strtol( tmp, NULL, 10 ); - } - - if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) - { - sd.domain_id = strtol( tmp, NULL, 10 ); - } - - if( sd.nameserver.empty() ) - { - sd.nameserver = DNSName(arg()["default-soa-name"]); - } - - if( sd.hostmaster.empty() ) - { - sd.hostmaster = DNSName("hostmaster") + DNSName(domain); - } - - sd.db = this; - } - while( getRecord( READ ) ); - } - catch( std::exception& e ) - { - g_log.log( m_myname + " getSOA: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::list( const DNSName& target, int zoneid, bool include_disabled ) -{ - try - { - DLOG( g_log.log( m_myname + " list()", Logger::Debug ) ); - - m_qname.clear(); - m_result = NULL; - - int len = snprintf( m_buffer, sizeof( m_buffer ), "%d", zoneid ); - - if( len < 0 ) - { - g_log.log( m_myname + " list: Unable to convert zone id to string - format error", Logger::Error ); - return false; - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " list: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); - return false; - } - - string stmt = getArg( "sql-list" ); - string& stmtref = strbind( ":id", string( m_buffer, len ), stmt ); - - if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } - } - catch( std::exception& e ) - { - g_log.log( m_myname + " list: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -void OdbxBackend::lookup( const QType& qtype, const DNSName& qname, int zoneid, DNSPacket* dnspkt ) -{ - try - { - DLOG( g_log.log( m_myname + " lookup()", Logger::Debug ) ); - - string stmt; - string& stmtref = stmt; - - m_result = NULL; - m_qname = qname; - - if( zoneid < 0 ) - { - if( qtype.getCode() == QType::ANY ) - { - stmt = getArg( "sql-lookup" ); - } else { - stmt = getArg( "sql-lookuptype" ); - stmtref = strbind( ":type", qtype.getName(), stmt ); - } - } - else - { - if( qtype.getCode() == QType::ANY ) - { - stmt = getArg( "sql-lookupid" ); - } else { - stmt = getArg( "sql-lookuptypeid" ); - stmtref = strbind( ":type", qtype.getName(), stmt ); - } - - int len = snprintf( m_buffer, sizeof( m_buffer ), "%d", zoneid ); - - if( len < 0 ) - { - g_log.log( m_myname + " lookup: Unable to convert zone id to string - format error", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " lookup: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - stmtref = strbind( ":id", string( m_buffer, len ), stmtref ); - } - - stmtref = strbind( ":name", escape( qname.makeLowerCase().toStringRootDot(), READ ), stmtref ); - - if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) - { - throw( DBException( "Error: DB statement failed" ) ); - } - } - catch( std::exception& e ) - { - g_log.log( m_myname + " lookup: Caught STL exception - " + e.what(), Logger::Error ); - throw( DBException( "Error: STL exception" ) ); - } -} - - - -bool OdbxBackend::get( DNSResourceRecord& rr ) -{ - const char* tmp; - string priority; - - try - { - DLOG( g_log.log( m_myname + " get()", Logger::Debug ) ); - - if( getRecord( READ ) ) - { - - rr.content = ""; - rr.domain_id = 0; - rr.last_modified = 0; - rr.ttl = m_default_ttl; - rr.qname = m_qname; - - if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) - { - rr.domain_id = strtol( tmp, NULL, 10 ); - } - - if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) - { - rr.qname = DNSName( string(tmp, odbx_field_length( m_result, 1 ) )); - } - - if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) - { - rr.qtype = tmp; - } - - if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) - { - rr.ttl = strtoul( tmp, NULL, 10 ); - } - - if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) - { - priority = string( tmp, odbx_field_length( m_result, 4 ) ); - } - - if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) - { - rr.content = string( tmp, odbx_field_length( m_result, 5 ) ); - } - - if (rr.qtype==QType::MX || rr.qtype==QType::SRV) - rr.content = priority + " " + rr.content; - - return true; - } - } - catch( std::exception& e ) - { - g_log.log( m_myname + " get: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return false; -} - - -void OdbxBackend::setFresh( uint32_t domain_id ) -{ - int len; - - - try - { - DLOG( g_log.log( m_myname + " setFresh()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " setFresh: Master server is unreachable", Logger::Error ); - throw( DBException( "Error: Server unreachable" ) ); - } - - len = snprintf( m_buffer, sizeof( m_buffer ), getArg( "sql-update-lastcheck" ).c_str(), time( 0 ), domain_id ); - - if( len < 0 ) - { - g_log.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - format error", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - insufficient buffer space", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - if( !execStmt( m_buffer, len, WRITE ) ) - { - throw( DBException( "Error: DB statement failed" ) ); - } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " setFresh: Caught STL exception - " + e.what(), Logger::Error ); - throw( DBException( "Error: STL exception" ) ); - } -} - - - -void OdbxBackend::setNotified( uint32_t domain_id, uint32_t serial ) -{ - try - { - DLOG( g_log.log( m_myname + " setNotified()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " setFresh: Master server is unreachable", Logger::Error ); - throw( DBException( "Error: Server unreachable" ) ); - } - - int len = snprintf( m_buffer, sizeof( m_buffer ), getArg( "sql-update-serial" ).c_str(), serial, domain_id ); - - if( len < 0 ) - { - g_log.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - format error", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - insufficient buffer space", Logger::Error ); - throw( DBException( "Error: Libc error" ) ); - } - - if( !execStmt( m_buffer, len, WRITE ) ) - { - throw( DBException( "Error: DB statement failed" ) ); - } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " setNotified: Caught STL exception - " + e.what(), Logger::Error ); - throw( DBException( "Error: STL exception" ) ); - } -} - - - -void OdbxBackend::getUnfreshSlaveInfos( vector* unfresh ) -{ - try - { - DLOG( g_log.log( m_myname + " getUnfreshSlaveInfos()", Logger::Debug ) ); - - if( unfresh == NULL ) - { - g_log.log( m_myname + " getUnfreshSlaveInfos: invalid parameter - NULL pointer", Logger::Error ); - return; - } - - getDomainList( getArg( "sql-infoslaves" ), unfresh, &checkSlave ); - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " getUnfreshSlaveInfo: Caught STL exception - " + e.what(), Logger::Error ); - } -} - - - -void OdbxBackend::getUpdatedMasters( vector* updated ) -{ - try - { - DLOG( g_log.log( m_myname + " getUpdatedMasters()", Logger::Debug ) ); - - if( updated == NULL ) - { - g_log.log( m_myname + " getUpdatedMasters: invalid parameter - NULL pointer", Logger::Error ); - return; - } - - getDomainList( getArg( "sql-infomasters" ), updated, &checkMaster ); - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " getUpdatedMasters: Caught STL exception - " + e.what(), Logger::Error ); - } -} - - - -bool OdbxBackend::superMasterBackend( const string& ip, const DNSName& domain, const vector& set, string *nameserver, string* account, DNSBackend** ddb ) -{ - try - { - DLOG( g_log.log( m_myname + " superMasterBackend()", Logger::Debug ) ); - - if( account != NULL && ddb != NULL ) - { - vector::const_iterator i; - - for( i = set.begin(); i != set.end(); i++ ) - { - string stmt = getArg( "sql-supermaster" ); - string& stmtref = strbind( ":ip", escape( ip, READ ), stmt ); - stmtref = strbind( ":ns", escape( i->content, READ ), stmtref ); - - if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; } - - if( getRecord( READ ) ) - { - if( odbx_field_value( m_result, 0 ) != NULL ) - { - *account = string( odbx_field_value( m_result, 0 ), odbx_field_length( m_result, 0 ) ); - } - - while( getRecord( READ ) ); - - *ddb=this; - return true; - } - } - } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " superMasterBackend: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return false; -} - - - -bool OdbxBackend::createSlaveDomain( const string& ip, const DNSName& domain, const string &nameserver, const string& account ) -{ - try - { - DLOG( g_log.log( m_myname + " createSlaveDomain()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " createSlaveDomain: Master server is unreachable", Logger::Error ); - return false; - } - - int len = snprintf( m_buffer, sizeof( m_buffer ), getArg( "sql-insert-slave" ).c_str(), escape( domain.makeLowerCase().toStringRootDot(), WRITE ).c_str(), - escape( ip, WRITE ).c_str(), escape( account, WRITE ).c_str() ); - - if( len < 0 ) - { - g_log.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - format error", Logger::Error ); - return false; - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - insufficient buffer space", Logger::Error ); - return false; - } - - if( !execStmt( m_buffer, len, WRITE ) ) { return false; } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " createSlaveDomain: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::feedRecord( const DNSResourceRecord& rr, const DNSName& ordername, bool ordernameIsNSEC3 ) -{ - try - { - DLOG( g_log.log( m_myname + " feedRecord()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " feedRecord: Master server is unreachable", Logger::Error ); - return false; - } - - unsigned int priority=0; - string content(rr.content); - - if(rr.qtype == QType::MX || rr.qtype == QType::SRV) { - priority=pdns_stou(content); - string::size_type pos = content.find_first_not_of("0123456789"); - if(pos != string::npos) - boost::erase_head(content, pos); - trim_left(content); - } - - int len = snprintf( m_buffer, sizeof( m_buffer ), getArg( "sql-insert-record" ).c_str(), rr.domain_id, - escape( rr.qname.makeLowerCase().toStringRootDot(), WRITE ).c_str(), rr.qtype.getName().c_str(), rr.ttl, priority, - escape( content, WRITE ).c_str() ); - - if( len < 0 ) - { - g_log.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - format error", Logger::Error ); - return false; - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - insufficient buffer space", Logger::Error ); - return false; - } - - if( !execStmt( m_buffer, len, WRITE ) ) { return false; } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " feedRecord: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::startTransaction( const DNSName& domain, int zoneid ) -{ - try - { - DLOG( g_log.log( m_myname + " startTransaction()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " startTransaction: Master server is unreachable", Logger::Error ); - return false; - } - - string stmtref = getArg( "sql-transactbegin" ); - if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; } - int len = snprintf( m_buffer, sizeof( m_buffer ), "%d", zoneid ); - - if( len < 0 ) - { - g_log.log( m_myname + " startTransaction: Unable to convert zone id to string - format error", Logger::Error ); - return false; - } - - if( len > static_cast(sizeof( m_buffer )) - 1 ) - { - g_log.log( m_myname + " startTransaction: Unable to convert zone id to string - insufficient buffer space", Logger::Error ); - return false; - } - - if(zoneid >= 0) { - string stmt = getArg( "sql-zonedelete" ); - stmtref = strbind( ":id", string( m_buffer, len ), stmt ); - if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; } - } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " startTransaction: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::commitTransaction() -{ - try - { - DLOG( g_log.log( m_myname + " commitTransaction()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " commitTransaction: Master server is unreachable", Logger::Error ); - return false; - } - - const string& stmt = getArg( "sql-transactend" ); - if( !execStmt( stmt.c_str(), stmt.size(), WRITE ) ) { return false; } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " commitTransaction: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} - - - -bool OdbxBackend::abortTransaction() -{ - try - { - DLOG( g_log.log( m_myname + " abortTransaction()", Logger::Debug ) ); - - if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) ) - { - g_log.log( m_myname + " abortTransaction: Master server is unreachable", Logger::Error ); - return false; - } - - const string& stmt = getArg( "sql-transactabort" ); - if( !execStmt( stmt.c_str(), stmt.size(), WRITE ) ) { return false; } - } - catch ( std::exception& e ) - { - g_log.log( m_myname + " abortTransaction: Caught STL exception - " + e.what(), Logger::Error ); - return false; - } - - return true; -} diff --git a/modules/opendbxbackend/odbxbackend.hh b/modules/opendbxbackend/odbxbackend.hh deleted file mode 100644 index edb3199b2a..0000000000 --- a/modules/opendbxbackend/odbxbackend.hh +++ /dev/null @@ -1,180 +0,0 @@ -/* - * This file is part of PowerDNS or dnsdist. - * Copyright -- PowerDNS.COM B.V. and its contributors - * originally authored by Norbert Sendetzky - * - * 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. - */ -#include -#include -#include -#include -#include "pdns/dns.hh" -#include "pdns/utility.hh" -#include "pdns/dnspacket.hh" -#include "pdns/dnsbackend.hh" -#include "pdns/pdnsexception.hh" -#include "pdns/arguments.hh" -#include "pdns/logger.hh" -#include - - -#ifndef ODBXBACKEND_HH -#define ODBXBACKEND_HH - - -#define BUFLEN 512 - - -using std::string; -using std::vector; - - - -bool checkSlave( uint32_t last, uint32_t notified, SOAData* sd, DomainInfo* di ); -bool checkMaster( uint32_t last, uint32_t notified, SOAData* sd, DomainInfo* di ); - - -class OdbxBackend : public DNSBackend -{ - enum QueryType { READ, WRITE }; - - string m_myname; - DNSName m_qname; - int m_default_ttl; - bool m_qlog; - odbx_t* m_handle[2]; - odbx_result_t* m_result; - char m_escbuf[BUFLEN]; - char m_buffer[2*BUFLEN]; - vector m_hosts[2]; - - string escape( const string& str, QueryType type ); - bool connectTo( const vector& host, QueryType type ); - bool getDomainList( const string& query, vector* list, bool (*check_fcn)(uint32_t,uint32_t,SOAData*,DomainInfo*) ); - bool execStmt( const char* stmt, unsigned long length, QueryType type ); - bool getRecord( QueryType type ); - - -public: - - OdbxBackend( const string& suffix="" ); - ~OdbxBackend(); - - void lookup( const QType& qtype, const DNSName& qdomain, int zoneid, DNSPacket* p = nullptr ) override; - bool getSOA( const DNSName& domain, SOAData& sd ) override; - bool list( const DNSName& target, int domain_id, bool include_disabled=false ) override; - bool get( DNSResourceRecord& rr ) override; - - bool startTransaction( const DNSName& domain, int domain_id ) override; - bool commitTransaction() override; - bool abortTransaction() override; - - bool getDomainInfo( const DNSName& domain, DomainInfo& di, bool getSerial=true ) override; - bool feedRecord( const DNSResourceRecord& rr, const DNSName& ordername, bool ordernameIsNSEC3=false ) override; - bool createSlaveDomain( const string& ip, const DNSName& domain, const string &nameserver, const string& account ) override; - bool superMasterBackend( const string& ip, const DNSName& domain, const vector& nsset, string *nameserver, string* account, DNSBackend** ddb ) override; - - void getUpdatedMasters( vector* updated ) override; - void getUnfreshSlaveInfos( vector* unfresh ) override; - - void setFresh( uint32_t domain_id ) override; - void setNotified( uint32_t domain_id, uint32_t serial ) override; -}; - - - -class OdbxFactory : public BackendFactory -{ - -public: - - OdbxFactory() : BackendFactory( "opendbx" ) {} - - - void declareArguments( const string &suffix="" ) - { - declare( suffix, "backend", "OpenDBX backend","mysql" ); - declare( suffix, "host-read", "Name or address of one or more DBMS server to read from","127.0.0.1" ); - declare( suffix, "host-write", "Name or address of one or more DBMS server used for updates","127.0.0.1" ); - declare( suffix, "port", "Port the DBMS server are listening to","" ); - declare( suffix, "database", "Database name containing the DNS records","powerdns" ); - declare( suffix, "username","User for connecting to the DBMS","powerdns"); - declare( suffix, "password","Password for connecting to the DBMS",""); - - declare( suffix, "sql-list", "AXFR query", "SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id" ); - - declare( suffix, "sql-lookup", "Lookup query","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"name\"=':name'" ); - declare( suffix, "sql-lookupid", "Lookup query with id","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id AND r.\"name\"=':name'" ); - declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"name\"=':name' AND r.\"type\"=':type'" ); - declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT r.\"domain_id\", r.\"name\", r.\"type\", r.\"ttl\", r.\"prio\", r.\"content\" FROM \"records\" r WHERE r.\"domain_id\"=:id AND r.\"name\"=':name' AND r.\"type\"=':type'" ); - declare( suffix, "sql-lookupsoa","Lookup query for SOA record","SELECT d.\"id\", d.\"auto_serial\", r.\"ttl\", r.\"content\" FROM \"records\" r JOIN \"domains\" d ON r.\"domain_id\"=d.\"id\" WHERE r.\"name\"=':name' AND r.\"type\"='SOA' AND d.\"status\"='A'" ); - - declare( suffix, "sql-zonedelete","Delete all records for this zone","DELETE FROM \"records\" WHERE \"domain_id\"=:id" ); - declare( suffix, "sql-zoneinfo","Get domain info","SELECT d.\"id\", d.\"name\", d.\"type\", d.\"master\", d.\"last_check\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"name\"=':name' AND d.\"status\"='A'" ); - - declare( suffix, "sql-transactbegin", "Start transaction", "BEGIN" ); - declare( suffix, "sql-transactend", "Finish transaction", "COMMIT" ); - declare( suffix, "sql-transactabort", "Abort transaction", "ROLLBACK" ); - - declare( suffix, "sql-insert-slave","Add slave domain", "INSERT INTO \"domains\" ( \"name\", \"type\", \"master\", \"account\" ) VALUES ( '%s', 'SLAVE', '%s', '%s' )" ); - declare( suffix, "sql-insert-record","Feed record into table", "INSERT INTO \"records\" ( \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" ) VALUES ( %d, '%s', '%s', %d, %d, '%s' )" ); - - declare( suffix, "sql-update-serial", "Set zone to notified", "UPDATE \"domains\" SET \"notified_serial\"=%d WHERE \"id\"=%d" ); - declare( suffix, "sql-update-lastcheck", "Set time of last check", "UPDATE \"domains\" SET \"last_check\"=%d WHERE \"id\"=%d" ); - - declare( suffix, "sql-master", "Get master record for zone", "SELECT d.\"master\" FROM \"domains\" d WHERE d.\"name\"=':name' AND d.\"status\"='A' AND d.\"type\"='SLAVE'" ); - declare( suffix, "sql-supermaster","Get supermaster info", "SELECT s.\"account\" FROM \"supermasters\" s WHERE s.\"ip\"=':ip' AND s.\"nameserver\"=':ns'" ); - - declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.\"id\", d.\"name\", d.\"master\", d.\"last_check\", d.\"notified_serial\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"status\"='A' AND d.\"type\"='SLAVE'" ); - declare( suffix, "sql-infomasters", "Get all updated masters", "SELECT d.\"id\", d.\"name\", d.\"master\", d.\"last_check\", d.\"notified_serial\", d.\"auto_serial\", r.\"content\" FROM \"domains\" d LEFT JOIN \"records\" r ON ( d.\"id\"=r.\"domain_id\" AND r.\"type\"='SOA' ) WHERE d.\"status\"='A' AND d.\"type\"='MASTER'" ); - - declare( suffix, "host", "deprecated, use host-read and host-write instead","" ); - } - - - DNSBackend* make( const string &suffix="" ) - { - return new OdbxBackend( suffix ); - } -}; - - -class OdbxLoader -{ - OdbxFactory factory; - -public: - - OdbxLoader() - { - BackendMakers().report( &factory ); - g_log<< Logger::Info << "[opendbxbackend] This is the opendbx backend version " VERSION -#ifndef REPRODUCIBLE - << " (" __DATE__ " " __TIME__ ")" -#endif - << " reporting" << endl; - } -}; - - -static OdbxLoader odbxloader; - - - -#endif /* ODBXBACKEND_HH */ diff --git a/regression-tests/backends/common b/regression-tests/backends/common index fac0d7ce6d..36c1b595cf 100644 --- a/regression-tests/backends/common +++ b/regression-tests/backends/common @@ -35,10 +35,6 @@ start_master () source ./backends/lmdb-master ;; - opendbx*) - source ./backends/opendbx-master - ;; - remote*) source ./backends/remote-master ;; diff --git a/regression-tests/backends/opendbx-master b/regression-tests/backends/opendbx-master deleted file mode 100644 index e19dd7868d..0000000000 --- a/regression-tests/backends/opendbx-master +++ /dev/null @@ -1,20 +0,0 @@ -case $context in - opendbx-sqlite3) - rm -f pdns-opendbx.sqlite3 - sqlite3 pdns-opendbx.sqlite3 < ../modules/gsqlite3backend/schema.sqlite3.sql - tosql gsqlite | sqlite3 pdns-opendbx.sqlite3 - sqlite3 pdns-opendbx.sqlite3 "ALTER TABLE domains ADD status CHARACTER(1) NOT NULL DEFAULT 'A'; \ - ALTER TABLE domains ADD auto_serial INTEGER DEFAULT 0;" - echo ANALYZE\; | sqlite3 pdns-opendbx.sqlite3 - - $RUNWRAPPER $PDNS --daemon=no --local-address=$address --local-port=$port --socket-dir=./ \ - --no-shuffle --launch=opendbx \ - --cache-ttl=$cachettl --dname-processing --no-config \ - --opendbx-backend=sqlite3 --opendbx-host-read=./ --opendbx-host-write=./ \ - --opendbx-database=pdns-opendbx.sqlite3 --module-dir=./modules & - skipreasons="nodnssec noent nodyndns nometa noalias" - ;; - - *) - nocontext=yes -esac diff --git a/regression-tests/modules/libopendbxbackend.so b/regression-tests/modules/libopendbxbackend.so deleted file mode 120000 index aa12c7622e..0000000000 --- a/regression-tests/modules/libopendbxbackend.so +++ /dev/null @@ -1 +0,0 @@ -../../modules/opendbxbackend/.libs/libopendbxbackend.so \ No newline at end of file diff --git a/regression-tests/start-test-stop b/regression-tests/start-test-stop index 6a16bac01e..96044e25f0 100755 --- a/regression-tests/start-test-stop +++ b/regression-tests/start-test-stop @@ -50,7 +50,6 @@ godbc_sqlite3-nodnssec godbc_sqlite3 godbc_sqlite3-nsec3 godbc_sqlite3-nsec3-opt 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 -opendbx-sqlite3 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