CXXFLAGS="-O1 -Werror=vla -Werror=shadow -Wformat=2 -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS" \
./configure \
--disable-lua-records \
- --with-modules='bind lmdb ldap gmysql gsqlite3 gpgsql godbc mydns random tinydns' \
+ --with-modules='bind lmdb ldap gmysql gsqlite3 gpgsql godbc random tinydns' \
--enable-systemd \
--enable-tools \
--with-lmdb=/usr \
__EOF__
- run:
name: Set up mysql client lib to force TCP
- command: echo 'export GMYSQLHOST=127.0.0.1 MYDNSHOST=127.0.0.1' > ./vars
+ command: echo 'export GMYSQLHOST=127.0.0.1' > ./vars
workdir: ~/project/regression-tests
- auth-regress:
context: bind-hybrid-nsec3
- test-auth-regress-mydns:
- docker:
- - image: debian:buster
- - image: circleci/mysql:5
- steps:
- - auth-regress-setup
- - run:
- command: apt-get install -qq -y default-mysql-client
- - run:
- command: |
- cat >> ~/.my.cnf \<<- __EOF__
- [client]
- protocol=TCP
- __EOF__
- - run:
- name: Set up mysql client lib to force TCP
- command: echo 'export GMYSQLHOST=127.0.0.1 MYDNSHOST=127.0.0.1' > ./vars
- workdir: ~/project/regression-tests
- - auth-regress:
- context: mydns
- doroot: false
-
test-auth-regress-gmysql:
docker:
- image: debian:buster
__EOF__
- run:
name: Set up mysql client lib to force TCP
- command: echo 'export GMYSQLHOST=127.0.0.1 MYDNSHOST=127.0.0.1 export GMYSQL2HOST=127.0.0.1 MYDNS2HOST=127.0.0.1 ' > ./vars
+ command: echo 'export GMYSQLHOST=127.0.0.1 export GMYSQL2HOST=127.0.0.1 ' > ./vars
workdir: ~/project/regression-tests
- auth-regress:
context: gmysql-nodnssec-both
./configure \
--disable-lua-records \
--disable-systemd \
- --with-modules='bind lmdb ldap gmysql gsqlite3 gpgsql godbc mydns random tinydns' \
+ --with-modules='bind lmdb ldap gmysql gsqlite3 gpgsql godbc random tinydns' \
--enable-tools \
--with-lmdb=/usr \
--with-libsodium \
- test-auth-regress-gmysql:
requires:
- build-auth
- - test-auth-regress-mydns:
- requires:
- - build-auth
- test-auth-regress-bind:
requires:
- build-auth
./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 mydns || EXITCODE=1
-
./timestamp ./start-test-stop 5300 opendbx-sqlite3 || EXITCODE=1
./timestamp timeout 120s ./start-test-stop 5300 remotebackend-pipe || EXITCODE=1
run "autoreconf -vi"
run "./configure \
${sanitizerflags} \
- --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 lmdb lua mydns opendbx pipe random remote tinydns godbc lua2' \
+ --with-dynmodules='bind gmysql geoip gpgsql gsqlite3 lmdb lua opendbx pipe random remote tinydns godbc lua2' \
--with-modules='' \
--with-sqlite3 \
--with-libsodium \
# 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 mydns"
-
run "./timestamp ./start-test-stop 5300 opendbx-sqlite3"
run "./timestamp ./start-test-stop 5300 remotebackend-pipe"
the libopendbx1-DATABASE package to allow OpenDBX to connect to
the chosen database.
-Package: pdns-backend-mydns
-Architecture: any
-Depends: pdns-server (= ${binary:Version}),
- ${misc:Depends},
- ${shlibs:Depends}
-Provides: pdns-backend
-Description: MyDNS compatibility 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 MyDNS compatibility backend for PowerDNS.
-
Package: pdns-backend-tinydns
Architecture: any
Depends: pdns-server (= ${binary:Version}),
2011 PowerDNS.COM BV
License: GPL-2 with OpenSSL Exception
-Files: modules/mydnsbackend/*
-Copyright: 2011 Jonathan Oddy (Hostway UK) <jonathan@woaf.net>
-License: GPL-2 with OpenSSL Exception
-
-Files: modules/mydnsbackend/schema.mydns.sql
-Copyright: 2002-2005 Don Moore
- 2007-2008 Howard Wilkinson
-License: GPL-2+
-
Files: modules/ldapbackend/* pdns/zone2ldap.cc
Copyright: 2003-2007 Norbert Sendetzky <norbert@linuxnetworks.de>
License: GPL-2 with OpenSSL Exception
+++ /dev/null
-modules/mydnsbackend/schema.mydns.sql
+++ /dev/null
-usr/lib/*/pdns/libmydnsbackend.so*
+++ /dev/null
-#!/bin/sh
-set -e
-
-dpkg-trigger pdns-server
-
-#DEBHELPER#
-
-exit 0
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# Backends
-backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua lua2 mydns remote random opendbx tinydns
+backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua lua2 remote random opendbx tinydns
# Disable systemd integration on non-linux archs
ifeq ($(DEB_HOST_ARCH_OS),linux)
the libopendbx1-DATABASE package to allow OpenDBX to connect to
the chosen database.
-Package: pdns-backend-mydns
-Architecture: any
-Depends: pdns-server (= ${binary:Version}),
- ${misc:Depends},
- ${shlibs:Depends}
-Provides: pdns-backend
-Description: MyDNS compatibility 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 MyDNS compatibility backend for PowerDNS.
-
Package: pdns-backend-tinydns
Architecture: any
Depends: pdns-server (= ${binary:Version}),
2011 PowerDNS.COM BV
License: GPL-2 with OpenSSL Exception
-Files: modules/mydnsbackend/*
-Copyright: 2011 Jonathan Oddy (Hostway UK) <jonathan@woaf.net>
-License: GPL-2 with OpenSSL Exception
-
-Files: modules/mydnsbackend/schema.mydns.sql
-Copyright: 2002-2005 Don Moore
- 2007-2008 Howard Wilkinson
-License: GPL-2+
-
Files: modules/ldapbackend/* pdns/zone2ldap.cc
Copyright: 2003-2007 Norbert Sendetzky <norbert@linuxnetworks.de>
License: GPL-2 with OpenSSL Exception
+++ /dev/null
-modules/mydnsbackend/schema.mydns.sql
+++ /dev/null
-usr/lib/*/pdns/libmydnsbackend.so*
+++ /dev/null
-#!/bin/sh
-set -e
-
-dpkg-trigger pdns-server
-
-#DEBHELPER#
-
-exit 0
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# Backends
-backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua lua2 mydns remote random opendbx tinydns
+backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua lua2 remote random opendbx tinydns
# Disable systemd integration on non-linux archs
ifeq ($(DEB_HOST_ARCH_OS),linux)
the libopendbx1-DATABASE package to allow OpenDBX to connect to
the chosen database.
-Package: pdns-backend-mydns
-Architecture: any
-Depends: pdns-server (= ${binary:Version}),
- ${misc:Depends},
- ${shlibs:Depends}
-Provides: pdns-backend
-Description: MyDNS compatibility 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 MyDNS compatibility backend for PowerDNS.
-
Package: pdns-backend-tinydns
Architecture: any
Depends: pdns-server (= ${binary:Version}),
2011 PowerDNS.COM BV
License: GPL-2 with OpenSSL Exception
-Files: modules/mydnsbackend/*
-Copyright: 2011 Jonathan Oddy (Hostway UK) <jonathan@woaf.net>
-License: GPL-2 with OpenSSL Exception
-
-Files: modules/mydnsbackend/schema.mydns.sql
-Copyright: 2002-2005 Don Moore
- 2007-2008 Howard Wilkinson
-License: GPL-2+
-
Files: modules/ldapbackend/* pdns/zone2ldap.cc
Copyright: 2003-2007 Norbert Sendetzky <norbert@linuxnetworks.de>
License: GPL-2 with OpenSSL Exception
+++ /dev/null
-modules/mydnsbackend/schema.mydns.sql
+++ /dev/null
-usr/lib/*/pdns/libmydnsbackend.so*
+++ /dev/null
-#!/bin/sh
-set -e
-
-dpkg-trigger pdns-server
-
-#DEBHELPER#
-
-exit 0
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# Backends
-backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua lua2 mydns remote random opendbx tinydns
+backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lmdb lua lua2 remote random opendbx tinydns
# Disable systemd integration on non-linux archs
ifeq ($(DEB_HOST_ARCH_OS),linux)
the libopendbx1-DATABASE package to allow OpenDBX to connect to
the chosen database.
-Package: pdns-backend-mydns
-Architecture: any
-Depends: pdns-server (= ${binary:Version}),
- ${misc:Depends},
- ${shlibs:Depends}
-Provides: pdns-backend
-Description: MyDNS compatibility 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 MyDNS compatibility backend for PowerDNS.
-
Package: pdns-backend-tinydns
Architecture: any
Depends: pdns-server (= ${binary:Version}),
2011 PowerDNS.COM BV
License: GPL-2 with OpenSSL Exception
-Files: modules/mydnsbackend/*
-Copyright: 2011 Jonathan Oddy (Hostway UK) <jonathan@woaf.net>
-License: GPL-2 with OpenSSL Exception
-
-Files: modules/mydnsbackend/schema.mydns.sql
-Copyright: 2002-2005 Don Moore
- 2007-2008 Howard Wilkinson
-License: GPL-2+
-
Files: modules/ldapbackend/* pdns/zone2ldap.cc
Copyright: 2003-2007 Norbert Sendetzky <norbert@linuxnetworks.de>
License: GPL-2 with OpenSSL Exception
+++ /dev/null
-modules/mydnsbackend/schema.mydns.sql
+++ /dev/null
-usr/lib/*/pdns/libmydnsbackend.so*
+++ /dev/null
-#!/bin/sh
-set -e
-
-dpkg-trigger pdns-server
-
-#DEBHELPER#
-
-exit 0
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# Backends
-backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua lua2 mydns remote random opendbx tinydns
+backends := bind ldap pipe gmysql godbc gpgsql gsqlite3 geoip lua lua2 remote random opendbx tinydns
# Use new build system
%description backend-sqlite
This package contains the SQLite backend for %{name}
-%package backend-mydns
-Summary: MyDNS backend for %{name}
-Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-%global backends %{backends} mydns
-
-%description backend-mydns
-This package contains the MyDNS backend for %{name}
-
%if 0%{?rhel} >= 7
%package backend-odbc
Summary: UnixODBC backend for %{name}
%doc modules/gsqlite3backend/nodnssec-3.x_to_3.4.0_schema.sqlite3.sql
%{_libdir}/%{name}/libgsqlite3backend.so
-%files backend-mydns
-%doc modules/mydnsbackend/schema.mydns.sql
-%{_libdir}/%{name}/libmydnsbackend.so
-
%if 0%{?rhel} >= 7
%files backend-odbc
%doc modules/godbcbackend/schema.mssql.sql
godbc)
PDNS_WITH_UNIXODBC
;;
- mydns|gmysql)
+ gmysql)
PDNS_WITH_MYSQL
;;
gpgsql)
modules/lmdbbackend/Makefile
modules/luabackend/Makefile
modules/lua2backend/Makefile
- modules/mydnsbackend/Makefile
modules/opendbxbackend/Makefile
modules/pipebackend/Makefile
modules/randombackend/Makefile
+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+
| :doc:`Lua2 <lua2>` | Yes | Yes | No | No | Yes | ``lua2`` |
+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+
-| :doc:`MyDNS <mydns>` | Yes | No | No | No | No | ``mydns`` |
-+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+
| :doc:`OpenDBX <opendbx>` | Yes | Yes | Yes | Yes | No | ``opendbx`` |
+------------------------------------------------+--------+--------+-------+--------------+---------------------------------+--------------+
| :doc:`Pipe <pipe>` | Yes | No | No | No | Partial | ``pipe`` |
lmdb
lua
lua2
- mydns
opendbx
pipe
random
+++ /dev/null
-MyDNS Backend
-=============
-
-* Native: Yes
-* Master: No
-* Slave: No
-* Superslave: No
-* Autoserial: No
-* Case: Depends
-* DNSSEC: No
-* Disabled data: No
-* Comments: No
-* Module name: mydns
-* Launch name: ``mydns``
-
-The MyDNS backend makes PowerDNS a drop-in replacement for the
-`MyDNS <http://mydns.bboy.net/>`__ nameserver, as it uses the same
-database schema.
-
-Configuration Parameters
-------------------------
-
-.. _setting-mydns-host:
-
-``mydns-host``
-~~~~~~~~~~~~~~
-
-Database host to connect to.
-
-.. _setting-mydns-port:
-
-``mydns-port``
-~~~~~~~~~~~~~~
-
-Port on the database server to connect to.
-
-.. _setting-mydns-dbname:
-
-``mydns-dbname``
-~~~~~~~~~~~~~~~~
-
-Name of the database to connect to, "mydns" by default.
-
-.. _setting-mydns-user:
-
-``mydns-user``
-~~~~~~~~~~~~~~
-
-User for the database, "powerdns" by default.
-
-.. _setting-mydns-password:
-
-``mydns-password``
-~~~~~~~~~~~~~~~~~~
-
-The user password.
-
-.. _setting-mydns-socket:
-
-``mydns-socket``
-~~~~~~~~~~~~~~~~
-
-Unix socket to connect to the database.
-
-.. _setting-mydns-rr-table:
-
-``mydns-rr-table``
-~~~~~~~~~~~~~~~~~~
-
-Name of the resource record table in the database, "rr" by default.
-
-.. _setting-mydns-soa-table:
-
-``mydns-soa-table``
-~~~~~~~~~~~~~~~~~~~
-
-Name of the SOA table in the database, "soa" by default.
-
-.. _setting-mydns-soa-where:
-
-``mydns-soa-where``
-~~~~~~~~~~~~~~~~~~~
-
-Additional WHERE clause for SOA, default is "1 = 1".
-
-.. _setting-mydns-rr-where:
-
-``mydns-rr-where``
-~~~~~~~~~~~~~~~~~~
-
-Additional WHERE clause for resource records, default is "1 = 1".
-
-.. _setting-mydns-soa-active:
-
-``mydns-soa-active``
-~~~~~~~~~~~~~~~~~~~~
-
-Use the active column in the SOA table, "yes" by default.
-
-.. _setting-mydns-rr-active:
-
-``mydns-rr-active``
-~~~~~~~~~~~~~~~~~~~
-
-Use the active column in the resource record table, "yes" by default.
-
-.. _setting-mydns-use-minimal-ttl:
-
-``mydns-use-minimal-ttl``
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Setting this to 'yes' will make the backend behave like MyDNS on the TTL
-values. Setting it to 'no' will make it ignore the minimal-ttl of the
-zone. The default is "yes".
-
-Migrating from MyDNS to another SQL backend
--------------------------------------------
-To use one of the :doc:`generic SQL backend <generic-sql>`, like the :doc:`Postgresql <generic-postgresql>` or :doc:`MySQL <generic-mysql>` backends, the data can be migratedusing the :ref:`Backend to Backend <b2b-migrate>` migration guide.
--gsqlite
Output in format suitable for the default configuration of the
Generic SQLite3 backend.
---mydns
- Output in a format suitable for the MyDNS backend.
OUTPUT Options
--------------
This tool lets you migrate data from one backend to another, it moves
all data, including zones, metadata and crypto keys (if present). Some
example use cases are moving from BIND-style zonefiles to SQL based, or
-other way around, or moving from MyDNS to gMySQL.
+other way around.
Prerequisites
~~~~~~~~~~~~~
lmdbbackend \
luabackend \
lua2backend \
- mydnsbackend \
opendbxbackend \
pipebackend \
randombackend \
+++ /dev/null
-AM_CPPFLAGS += $(MYSQL_CFLAGS)
-pkglib_LTLIBRARIES = libmydnsbackend.la
-
-EXTRA_DIST = \
- OBJECTFILES \
- OBJECTLIBS \
- schema.mydns.sql
-
-dist_doc_DATA = schema.mydns.sql
-
-libmydnsbackend_la_SOURCES = \
- mydnsbackend.cc mydnsbackend.hh
-
-libmydnsbackend_la_LDFLAGS = -module -avoid-version
-libmydnsbackend_la_LIBADD = \
- ../gmysqlbackend/smysql.lo \
- $(MYSQL_LIBS)
+++ /dev/null
-mydnsbackend.lo
+++ /dev/null
-$(MYSQL_LIBS)
+++ /dev/null
-/*
- * This file is part of PowerDNS or dnsdist.
- * Copyright -- PowerDNS.COM B.V. and its contributors
- * originally authored by Jonathan Oddy
- *
- * 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.
- */
-
-/*
- * The schema used by MyDNS isn't suitable for retrieving results with a single
- * query. This means that existing PowerDNS backends are unable to make use of
- * the schema without lame hackery (or awful performance.) This module does
- * the nasty lookup logic required to make use of the schema, and should be as
- * tolerant as MyDNS when it comes to things being fully qualified or not.
- *
- * A known "bug" is that AXFRs will fail if your rr table contains invalid
- * junk. I'm not sure this is really a bug, if you've decided to put free-form
- * text in your data for an A record you have bigger issues.
- *
- * I'd advise avoiding the MyDNS schema if at all possible as the query count
- * for even simple lookups is daft. It's quite trivial to craft a request
- * that'll require 128 database queries to answer with a servfail!
- *
- * If you do not know what mydns is: http://mydns.bboy.net/
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string>
-#include <map>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sstream>
-
-#include "pdns/namespaces.hh"
-
-#include "pdns/dns.hh"
-#include "pdns/dnsbackend.hh"
-#include "mydnsbackend.hh"
-#include "pdns/dnspacket.hh"
-#include "pdns/pdnsexception.hh"
-#include "pdns/logger.hh"
-#include "pdns/arguments.hh"
-
-#include <modules/gmysqlbackend/smysql.hh>
-
-static string backendName="[MyDNSbackend]";
-
-MyDNSBackend::MyDNSBackend(const string &suffix) {
- setArgPrefix("mydns"+suffix);
-
- try {
- d_db = new SMySQL(getArg("dbname"),
- getArg("host"),
- getArgAsNum("port"),
- getArg("socket"),
- getArg("user"),
- getArg("password"));
- d_db->setLog(::arg().mustDo("query-logging"));
- }
- catch(SSqlException &e) {
- g_log<<Logger::Error<<backendName<<" Connection failed: "<<e.txtReason()<<endl;
- throw PDNSException(backendName+"Unable to launch connection: "+e.txtReason());
- }
-
- string rrtable=getArg("rr-table");
- string soatable=getArg("soa-table");
- string rrwhere=(mustDo("rr-active")?"(active = '1' or active = 'Y') and ":"")+getArg("rr-where");
- string soawhere=(mustDo("soa-active")?"(active = '1' or active = 'Y') and ":"")+getArg("soa-where");
-
- if (soatable.empty()) { throw PDNSException("SOA Table must not be empty"); }
- if (rrtable.empty()) { throw PDNSException("Records table must not be empty"); }
-
- d_useminimalttl=mustDo("use-minimal-ttl");
- d_minimum=0;
-
- g_log<<Logger::Warning<<backendName<<" Connection successful"<<endl;
-
- try {
-
- string domainIdQuery = "SELECT origin, minimum FROM `"+soatable+"` WHERE id = ?";
- string domainNoIdQuery = "SELECT id, origin, minimum FROM `"+soatable+"` WHERE origin = ?";
- string soaQuery = "SELECT id, mbox, serial, ns, refresh, retry, expire, minimum, ttl FROM `"+soatable+"` WHERE origin = ?";
- string allDomainsQuery = "SELECT id, origin, serial FROM `"+soatable+"`";
-
- if (!soawhere.empty()) {
- domainIdQuery += " AND " + soawhere;
- domainNoIdQuery += " AND " + soawhere;
- soaQuery += " AND "+soawhere;
- allDomainsQuery += " WHERE "+soawhere;
- }
-
- d_domainIdQuery_stmt = d_db->prepare(domainIdQuery, 1);
- d_domainNoIdQuery_stmt = d_db->prepare(domainNoIdQuery, 1);
- d_soaQuery_stmt = d_db->prepare(soaQuery, 1);
- d_allDomainsQuery_stmt = d_db->prepare(allDomainsQuery, 0);
-
- string listQuery = "SELECT type, data, aux, ttl, zone, name FROM `"+rrtable+"` WHERE zone = ?";
- string basicQuery = "SELECT type, data, aux, ttl, zone FROM `"+rrtable+"` WHERE zone = ? AND (name = ? OR name = ?) AND type = ?";
- string anyQuery = "(SELECT type, data, aux, ttl, zone FROM `"+rrtable+"` WHERE zone = ? AND (name = ? OR name = ?)";
-
- if (!rrwhere.empty()) {
- listQuery += " AND "+rrwhere;
- basicQuery += " AND " + rrwhere;
- anyQuery += " AND " + rrwhere;
- }
-
- d_listQuery_stmt = d_db->prepare(listQuery, 1);
-
- anyQuery += ") UNION (SELECT 'SOA' AS type, CONCAT_WS(' ', ns, mbox,serial,refresh,retry,expire,minimum) AS data, '0' AS aux, ttl, id AS zone FROM `"+soatable+"` WHERE id = ? AND origin = ?";
-
- if (!soawhere.empty()) {
- anyQuery += " AND "+soawhere;
- }
-
- basicQuery += " ORDER BY type,aux,data";
- anyQuery += ") ORDER BY type,aux,data";
-
- d_basicQuery_stmt = d_db->prepare(basicQuery, 4);
- d_anyQuery_stmt = d_db->prepare(anyQuery, 5);
- } catch (SSqlException &e) {
- g_log<<Logger::Error<<"Cannot prepare statements: " << e.txtReason() <<endl;
- throw PDNSException("Cannot prepare statements: " + e.txtReason());
- }
- // keeps static analyzers happy
- d_query_stmt = nullptr;
-}
-
-MyDNSBackend::~MyDNSBackend() {
- d_domainIdQuery_stmt.release();
- d_domainNoIdQuery_stmt.release();
- d_listQuery_stmt.release();
- d_soaQuery_stmt.release();
- d_basicQuery_stmt.release();
- d_anyQuery_stmt.release();
- d_allDomainsQuery_stmt.release();
- delete(d_db);
-}
-
-
-bool MyDNSBackend::list(const DNSName &target, int zoneId, bool include_disabled) {
- string query;
- string sname;
- SSqlStatement::row_t rrow;
-
- try {
- d_domainIdQuery_stmt->
- bind("domain_id", zoneId)->
- execute()->
- getResult(d_result)->
- reset();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to list domain_id "+itoa(zoneId)+": "+e.txtReason());
- }
-
- if (d_result.empty())
- return false; // No such zone
-
- d_origin = d_result[0][0];
- if (d_origin[d_origin.length()-1] == '.')
- d_origin.erase(d_origin.length()-1);
- d_minimum = pdns_stou(d_result[0][1]);
-
- if (d_result.size()>1) {
- g_log<<Logger::Warning<<backendName<<" Found more than one matching origin for zone ID: "<<zoneId<<endl;
- };
-
- try {
- d_query_stmt = &d_listQuery_stmt;
- (*d_query_stmt)->
- bind("domain_id", zoneId)->
- execute();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to list domain_id "+itoa(zoneId)+": "+e.txtReason());
- }
-
- d_qname = "";
- return true;
-}
-
-bool MyDNSBackend::getSOA(const DNSName& name, SOAData& soadata) {
- string query;
- SSqlStatement::row_t rrow;
-
- if (name.empty())
- return false;
-
- try {
- d_soaQuery_stmt->
- bind("origin", name.toString())->
- execute()->
- getResult(d_result)->
- reset();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to get soa for domain "+name.toLogString()+": "+e.txtReason());
- }
-
- if (d_result.empty()) {
- return false;
- }
-
- rrow = d_result[0];
-
- soadata.qname = name;
- soadata.domain_id = pdns_stou(rrow[0]);
- soadata.hostmaster = DNSName(rrow[1]);
- soadata.serial = pdns_stou(rrow[2]);
- soadata.nameserver = DNSName(rrow[3]);
- soadata.refresh = pdns_stou(rrow[4]);
- soadata.retry = pdns_stou(rrow[5]);
- soadata.expire = pdns_stou(rrow[6]);
- soadata.default_ttl = pdns_stou(rrow[7]);
- soadata.ttl = pdns_stou(rrow[8]);
- if (d_useminimalttl) {
- soadata.ttl = std::min(soadata.ttl, soadata.default_ttl);
- }
- soadata.db = this;
-
- if (d_result.size()>1) {
- g_log<<Logger::Warning<<backendName<<" Found more than one matching zone for: "<<name<<endl;
- };
-
- return true;
-}
-
-void MyDNSBackend::lookup(const QType &qtype, const DNSName &qname, int zoneId, DNSPacket *p) {
- SSqlStatement::row_t rrow;
- bool found = false;
-
- DNSName sdom(qname);
- d_origin = "";
-
- if (qname.empty()) {
- return;
- }
-
- DLOG(g_log<<Logger::Debug<<"MyDNSBackend::lookup(" << qtype.getName() << "," << qname << ",p," << zoneId << ")" << endl);
-
- if (zoneId < 0) {
- // First off we need to work out what zone we're working with
- // MyDNS records aren't always fully qualified, so we need to work out the zone ID.
-
-
- do {
- try {
- d_domainNoIdQuery_stmt->
- bind("domain", sdom.toString())->
- execute()->
- getResult(d_result)->
- reset();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
- }
-
- if (d_result.empty() == false) {
- rrow = d_result[0];
- zoneId = pdns_stou(rrow[0]);
- d_origin = stripDot(rrow[1]);
- d_minimum = pdns_stou(rrow[2]);
- found = true;
- break;
- }
-
- } while(sdom.chopOff());
-
- } else {
- try {
- d_domainIdQuery_stmt->
- bind("domain_id", zoneId)->
- execute()->
- getResult(d_result)->
- reset();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
- }
-
- if(d_result.empty()) {
- return; // just return if zone was not found instead of throwing an error
- }
-
- rrow = d_result[0];
-
- found = true;
- d_origin = stripDot(rrow[0]);
- d_minimum = pdns_stou(rrow[1]);
- }
-
- if (found) {
-
- if (d_result.size()>1) {
- g_log<<Logger::Warning<<backendName<<" Found more than one matching zone for: "+d_origin<<endl;
- };
- // We found the zoneId, so we can work out how to find our rr
- string host;
-
- // The host part of the query is the name less the origin
- DNSName origin(d_origin);
- host = qname.makeRelative(origin).toStringNoDot();
-
- try {
-
- if (qtype.getCode()==QType::ANY) {
- DLOG(g_log<<Logger::Debug<<"Running d_anyQuery_stmt with " << zoneId << ", " << host << ", " << sdom << ", " << zoneId <<" , "<< qname << ", " << qtype.getName() << endl);
- d_query_stmt = &d_anyQuery_stmt;
- (*d_query_stmt)->
- bind("domain_id", zoneId)->
- bind("host", host)->
- bind("qname", qname.toString())->
- bind("domain_id", zoneId)-> // this is because positional arguments
- bind("qname2", sdom.toString())->
- execute();
- } else {
- DLOG(g_log<<Logger::Debug<<"Running d_basicQuery_stmt with " << zoneId << ", " << host << ", " << qname << ", " << qtype.getName() << endl);
- d_query_stmt = &d_basicQuery_stmt;
- (*d_query_stmt)->
- bind("domain_id", zoneId)->
- bind("host", host)->
- bind("qname", qname.toString())->
- bind("qtype", qtype.getName())->
- execute();
- }
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+qname.toLogString()+": "+e.txtReason());
- }
-
- d_qname = qname.toString();
- }
-
-}
-
-bool MyDNSBackend::get(DNSResourceRecord &rr) {
- if (d_origin.empty()) {
- if (d_query_stmt) {
- try {
- (*d_query_stmt)->reset();
- } catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+d_qname+": "+e.txtReason());
- }
- d_query_stmt = NULL;
- }
- // This happens if lookup() couldn't find the zone
- return false;
- }
-
- SSqlStatement::row_t rrow;
-
- if ((*d_query_stmt)->hasNextRow()) {
- try {
- (*d_query_stmt)->nextRow(rrow);
- } catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+d_qname+": "+e.txtReason());
- }
- rr.qtype=rrow[0];
- rr.content = rrow[1];
-
- if(!d_qname.empty()) {
- // use this to distinguish between select with 'name' field (list()) and one without
- rr.qname=DNSName(d_qname);
- } else {
- string tmpQname = rrow[5];
-
- //TODO: Refactor
- if (!tmpQname.empty() && tmpQname[tmpQname.length()-1] == '.') {
- tmpQname.erase(tmpQname.length()-1); // Fully qualified, nuke the last .
- } else {
- if (!tmpQname.empty()) {
- tmpQname += ".";
- }
- tmpQname += d_origin; // Not fully qualified
- }
- rr.qname = DNSName(tmpQname);
- }
-
- if (rr.qtype.getCode() == QType::NS || rr.qtype.getCode()==QType::MX ||
- rr.qtype.getCode() == QType::CNAME || rr.qtype.getCode() == QType::PTR) {
- if (!rr.content.empty() && rr.content[rr.content.length()-1] == '.') {
- if (rr.content.length() > 1)
- rr.content.erase(rr.content.length()-1); // Fully qualified, nuke the last .
- } else {
- if (rr.content != ".")
- rr.content += ".";
- rr.content += d_origin;
- }
- }
-
- if (rr.qtype.getCode() == QType::MX || rr.qtype.getCode() == QType::SRV)
- rr.content=rrow[2]+" "+rr.content;
-
- rr.ttl = pdns_stou(rrow[3]);
- if (d_useminimalttl)
- rr.ttl = std::min(rr.ttl, d_minimum);
- rr.domain_id=pdns_stou(rrow[4]);
-
- rr.last_modified=0;
-
- return true;
- }
-
- try {
- (*d_query_stmt)->reset();
- } catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to lookup "+d_qname+": "+e.txtReason());
- }
-
- d_query_stmt = NULL;
-
- return false;
-}
-
-void MyDNSBackend::getAllDomains(vector<DomainInfo> *domains, bool include_disabled) {
- /* include_disabled is unfortunately ignored here */
- try {
- d_allDomainsQuery_stmt->
- execute();
-
- while(d_allDomainsQuery_stmt->hasNextRow()) {
- SSqlStatement::row_t row;
- DomainInfo di;
- d_allDomainsQuery_stmt->nextRow(row);
-
- di.id = pdns_stou(row[0]);
- di.zone = DNSName(row[1]);
- di.serial = pdns_stou(row[2]);
- di.kind = DomainInfo::Native;
- di.backend = this;
-
- domains->push_back(di);
- }
-
- d_allDomainsQuery_stmt->
- reset();
- }
- catch (SSqlException &e) {
- throw PDNSException("MyDNSBackend unable to list all domains: "+e.txtReason());
- }
-}
-
-class MyDNSFactory : public BackendFactory {
-
-public:
- MyDNSFactory() : BackendFactory("mydns") {}
-
- void declareArguments(const string &suffix = "") {
- declare(suffix,"dbname","Pdns backend database name to connect to","mydns");
- declare(suffix,"user","Pdns backend user to connect as","powerdns");
- declare(suffix,"host","Pdns backend host to connect to","");
- declare(suffix,"port","Pdns backend host to connect to","");
- declare(suffix,"password","Pdns backend password to connect with","");
- declare(suffix,"socket","Pdns backend socket to connect to","");
- declare(suffix,"rr-table","Name of RR table to use","rr");
- declare(suffix,"soa-table","Name of SOA table to use","soa");
- declare(suffix,"soa-where","Additional WHERE clause for SOA","1 = 1");
- declare(suffix,"rr-where","Additional WHERE clause for RR","1 = 1");
- declare(suffix,"soa-active","Use the active column in the SOA table","yes");
- declare(suffix,"rr-active","Use the active column in the RR table","yes");
- declare(suffix,"use-minimal-ttl","Setting this to 'yes' will make the backend behave like MyDNS on the TTL values. Setting it to 'no' will make it ignore the minimal-ttl of the zone.","yes");
- }
-
- DNSBackend *make(const string &suffix="") {
- return new MyDNSBackend(suffix);
- }
-
-};
-
-class MyDNSLoader {
-
-public:
- MyDNSLoader() {
- BackendMakers().report(new MyDNSFactory());
- g_log << Logger::Info << "[mydnsbackend] This is the mydns backend version " VERSION
-#ifndef REPRODUCIBLE
- << " (" __DATE__ " " __TIME__ ")"
-#endif
- << " reporting" << endl;
- }
-};
-
-static MyDNSLoader mydnsloader;
+++ /dev/null
-/*
- * This file is part of PowerDNS or dnsdist.
- * Copyright -- PowerDNS.COM B.V. and its contributors
- * originally authored by Jonathan Oddy
- *
- * 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 MYDNSBACKEND_HH
-#define MYDNSBACKEND_HH
-
-#include <string>
-#include <map>
-
-#include "pdns/namespaces.hh"
-
-#include <modules/gmysqlbackend/smysql.hh>
-
-class MyDNSBackend : public DNSBackend
-{
-public:
- MyDNSBackend(const string &suffix);
- ~MyDNSBackend();
-
- void lookup(const QType &, const DNSName &qdomain, int zoneId, DNSPacket *p=nullptr) override;
- bool list(const DNSName &target, int domain_id, bool include_disabled=false) override;
- bool get(DNSResourceRecord &r) override;
- bool getSOA(const DNSName& name, SOAData& soadata) override;
- void getAllDomains(vector<DomainInfo> *domains, bool include_disabled=false) override;
-
-private:
- SMySQL *d_db;
-
- string d_qname;
- string d_origin;
- bool d_useminimalttl;
- unsigned int d_minimum;
-
- SSqlStatement::result_t d_result;
-
- std::unique_ptr<SSqlStatement>* d_query_stmt;
- std::unique_ptr<SSqlStatement> d_domainIdQuery_stmt;
- std::unique_ptr<SSqlStatement> d_domainNoIdQuery_stmt;
- std::unique_ptr<SSqlStatement> d_listQuery_stmt;
- std::unique_ptr<SSqlStatement> d_soaQuery_stmt;
- std::unique_ptr<SSqlStatement> d_basicQuery_stmt;
- std::unique_ptr<SSqlStatement> d_anyQuery_stmt;
- std::unique_ptr<SSqlStatement> d_allDomainsQuery_stmt;
-};
-
-#endif /* MYDNSBACKEND_HH */
+++ /dev/null
---
--- Table layouts for mydns 1.2.8.31 (Dec 2014)
--- Copyright (C) 2002-2005 Don Moore 2007-2008 Howard Wilkinson
---
--- You might create these tables with a command like:
---
--- $ mydns --create-tables | mysql -hHOST -p -uUSER DATABASE
---
--- Originally licensed under the GNU GPLv2 or higher
-
---
--- Table structure for table 'soa' (zones of authority)
---
-CREATE TABLE IF NOT EXISTS soa (
- id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
- origin CHAR(255) NOT NULL,
- ns CHAR(255) NOT NULL,
- mbox CHAR(255) NOT NULL,
- serial INT UNSIGNED NOT NULL default '1',
- refresh INT UNSIGNED NOT NULL default '28800',
- retry INT UNSIGNED NOT NULL default '7200',
- expire INT UNSIGNED NOT NULL default '604800',
- minimum INT UNSIGNED NOT NULL default '86400',
- ttl INT UNSIGNED NOT NULL default '86400',
- active ENUM('Y', 'N') NOT NULL DEFAULT 'Y',
- UNIQUE KEY (origin)
-) Engine=MyISAM;
-
---
--- Table structure for table 'rr' (resource records)
---
-CREATE TABLE IF NOT EXISTS rr (
- id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
- zone INT UNSIGNED NOT NULL,
- name CHAR(200) NOT NULL,
- data VARBINARY(128) NOT NULL,
- aux INT UNSIGNED NOT NULL,
- ttl INT UNSIGNED NOT NULL default '86400',
- type ENUM('A','AAAA','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT'),
- active ENUM('Y', 'N') NOT NULL DEFAULT 'Y',
- UNIQUE KEY rr (zone,name,type,data,aux,active)
-) Engine=MyISAM;
StatBag S;
-enum dbmode_t {MYSQL, POSTGRES, SQLITE, MYDNS};
+enum dbmode_t {MYSQL, POSTGRES, SQLITE};
static dbmode_t g_mode;
static bool g_intransaction;
static int g_numRecords;
if(g_mode==POSTGRES) {
cout<<"COMMIT WORK;"<<endl;
}
- else if(g_mode == MYSQL || g_mode == SQLITE || g_mode == MYDNS) {
+ else if(g_mode == MYSQL || g_mode == SQLITE) {
cout<<"COMMIT;"<<endl;
}
}
g_intransaction=1;
- if(g_mode == MYSQL || g_mode == MYDNS)
+ if(g_mode == MYSQL)
cout<<"BEGIN;"<<endl;
else
cout<<"BEGIN TRANSACTION;"<<endl;
sqlstr(stripDotContent(content))<<", "<<ttl<<", "<<prio<<", '"<<(disabled ? 't': 'f') <<
"' from domains where name="<<toLower(sqlstr(zname))<<";\n";
}
- else if (g_mode == MYDNS) {
- string zoneNameDot = zname + ".";
- if (qtype == "A" || qtype == "AAAA" || qtype == "CNAME" || qtype == "HINFO" || qtype == "MX" || qtype == "NAPTR" ||
- qtype == "NS" || qtype == "PTR" || qtype == "RP" || qtype == "SRV" || qtype == "TXT")
- {
- if ((qtype == "MX" || qtype == "NS" || qtype == "SRV" || qtype == "CNAME") && content[content.size()-1] != '.')
- content.append(".");
- cout<<"INSERT INTO rr(zone, name, type, data, aux, ttl) VALUES("<<
- "(SELECT id FROM soa WHERE origin = "<<
- sqlstr(toLower(zoneNameDot))<<"), "<<
- sqlstr(toLower(DNSqname.toString()))<<", "<<
- sqlstr(qtype)<<", "<<sqlstr(content)<<", "<<prio<<", "<<ttl<<");\n";
- }
- else if (qtype == "SOA") {
- //pdns CONTENT = ns1.wtest.com. ahu.example.com. 2005092501 28800 7200 604800 86400
- vector<string> parts;
- stringtok(parts, content);
-
- cout<<"INSERT INTO soa(origin, ns, mbox, serial, refresh, retry, expire, minimum, ttl) VALUES("<<
- sqlstr(toLower(zoneNameDot))<<", "<<sqlstr(parts[0])<<", "<<sqlstr(parts[1])<<", "<<pdns_stou(parts[2])<<", "<<
- pdns_stou(parts[3])<<", "<<pdns_stou(parts[4])<<", "<<pdns_stou(parts[5])<<", "<<pdns_stou(parts[6])<<", "<<ttl<<");\n";
- }
- else
- {
- cerr<<"Record type "<<qtype<<" is not supported."<<endl;
- }
- }
}
::arg().setSwitch("gpgsql","Output in format suitable for default gpgsqlbackend")="no";
::arg().setSwitch("gmysql","Output in format suitable for default gmysqlbackend")="no";
- ::arg().setSwitch("mydns","Output in format suitable for default mydnsbackend")="no";
::arg().setSwitch("gsqlite","Output in format suitable for default gsqlitebackend")="no";
::arg().setSwitch("verbose","Verbose comments on operation")="no";
::arg().setSwitch("slave","Keep BIND slaves as slaves. Only works with named-conf.")="no";
g_mode=POSTGRES;
else if(::arg().mustDo("gsqlite"))
g_mode=SQLITE;
- else if(::arg().mustDo("mydns"))
- g_mode=MYDNS;
else {
cerr<<"Unknown SQL mode!\n\n";
cerr<<"syntax:"<<endl<<endl;
source ./backends/lmdb-master
;;
- mydns*)
- source ./backends/mydns-master
- ;;
-
opendbx*)
source ./backends/opendbx-master
;;
+++ /dev/null
-case $context in
- mydns)
- [ -z "$MYDNSDB" ] && MYDNSDB=pdnstest
- [ -z "$MYDNSUSER" ] && MYDNSUSER=root
- [ -z "$MYDNSHOST" ] && MYDNSHOST=localhost
- [ -z "$MYDNSPASSWD" ] && MYDNSPASSWD=''
-
- mysqladmin --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" --force drop "$MYDNSDB" \
- || echo ignoring mysqladmin drop failure
- mysqladmin --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" create "$MYDNSDB"
- mysql --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" \
- "$MYDNSDB" < ../modules/mydnsbackend/schema.mydns.sql
-
- tosql mydns | grep -v 'double\.example\.com' | grep -v 'very-long-txt\.test\.com' | mysql --user="$MYDNSUSER" --password="$MYDNSPASSWD" --host="$MYDNSHOST" \
- "$MYDNSDB"
-
- cat > pdns-mydns.conf << __EOF__
-module-dir=./modules
-launch=mydns
-mydns-dbname=$MYDNSDB
-mydns-user=$MYDNSUSER
-mydns-host=$MYDNSHOST
-mydns-password=$MYDNSPASSWD
-__EOF__
- $RUNWRAPPER $PDNS --daemon=no --local-address=$address --local-port=$port --socket-dir=./ \
- --config-dir=. --config-name=mydns \
- --no-shuffle --master \
- --cache-ttl=0 --dname-processing \
- --mydns-rr-active=no --mydns-soa-active=no --mydns-use-minimal-ttl=no &
- skipreasons="nodnssec noent nodyndns nometa noaxfr noalias"
- ;;
-
- *)
- nocontext=yes
-esac
+++ /dev/null
-../../modules/mydnsbackend/.libs/libmydnsbackend.so
\ No newline at end of file
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
remotebackend-pipe remotebackend-unix remotebackend-http remotebackend-zeromq
remotebackend-pipe-dnssec remotebackend-unix-dnssec remotebackend-http-dnssec remotebackend-zeromq-dnssec
+++ /dev/null
-MYDNS backend does not support EUI48 record type.
+++ /dev/null
-MYDNS backend does not support EUI48 record type.
+++ /dev/null
-MYDNS backend does not support LOC record type.
+++ /dev/null
-MYDNS has only 128 chars of data.