aboutsummaryrefslogtreecommitdiff
path: root/dns/powerdns
diff options
context:
space:
mode:
authorCheng-Lung Sung <clsung@FreeBSD.org>2007-04-27 07:25:40 +0000
committerCheng-Lung Sung <clsung@FreeBSD.org>2007-04-27 07:25:40 +0000
commit25d9bf9e394b19f160c1c8222cb4fad0d2be7648 (patch)
tree15b781807be08c962521d767dd45b5a3bb3f32cc /dns/powerdns
parent8434766ac1b3340bde95e4ef2e2fc5a8c8907b9b (diff)
downloadports-25d9bf9e394b19f160c1c8222cb4fad0d2be7648.tar.gz
ports-25d9bf9e394b19f160c1c8222cb4fad0d2be7648.zip
Notes
Diffstat (limited to 'dns/powerdns')
-rw-r--r--dns/powerdns/Makefile17
-rw-r--r--dns/powerdns/distinfo6
-rw-r--r--dns/powerdns/files/patch-opendbx1047
-rw-r--r--dns/powerdns/files/patch-pdns_distributor.hh11
-rw-r--r--dns/powerdns/files/patch-pdns_nameserver.cc14
-rw-r--r--dns/powerdns/files/patch-pdns_qtype_cc15
-rw-r--r--dns/powerdns/files/patch-pdns_tcpreceiver.cc15
-rw-r--r--dns/powerdns/files/pdns.conf106
-rw-r--r--dns/powerdns/files/pdns_mysql.sql50
-rw-r--r--dns/powerdns/files/pdns_postgresql.sql52
-rw-r--r--dns/powerdns/files/pdns_sqlite.sql45
-rw-r--r--dns/powerdns/files/tables-mssql_or_sybase.sql56
-rw-r--r--dns/powerdns/files/tables-mysql.sql57
-rw-r--r--dns/powerdns/files/tables-pgsql.sql57
-rw-r--r--dns/powerdns/files/tables-sqlite.sql51
-rw-r--r--dns/powerdns/pkg-plist11
16 files changed, 336 insertions, 1274 deletions
diff --git a/dns/powerdns/Makefile b/dns/powerdns/Makefile
index 45b144c250c7..221f7bb89e52 100644
--- a/dns/powerdns/Makefile
+++ b/dns/powerdns/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= powerdns
-PORTVERSION= 2.9.20
-PORTREVISION= 6
+PORTVERSION= 2.9.21
CATEGORIES= dns ipv6
MASTER_SITES= http://downloads.powerdns.com/releases/ \
http://mirrors.evolva.ro/powerdns.com/releases/
@@ -27,7 +26,8 @@ LDFLAGS+= -L${LOCALBASE}/lib
CONFIGURE_TARGET= --build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
CONFIGURE_ARGS+= --with-modules="pipe" \
--with-dynmodules="${CONFIGURE_MODULES}" \
- --sysconfdir="${PREFIX}/etc/pdns"
+ --sysconfdir="${PREFIX}/etc/pdns" \
+ --mandir="${PREFIX}/man"
# --enable-debug
SCRIPTS_ENV= WRKDIRPREFIX="${WRKDIRPREFIX}" \
CURDIR2="${.CURDIR}" \
@@ -41,6 +41,7 @@ SUB_FILES= pkg-message
OPTIONS= PGSQL "PostgreSQL backend" on \
MYSQL "MySQL backend" off \
SQLITE "SQLite 2 backend" off \
+ SQLITE3 "SQLite 3 backend" off \
OPENDBX "OpenDBX backend" off \
OPENLDAP "OpenLDAP backend" off \
GEO "Geo backend" off
@@ -97,6 +98,14 @@ PLIST_SUB+= WITHSQLITE=""
PLIST_SUB+= WITHSQLITE="@comment "
.endif
+.if defined(WITH_SQLITE3)
+USE_SQLITE?= 3
+CONFIGURE_MODULES+= "gsqlite3"
+PLIST_SUB+= WITHSQLITE3=""
+.else
+PLIST_SUB+= WITHSQLITE3="@comment "
+.endif
+
.if defined(WITH_OPENDBX)
LIB_DEPENDS+= opendbx.[1-2]:${PORTSDIR}/databases/opendbx
CONFIGURE_MODULES+= "opendbx"
@@ -126,7 +135,7 @@ post-install:
.endif
.if !defined(NOPORTDOCS)
${MKDIR} ${EXAMPLESDIR}
-.for i in pdns.conf pdns_mysql.sql pdns_postgresql.sql pdns_sqlite.sql
+.for i in pdns.conf tables-mssql_or_sybase.sql tables-mysql.sql tables-pgsql.sql tables-sqlite.sql
${INSTALL_DATA} ${FILESDIR}/$i ${EXAMPLESDIR}/
.endfor
.endif
diff --git a/dns/powerdns/distinfo b/dns/powerdns/distinfo
index 8d9a4a9444cf..9e0cb45f04d2 100644
--- a/dns/powerdns/distinfo
+++ b/dns/powerdns/distinfo
@@ -1,3 +1,3 @@
-MD5 (pdns-2.9.20.tar.gz) = 33b20ef1b767f93297101f2aa09e99ed
-SHA256 (pdns-2.9.20.tar.gz) = 28984207c78bc5d40542d40366d74f6695a9cf3a7ec4f431d908966d4fc35e3d
-SIZE (pdns-2.9.20.tar.gz) = 867520
+MD5 (pdns-2.9.21.tar.gz) = a0d650dd1489ed46b36dfcc1d73653af
+SHA256 (pdns-2.9.21.tar.gz) = 4b24db683ba2217caa1edf54545841dcdfa6fd27b66017577d8b0dd54f8e7ed5
+SIZE (pdns-2.9.21.tar.gz) = 991071
diff --git a/dns/powerdns/files/patch-opendbx b/dns/powerdns/files/patch-opendbx
deleted file mode 100644
index fb4404cc2984..000000000000
--- a/dns/powerdns/files/patch-opendbx
+++ /dev/null
@@ -1,1047 +0,0 @@
---- modules/opendbxbackend/odbxbackend.hh 2006-03-15 19:29:39.000000000 +0100
-+++ modules/opendbxbackend/odbxbackend.hh 2007-01-25 22:16:13.000000000 +0100
-@@ -1,11 +1,10 @@
- /*
- * PowerDNS OpenDBX Backend
-- * Copyright (C) 2005 Norbert Sendetzky <norbert@linuxnetworks.de>
-+ * Copyright (C) 2005-2006 Norbert Sendetzky <norbert@linuxnetworks.de>
- *
- * This program is free software; you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License as published by
-- * the Free Software Foundation; either version 2 of the License, or
-- * any later version.
-+ * it under the terms of the GNU General Public License version 2
-+ * as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-@@ -14,7 +13,7 @@
- *
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-@@ -32,7 +31,6 @@
- #include <pdns/arguments.hh>
- #include <pdns/logger.hh>
- #include <odbx.h>
--#include "modules/ldapbackend/utils.hh"
-
-
- #ifndef ODBXBACKEND_HH
-@@ -53,19 +51,23 @@
-
- class OdbxBackend : public DNSBackend
- {
-+ enum QueryType { READ, WRITE };
-+
- string m_myname;
- string m_qname;
- int m_default_ttl;
- bool m_qlog;
-- odbx_t* m_handle;
-+ odbx_t* m_handle[2];
- odbx_result_t* m_result;
- char m_escbuf[BUFLEN];
- char m_buffer[2*BUFLEN];
-+ vector<string> m_hosts[2];
-
-- bool getRecord();
-- void execStmt( const char* stmt, unsigned long length, bool select );
-- void getDomainList( const string& query, vector<DomainInfo>* list, bool (*check_fcn)(u_int32_t,u_int32_t,SOAData*,DomainInfo*) );
-- string escape( const string& str );
-+ string escape( const string& str, QueryType type );
-+ bool connectTo( const vector<string>& host, QueryType type );
-+ bool getDomainList( const string& query, vector<DomainInfo>* list, bool (*check_fcn)(u_int32_t,u_int32_t,SOAData*,DomainInfo*) );
-+ bool execStmt( const char* stmt, unsigned long length, QueryType type );
-+ bool getRecord( QueryType type );
-
-
- public:
-@@ -107,37 +109,40 @@
- void declareArguments( const string &suffix="" )
- {
- declare( suffix, "backend", "OpenDBX backend","mysql" );
-- declare( suffix, "host", "Name or address of one or more DBMS server","127.0.0.1" );
-- declare( suffix, "port", "Port the DBMS server is listening to","" );
-+ 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 domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id'" );
-+ declare( suffix, "sql-list", "AXFR query", "SELECT \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" FROM \"records\" WHERE \"domain_id\"=:id" );
-
-- declare( suffix, "sql-lookup", "Lookup query","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE name=':name'" );
-- declare( suffix, "sql-lookupid", "Lookup query with id","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id' AND name=':name'" );
-- declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE name=':name' AND type=':type'" );
-- declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id' AND name=':name' AND type=':type'" );
-+ declare( suffix, "sql-lookup", "Lookup query","SELECT \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" FROM \"records\" WHERE \"name\"=':name'" );
-+ declare( suffix, "sql-lookupid", "Lookup query with id","SELECT \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" FROM \"records\" WHERE \"domain_id\"=:id AND \"name\"=':name'" );
-+ declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" FROM \"records\" WHERE \"name\"=':name' AND \"type\"=':type'" );
-+ declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT \"domain_id\", \"name\", \"type\", \"ttl\", \"prio\", \"content\" FROM \"records\" WHERE \"domain_id\"=:id AND \"name\"=':name' AND \"type\"=':type'" );
-
-- 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, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.name=':name' AND r.type='SOA' ) OR ( d.name=':name' AND r.domain_id IS NULL )" );
-+ 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\", 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-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-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 \"master\" FROM \"domains\" WHERE \"name\"=':name' AND \"status\"='A' AND \"type\"='SLAVE'" );
-+ declare( suffix, "sql-supermaster","Get supermaster info", "SELECT \"account\" FROM \"supermasters\" WHERE \"ip\"=':ip' AND \"nameserver\"=':ns'" );
-
-- declare( suffix, "sql-master", "Get master record for zone", "SELECT master FROM domains WHERE name=':name' AND type='SLAVE'" );
-- declare( suffix, "sql-supermaster","Get supermaster info", "SELECT account FROM supermasters WHERE ip=':ip' AND nameserver=':ns'" );
-+ declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.\"id\", d.\"name\", d.\"master\", d.\"notified_serial\", d.\"last_check\", r.\"change_date\", 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.\"notified_serial\", d.\"last_check\", r.\"change_date\", r.\"content\" FROM \"domains\" d JOIN \"records\" r ON d.\"id\"=r.\"domain_id\" WHERE d.\"status\"='A' AND d.\"type\"='MASTER' AND r.\"type\"='SOA'" );
-
-- declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.id, d.name, d.master, d.notified_serial, d.last_check, r.change_date, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.type='SLAVE' AND r.type='SOA' ) OR ( d.type='SLAVE' AND r.domain_id IS NULL )" );
-- declare( suffix, "sql-infomasters", "Get all updated masters", "SELECT d.id, d.name, d.master, d.notified_serial, d.last_check, r.change_date, r.content FROM domains AS d, records AS r WHERE d.type='MASTER' AND d.id=r.domain_id AND r.type='SOA'" );
-+ declare( suffix, "host", "depricated, use host-read and host-write instead","" );
- }
-
-
---- modules/opendbxbackend/odbxbackend.cc 2006-03-15 19:29:39.000000000 +0100
-+++ modules/opendbxbackend/odbxbackend.cc 2006-06-17 11:39:04.000000000 +0200
-@@ -2,62 +2,80 @@
-
-
-
--unsigned int odbx_host_index = 0;
-+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;
-+}
-+
-+
-+
-+inline string& toLowerByRef( string& str )
-+{
-+ for( unsigned int i = 0; i < str.length(); i++ )
-+ {
-+ str[i] = dns_tolower( str[i] );
-+ }
-+
-+ return str;
-+}
-
-
-
- OdbxBackend::OdbxBackend( const string& suffix )
- {
-- int err = -1;
-- unsigned int idx, i, h;
- vector<string> 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 );
-- stringtok( hosts, getArg( "host" ), ", " );
-
-- idx = odbx_host_index++ % hosts.size();
--
-- for( i = 0; i < hosts.size(); i++ )
-+ if( getArg( "host" ).size() > 0 )
- {
-- h = ( idx + i ) % hosts.size();
-- if( !( err = odbx_init( &m_handle, getArg( "backend" ).c_str(), hosts[h].c_str(), getArg( "port" ).c_str() ) ) ) { break; }
-+ L.log( m_myname + " WARNING: Using depricated opendbx-host parameter", Logger::Warning );
-+ stringtok( m_hosts[READ], getArg( "host" ), ", " );
-+ m_hosts[WRITE] = m_hosts[READ];
- }
--
-- if( err < 0 )
-+ else
- {
-- L.log( m_myname + " OdbxBackend: Unable to connect to server - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-- throw( AhuException( "Fatal: odbx_init() failed" ) );
-+ stringtok( m_hosts[READ], getArg( "host-read" ), ", " );
-+ stringtok( m_hosts[WRITE], getArg( "host-write" ), ", " );
- }
-
-- if( ( err = odbx_bind_simple( m_handle, getArg( "database" ).c_str(), getArg( "username" ).c_str(), getArg( "password" ).c_str() ) ) < 0 )
-- {
-- L.log( m_myname + " OdbxBackend: Unable to bind to database - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-- throw( AhuException( "Fatal: odbx_bind_simple() failed" ) );
-- }
-+ if( !connectTo( m_hosts[READ], READ ) ) { throw( AhuException( "Fatal: Connecting to server for reading failed" ) ); }
-+ if( !connectTo( m_hosts[WRITE], WRITE ) ) { throw( AhuException( "Fatal: Connecting to server for writing failed" ) ); }
- }
- catch( exception& e )
- {
-- L.log( m_myname + " OdbxBackend: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Fatal: STL exception" ) );
-+ L.log( m_myname + " OdbxBackend(): Caught STL exception - " + e.what(), Logger::Error );
-+ throw( AhuException( "Fatal: STL exception" ) );
- }
--
-- L.log( m_myname + " Connection succeeded", Logger::Notice );
- }
-
-
-
- OdbxBackend::~OdbxBackend()
- {
-- odbx_unbind( m_handle );
-- odbx_finish( m_handle );
-+ odbx_unbind( m_handle[WRITE] );
-+ odbx_unbind( m_handle[READ] );
-+
-+ odbx_finish( m_handle[WRITE] );
-+ odbx_finish( m_handle[READ] );
- }
-
-
-@@ -65,17 +83,17 @@
- bool OdbxBackend::getDomainInfo( const string& domain, DomainInfo& di )
- {
- const char* tmp;
-- string stmt;
-
-
- try
- {
- DLOG( L.log( m_myname + " getDomainInfo()", Logger::Debug ) );
-
-- stmt = strbind( ":name", escape( toLower( domain ) ), getArg( "sql-zoneinfo" ) );
-- execStmt( stmt.c_str(), stmt.size(), true );
-+ string stmt = getArg( "sql-zoneinfo" );
-+ string& stmtref = strbind( ":name", escape( toLower( domain ), READ ), stmt );
-
-- if( !getRecord() ) { return false; }
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; }
-+ if( !getRecord( READ ) ) { return false; }
-
- do
- {
-@@ -95,7 +113,7 @@
-
- if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL )
- {
-- di.zone = string( tmp );
-+ di.zone = string( tmp, odbx_field_length( m_result, 1 ) );
- }
-
- if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL )
-@@ -112,7 +130,7 @@
-
- if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL )
- {
-- di.master = string( tmp );
-+ di.master = string( tmp, odbx_field_length( m_result, 3 ) );
- }
-
- if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL )
-@@ -125,16 +143,16 @@
- SOAData sd;
-
- sd.serial = 0;
-- DNSPacket::fillSOAData( string( tmp ), sd );
-+ DNSPacket::fillSOAData( string( tmp, odbx_field_length( m_result, 6 ) ), sd );
- di.serial = sd.serial;
- }
- }
-- while( getRecord() );
-+ while( getRecord( READ ) );
- }
- catch( exception& e )
- {
- L.log( m_myname + " getDomainInfo: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -144,11 +162,6 @@
-
- bool OdbxBackend::list( const string& target, int zoneid )
- {
-- string stmt;
-- size_t len;
--
--
--
- try
- {
- DLOG( L.log( m_myname + " list()", Logger::Debug ) );
-@@ -156,22 +169,29 @@
- m_qname = "";
- m_result = NULL;
-
-- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid );
-+ size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid );
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ if( len < 0 )
- {
-- L.log( m_myname + " list: Unable to convert zone id to string", Logger::Error );
-- throw( DBException( "Error: Libc error" ) );
-+ L.log( m_myname + " list: Unable to convert zone id to string - format error", Logger::Error );
-+ return false;
- }
-
-- stmt = strbind( ":id", string( m_buffer, len ), getArg( "sql-list" ) );
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.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 );
-
-- execStmt( stmt.c_str(), stmt.size(), true );
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; }
- }
- catch( exception& e )
- {
- L.log( m_myname + " list: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -181,23 +201,24 @@
-
- void OdbxBackend::lookup( const QType& qtype, const string& qname, DNSPacket* dnspkt, int zoneid )
- {
-- string stmt;
--
--
- try
- {
- DLOG( L.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 = strbind( ":type", qtype.getName(), getArg( "sql-lookuptype" ) );
-+ stmt = getArg( "sql-lookuptype" );
-+ stmtref = strbind( ":type", qtype.getName(), stmt );
- }
- }
- else
-@@ -206,22 +227,34 @@
- {
- stmt = getArg( "sql-lookupid" );
- } else {
-- stmt = strbind( ":type", qtype.getName(), getArg( "sql-lookuptypeid" ) );
-+ stmt = getArg( "sql-lookuptypeid" );
-+ stmtref = strbind( ":type", qtype.getName(), stmt );
- }
--
-+
- size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid );
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ if( len < 0 )
- {
-- L.log( m_myname + " lookup: Unable to convert zone id to string", Logger::Error );
-+ L.log( m_myname + " lookup: Unable to convert zone id to string - format error", Logger::Error );
- throw( DBException( "Error: Libc error" ) );
- }
-
-- stmt = strbind( ":id", string( m_buffer, len ), stmt );
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.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 );
- }
-
-- stmt = strbind( ":name", escape( toLower( qname ) ), stmt );
-- execStmt( stmt.c_str(), stmt.size(), true );
-+ string tmp = qname;
-+ stmtref = strbind( ":name", escape( toLowerByRef( tmp ), READ ), stmtref );
-+
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) )
-+ {
-+ throw( DBException( "Error: DB statement failed" ) );
-+ }
- }
- catch( exception& e )
- {
-@@ -241,7 +274,7 @@
- {
- DLOG( L.log( m_myname + " get()", Logger::Debug ) );
-
-- if( getRecord() )
-+ if( getRecord( READ ) )
- {
- rr.content = "";
- rr.priority = 0;
-@@ -257,7 +290,7 @@
-
- if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL )
- {
-- rr.qname = string( tmp );
-+ rr.qname = string( tmp, odbx_field_length( m_result, 1 ) );
- }
-
- if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL )
-@@ -277,7 +310,7 @@
-
- if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL )
- {
-- rr.content = string( tmp );
-+ rr.content = string( tmp, odbx_field_length( m_result, 5 ) );
- }
-
- return true;
-@@ -286,7 +319,7 @@
- catch( exception& e )
- {
- L.log( m_myname + " get: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return false;
-@@ -302,15 +335,30 @@
- {
- DLOG( L.log( m_myname + " setFresh()", Logger::Debug ) );
-
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.log( m_myname + " setFresh: Master server is unreachable", Logger::Error );
-+ throw( DBException( "Error: Server unreachable" ) );
-+ }
-+
- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-update-lastcheck" ).c_str(), time( 0 ), domain_id );
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ if( len < 0 )
-+ {
-+ L.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 > sizeof( m_buffer ) - 1 )
- {
-- L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "'", Logger::Error );
-+ L.log( m_myname + " setFresh: Unable to insert values into statement '" + getArg( "sql-update-lastcheck" ) + "' - insufficient buffer space", Logger::Error );
- throw( DBException( "Error: Libc error" ) );
- }
-
-- execStmt( m_buffer, len, false );
-+ if( !execStmt( m_buffer, len, WRITE ) )
-+ {
-+ throw( DBException( "Error: DB statement failed" ) );
-+ }
- }
- catch ( exception& e )
- {
-@@ -323,22 +371,34 @@
-
- void OdbxBackend::setNotified( u_int32_t domain_id, u_int32_t serial )
- {
-- size_t len;
--
--
- try
- {
- DLOG( L.log( m_myname + " setNotified()", Logger::Debug ) );
-
-- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-update-serial" ).c_str(), serial, domain_id );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.log( m_myname + " setFresh: Master server is unreachable", Logger::Error );
-+ throw( DBException( "Error: Server unreachable" ) );
-+ }
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-update-serial" ).c_str(), serial, domain_id );
-+
-+ if( len < 0 )
- {
-- L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "'", Logger::Error );
-+ L.log( m_myname + " setNotified: Unable to insert values into statement '" + getArg( "sql-update-serial" ) + "' - format error", Logger::Error );
- throw( DBException( "Error: Libc error" ) );
- }
-
-- execStmt( m_buffer, len, false );
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.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 ( exception& e )
- {
-@@ -351,17 +411,15 @@
-
- bool OdbxBackend::isMaster( const string& domain, const string& ip )
- {
-- string stmt;
--
--
- try
- {
- DLOG( L.log( m_myname + " isMaster()", Logger::Debug ) );
-
-- stmt = strbind( ":name", escape( toLower( domain ) ), getArg( "sql-master" ) );
-- execStmt( stmt.c_str(), stmt.size(), true );
-+ string stmt = getArg( "sql-master" );
-+ string& stmtref = strbind( ":name", escape( toLower( domain ), READ ), stmt );
-
-- if( !getRecord() ) { return false; }
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; }
-+ if( !getRecord( READ ) ) { return false; }
-
- do
- {
-@@ -369,16 +427,17 @@
- {
- if( !strcmp( odbx_field_value( m_result, 0 ), ip.c_str() ) )
- {
-+ while( getRecord( READ ) );
- return true;
- }
- }
- }
-- while( getRecord() );
-+ while( getRecord( READ ) );
- }
- catch ( exception& e )
- {
- L.log( m_myname + " isMaster: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return false;
-@@ -392,15 +451,17 @@
- {
- DLOG( L.log( m_myname + " getUnfreshSlaveInfos()", Logger::Debug ) );
-
-- if( unfresh != NULL )
-+ if( unfresh == NULL )
- {
-- getDomainList( getArg( "sql-infoslaves" ), unfresh, &checkSlave );
-+ L.log( m_myname + " getUnfreshSlaveInfos: invalid parameter - NULL pointer", Logger::Error );
-+ return;
- }
-+
-+ getDomainList( getArg( "sql-infoslaves" ), unfresh, &checkSlave );
- }
- catch ( exception& e )
- {
- L.log( m_myname + " getUnfreshSlaveInfo: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
- }
- }
-
-@@ -412,15 +473,17 @@
- {
- DLOG( L.log( m_myname + " getUpdatedMasters()", Logger::Debug ) );
-
-- if( updated != NULL )
-+ if( updated == NULL )
- {
-- getDomainList( getArg( "sql-infomasters" ), updated, &checkMaster );
-+ L.log( m_myname + " getUpdatedMasters: invalid parameter - NULL pointer", Logger::Error );
-+ return;
- }
-+
-+ getDomainList( getArg( "sql-infomasters" ), updated, &checkMaster );
- }
- catch ( exception& e )
- {
- L.log( m_myname + " getUpdatedMasters: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
- }
- }
-
-@@ -428,43 +491,41 @@
-
- bool OdbxBackend::superMasterBackend( const string& ip, const string& domain, const vector<DNSResourceRecord>& set, string* account, DNSBackend** ddb )
- {
-- string stmt;
-- vector<DNSResourceRecord>::const_iterator i;
--
--
- try
- {
- DLOG( L.log( m_myname + " superMasterBackend()", Logger::Debug ) );
-
- if( account != NULL && ddb != NULL )
- {
-+ vector<DNSResourceRecord>::const_iterator i;
-+
- for( i = set.begin(); i != set.end(); i++ )
- {
-- stmt = strbind( ":ip", escape( ip ), getArg( "sql-supermaster" ) );
-- stmt = strbind( ":ns", escape( i->content ), stmt );
--
-- execStmt( stmt.c_str(), stmt.size(), true );
-+ string stmt = getArg( "sql-supermaster" );
-+ string& stmtref = strbind( ":ip", escape( ip, READ ), stmt );
-+ stmtref = strbind( ":ns", escape( i->content, READ ), stmtref );
-
-- if( !getRecord() ) { return false; }
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), READ ) ) { return false; }
-
-- do
-+ 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() );
-
-- *ddb=this;
-- return true;
-+ while( getRecord( READ ) );
-+
-+ *ddb=this;
-+ return true;
-+ }
- }
- }
- }
- catch ( exception& e )
- {
- L.log( m_myname + " superMasterBackend: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return false;
-@@ -474,28 +535,38 @@
-
- bool OdbxBackend::createSlaveDomain( const string& ip, const string& domain, const string& account )
- {
-- size_t len;
--
--
- try
- {
- DLOG( L.log( m_myname + " createSlaveDomain()", Logger::Debug ) );
-
-- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-slave" ).c_str(), escape( toLower( domain ) ).c_str(),
-- escape( ip ).c_str(), escape( account ).c_str() );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.log( m_myname + " createSlaveDomain: Master server is unreachable", Logger::Error );
-+ return false;
-+ }
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ string tmp = domain;
-+ size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-slave" ).c_str(), escape( toLowerByRef( tmp ), WRITE ).c_str(),
-+ escape( ip, WRITE ).c_str(), escape( account, WRITE ).c_str() );
-+
-+ if( len < 0 )
- {
-- L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "'", Logger::Error );
-- throw( DBException( "Error: Libc error" ) );
-+ L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - format error", Logger::Error );
-+ return false;
-+ }
-+
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.log( m_myname + " createSlaveDomain: Unable to insert values in statement '" + getArg( "sql-insert-slave" ) + "' - insufficient buffer space", Logger::Error );
-+ return false;
- }
-
-- execStmt( m_buffer, len, false );
-+ if( !execStmt( m_buffer, len, WRITE ) ) { return false; }
- }
- catch ( exception& e )
- {
- L.log( m_myname + " createSlaveDomain: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -505,28 +576,39 @@
-
- bool OdbxBackend::feedRecord( const DNSResourceRecord& rr )
- {
-- size_t len;
--
--
- try
- {
- DLOG( L.log( m_myname + " feedRecord()", Logger::Debug ) );
-
-- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-record" ).c_str(), rr.domain_id,
-- escape( toLower( rr.qname ) ).c_str(), rr.qtype.getName().c_str(), rr.ttl, rr.priority, escape( rr.content ).c_str() );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.log( m_myname + " feedRecord: Master server is unreachable", Logger::Error );
-+ return false;
-+ }
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ string tmp = rr.qname;
-+ size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, getArg( "sql-insert-record" ).c_str(), rr.domain_id,
-+ escape( toLowerByRef( tmp ), WRITE ).c_str(), rr.qtype.getName().c_str(), rr.ttl, rr.priority,
-+ escape( rr.content, WRITE ).c_str() );
-+
-+ if( len < 0 )
- {
-- L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "'", Logger::Error );
-- throw( DBException( "Error: Libc error" ) );
-+ L.log( m_myname + " feedRecord: Unable to insert values in statement '" + getArg( "sql-insert-record" ) + "' - format error", Logger::Error );
-+ return false;
- }
-
-- execStmt( m_buffer, len, false );
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.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 ( exception& e )
- {
- L.log( m_myname + " feedRecord: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -536,33 +618,41 @@
-
- bool OdbxBackend::startTransaction( const string& domain, int zoneid )
- {
-- size_t len;
-- string stmt;
--
--
- try
- {
- DLOG( L.log( m_myname + " startTransaction()", Logger::Debug ) );
-
-- stmt = getArg( "sql-transactbegin" );
-- execStmt( stmt.c_str(), stmt.size(), false );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.log( m_myname + " startTransaction: Master server is unreachable", Logger::Error );
-+ return false;
-+ }
-
-- len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid );
-+ string& stmtref = const_cast<string&>( getArg( "sql-transactbegin" ) );
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; }
-
-- if( len < 0 || len > sizeof( m_buffer ) - 1 )
-+ size_t len = snprintf( m_buffer, sizeof( m_buffer ) - 1, "%d", zoneid );
-+
-+ if( len < 0 )
- {
-- L.log( m_myname + " lookup: Unable to convert zone id to string", Logger::Error );
-- throw( DBException( "Error: Libc error" ) );
-+ L.log( m_myname + " startTransaction: Unable to convert zone id to string - format error", Logger::Error );
-+ return false;
- }
-
-- stmt = strbind( ":id", string( m_buffer, len ), getArg( "sql-zonedelete" ) );
-+ if( len > sizeof( m_buffer ) - 1 )
-+ {
-+ L.log( m_myname + " startTransaction: Unable to convert zone id to string - insufficient buffer space", Logger::Error );
-+ return false;
-+ }
-
-- execStmt( stmt.c_str(), stmt.size(), false );
-+ string stmt = getArg( "sql-zonedelete" );
-+ stmtref = strbind( ":id", string( m_buffer, len ), stmt );
-+ if( !execStmt( stmtref.c_str(), stmtref.size(), WRITE ) ) { return false; }
- }
- catch ( exception& e )
- {
- L.log( m_myname + " startTransaction: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -576,12 +666,19 @@
- {
- DLOG( L.log( m_myname + " commitTransaction()", Logger::Debug ) );
-
-- execStmt( getArg( "sql-transactend" ).c_str(), getArg( "sql-transactend" ).size(), false );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.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 ( exception& e )
- {
- L.log( m_myname + " commitTransaction: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
-@@ -595,12 +692,19 @@
- {
- DLOG( L.log( m_myname + " abortTransaction()", Logger::Debug ) );
-
-- execStmt( getArg( "sql-transactabort" ).c_str(), getArg( "sql-transabort" ).size(), false );
-+ if( !m_handle[WRITE] && !connectTo( m_hosts[WRITE], WRITE ) )
-+ {
-+ L.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 ( exception& e )
- {
- L.log( m_myname + " abortTransaction: Caught STL exception - " + e.what(), Logger::Error );
-- throw( DBException( "Error: STL exception" ) );
-+ return false;
- }
-
- return true;
---- modules/opendbxbackend/odbxprivate.cc 2006-03-15 19:29:39.000000000 +0100
-+++ modules/opendbxbackend/odbxprivate.cc 2007-02-16 21:42:05.000000000 +0100
-@@ -2,7 +2,50 @@
-
-
-
--void OdbxBackend::execStmt( const char* stmt, unsigned long length, bool select )
-+unsigned int odbx_host_index[2] = { 0, 0 };
-+
-+
-+
-+bool OdbxBackend::connectTo( const vector<string>& hosts, QueryType type )
-+{
-+ int err;
-+ unsigned int h, i;
-+ int idx = odbx_host_index[type]++ % hosts.size();
-+
-+
-+ if( m_handle[type] != NULL )
-+ {
-+ odbx_unbind( m_handle[type] );
-+ odbx_finish( m_handle[type] );
-+ m_handle[type] = NULL;
-+ }
-+
-+ for( i = 0; i < hosts.size(); i++ )
-+ {
-+ h = ( idx + i ) % hosts.size();
-+
-+ if( ( err = odbx_init( &(m_handle[type]), getArg( "backend" ).c_str(), hosts[h].c_str(), getArg( "port" ).c_str() ) ) == ODBX_ERR_SUCCESS )
-+ {
-+ if( ( err = odbx_bind( m_handle[type], getArg( "database" ).c_str(), getArg( "username" ).c_str(), getArg( "password" ).c_str(), ODBX_BIND_SIMPLE ) ) == ODBX_ERR_SUCCESS )
-+ {
-+ L.log( m_myname + " Database connection (" + (type ? "write" : "read") + ") to '" + hosts[h] + "' succeeded", Logger::Notice );
-+ return true;
-+ }
-+
-+ L.log( m_myname + " Unable to bind to database on host " + hosts[h] + " - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
-+ continue;
-+ }
-+
-+ L.log( m_myname + " Unable to connect to server on host " + hosts[h] + " - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
-+ }
-+
-+ m_handle[type] = NULL;
-+ return false;
-+}
-+
-+
-+
-+bool OdbxBackend::execStmt( const char* stmt, unsigned long length, QueryType type )
- {
- int err;
-
-@@ -11,18 +54,23 @@
-
- if( m_qlog ) { L.log( m_myname + " Query: " + stmt, Logger::Info ); }
-
-- if( ( err = odbx_query( m_handle, stmt, length ) ) < 0 )
-+ if( ( err = odbx_query( m_handle[type], stmt, length ) ) < 0 )
- {
-- L.log( m_myname + " execStmt: Unable to execute query - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-- throw( AhuException( "Error: odbx_query() failed" ) );
-+ L.log( m_myname + " execStmt: Unable to execute query - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
-+
-+ if( err != -ODBX_ERR_PARAM && odbx_error_type( m_handle[type], err ) > 0 ) { return false; } // ODBX_ERR_PARAM workaround
-+ if( !connectTo( m_hosts[type], type ) ) { return false; }
-+ if( odbx_query( m_handle[type], stmt, length ) < 0 ) { return false; }
- }
-
-- if( !select ) { while( getRecord() ); }
-+ if( type == WRITE ) { while( getRecord( type ) ); }
-+
-+ return true;
- }
-
-
-
--bool OdbxBackend::getRecord()
-+bool OdbxBackend::getRecord( QueryType type )
- {
- int err = 3;
-
-@@ -31,13 +79,19 @@
-
- do
- {
-+ if( err < 0 )
-+ {
-+ L.log( m_myname + " getRecord: Unable to get next result - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
-+ throw( AhuException( "Error: odbx_result() failed" ) );
-+ }
-+
- if( m_result != NULL )
- {
- if( err == 3 )
- {
- if( ( err = odbx_row_fetch( m_result ) ) < 0 )
- {
-- L.log( m_myname + " getRecord: Unable to get next row - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-+ L.log( m_myname + " getRecord: Unable to get next row - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
- throw( AhuException( "Error: odbx_row_fetch() failed" ) );
- }
-
-@@ -72,13 +126,7 @@
- m_result = NULL;
- }
- }
-- while( ( err = odbx_result( m_handle, &m_result, NULL, 0 ) ) > 0 );
--
-- if( err < 0 )
-- {
-- L.log( m_myname + " getRecord: Unable to get next result - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-- throw( AhuException( "Error: odbx_result() failed" ) );
-- }
-+ while( ( err = odbx_result( m_handle[type], &m_result, NULL, 0 ) ) != 0 );
-
- m_result = NULL;
- return false;
-@@ -86,18 +134,21 @@
-
-
-
--string OdbxBackend::escape( const string& str )
-+string OdbxBackend::escape( const string& str, QueryType type )
- {
- int err;
- unsigned long len = sizeof( m_escbuf );
-
-
-- DLOG( L.log( m_myname + " escape()", Logger::Debug ) );
-+ DLOG( L.log( m_myname + " escape(string)", Logger::Debug ) );
-
-- if( ( err = odbx_escape( m_handle, str.c_str(), str.size(), m_escbuf, &len ) ) < 0 )
-+ if( ( err = odbx_escape( m_handle[type], str.c_str(), str.size(), m_escbuf, &len ) ) < 0 )
- {
-- L.log( m_myname + " escape: Unable to escape string - " + string( odbx_error( m_handle, err ) ), Logger::Error );
-- throw( AhuException( "Error: odbx_escape() failed" ) );
-+ L.log( m_myname + " escape(string): Unable to escape string - " + string( odbx_error( m_handle[type], err ) ), Logger::Error );
-+
-+ if( err != -ODBX_ERR_PARAM && odbx_error_type( m_handle[type], err ) > 0 ) { throw( runtime_error( "odbx_escape() failed" ) ); } // ODBX_ERR_PARAM workaround
-+ if( !connectTo( m_hosts[type], type ) ) { throw( runtime_error( "odbx_escape() failed" ) ); }
-+ if( odbx_escape( m_handle[type], str.c_str(), str.size(), m_escbuf, &len ) < 0 ) { throw( runtime_error( "odbx_escape() failed" ) ); }
- }
-
- return string( m_escbuf, len );
-@@ -105,7 +156,7 @@
-
-
-
--void OdbxBackend::getDomainList( const string& stmt, vector<DomainInfo>* list, bool (*check_fcn)(u_int32_t,u_int32_t,SOAData*,DomainInfo*) )
-+bool OdbxBackend::getDomainList( const string& stmt, vector<DomainInfo>* list, bool (*check_fcn)(u_int32_t,u_int32_t,SOAData*,DomainInfo*) )
- {
- const char* tmp;
- u_int32_t nlast, nserial;
-@@ -115,9 +166,8 @@
-
- DLOG( L.log( m_myname + " getDomainList()", Logger::Debug ) );
-
-- execStmt( stmt.c_str(), stmt.size(), true );
--
-- if( !getRecord() ) { return; }
-+ if( !execStmt( stmt.c_str(), stmt.size(), READ ) ) { return false; }
-+ if( !getRecord( READ ) ) { return false; }
-
- do
- {
-@@ -128,7 +178,7 @@
-
- if( ( tmp = odbx_field_value( m_result, 6 ) ) != NULL )
- {
-- DNSPacket::fillSOAData( string( tmp ), sd );
-+ DNSPacket::fillSOAData( string( tmp, odbx_field_length( m_result, 6 ) ), sd );
- }
-
- if( !sd.serial && ( tmp = odbx_field_value( m_result, 5 ) ) != NULL )
-@@ -171,7 +221,9 @@
- list->push_back( di );
- }
- }
-- while( getRecord() );
-+ while( getRecord( READ ) );
-+
-+ return true;
- }
-
-
diff --git a/dns/powerdns/files/patch-pdns_distributor.hh b/dns/powerdns/files/patch-pdns_distributor.hh
deleted file mode 100644
index 784fd3603362..000000000000
--- a/dns/powerdns/files/patch-pdns_distributor.hh
+++ /dev/null
@@ -1,11 +0,0 @@
---- pdns/distributor.hh.org Wed Mar 15 19:29:38 2006
-+++ pdns/distributor.hh Wed Feb 7 19:42:24 2007
-@@ -198,7 +198,7 @@
- return 0;
- }
- catch(...) {
-- L<<Logger::Error<<Logger::NTLog<<"Caught unknown exception in Distributor thread "<<(unsigned int)pthread_self()<<endl;
-+ L<<Logger::Error<<Logger::NTLog<<"Caught unknown exception in Distributor thread "<<(unsigned long)pthread_self()<<endl;
- delete b;
- return 0;
- }
diff --git a/dns/powerdns/files/patch-pdns_nameserver.cc b/dns/powerdns/files/patch-pdns_nameserver.cc
deleted file mode 100644
index fc7334537c61..000000000000
--- a/dns/powerdns/files/patch-pdns_nameserver.cc
+++ /dev/null
@@ -1,14 +0,0 @@
---- pdns/nameserver.cc.orig Sun Nov 19 16:09:10 2006
-+++ pdns/nameserver.cc Sun Nov 19 16:10:28 2006
-@@ -145,9 +145,9 @@
- }
-
- sockaddr_in6 locala;
-- locala.sin6_port=ntohs(arg().asNum("local-port"));
-+ memset(&locala, 0, sizeof(locala));
-+ locala.sin6_port=htons(arg().asNum("local-port"));
- locala.sin6_family=AF_INET6;
-- locala.sin6_flowinfo=0;
-
- if(!inet_pton(AF_INET6, localname.c_str(), (void *)&locala.sin6_addr)) {
- addrinfo *addrinfos;
diff --git a/dns/powerdns/files/patch-pdns_qtype_cc b/dns/powerdns/files/patch-pdns_qtype_cc
new file mode 100644
index 000000000000..4a4c86b924ee
--- /dev/null
+++ b/dns/powerdns/files/patch-pdns_qtype_cc
@@ -0,0 +1,15 @@
+===================================================================
+--- pdns/qtype.cc (revision 978)
++++ pdns/qtype.cc (revision 1046)
+@@ -57,6 +57,11 @@
+ insert("LOC",29);
+ insert("SRV",33);
++ insert("CERT", 37);
+ insert("A6",38);
+ insert("NAPTR",35);
++ insert("DS", 43);
++ insert("SSHFP", 44);
++ insert("RRSIG", 46);
++ insert("DNSKEY", 48);
+ insert("SPF",99);
+ insert("AXFR",252);
diff --git a/dns/powerdns/files/patch-pdns_tcpreceiver.cc b/dns/powerdns/files/patch-pdns_tcpreceiver.cc
deleted file mode 100644
index 7d7baba77fdc..000000000000
--- a/dns/powerdns/files/patch-pdns_tcpreceiver.cc
+++ /dev/null
@@ -1,15 +0,0 @@
---- pdns/tcpreceiver.cc.orig Sun Nov 19 16:11:25 2006
-+++ pdns/tcpreceiver.cc Sun Nov 19 16:13:27 2006
-@@ -480,10 +480,9 @@
- throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
-
- sockaddr_in6 locala;
-- locala.sin6_port=ntohs(arg().asNum("local-port"));
-+ memset(&locala, 0, sizeof(locala));
-+ locala.sin6_port=htons(arg().asNum("local-port"));
- locala.sin6_family=AF_INET6;
-- locala.sin6_flowinfo=0;
--
-
- if(!inet_pton(AF_INET6, laddr->c_str(), (void *)&locala.sin6_addr)) {
- addrinfo *addrinfos;
diff --git a/dns/powerdns/files/pdns.conf b/dns/powerdns/files/pdns.conf
index a11889e2b6a4..c539c38c2b81 100644
--- a/dns/powerdns/files/pdns.conf
+++ b/dns/powerdns/files/pdns.conf
@@ -12,28 +12,49 @@
#gpgsql-user=pdns
#gpgsql-password=pdns
-# SQLite
+# SQLite 2
#launch=gsqlite
#gsqlite-database=<path to your SQLite database>
-# OpenDBX
+# SQLite 3
+#launch=gsqlite3
+#gsqlite3-database=<path to your SQLite database>
+
+# LDAP (check http://www.linuxnetworks.de for more information)
+#launch=ldap
+#ldap-host (default "127.0.0.1:389")
+#ldap-starttls (default "no")
+#ldap-basedn (default "")
+#ldap-binddn (default "")
+#ldap-secret (default "")
+#ldap-method (default "simple")
+#ldap-filter-axfr (default "(:target:)" )
+ldap-filter-lookup (default "(:target:)" )
+
+# OpenDBX (check http://www.linuxnetworks.de for more information)
#launch=opendbx
-#opendbx-backend=mysql
-#opendbx-host=127.0.0.1
-#opendbx-database=pdns
-#opendbx-username=pdns
-#opendbx-password=pdns
+#opendbx-backend (default "mysql")
+#opendbx-host-read (default "127.0.0.1")
+#opendbx-host-write (default "127.0.0.1")
+#opendbx-database (default "powerdns")
+#opendbx-username (default "powerdns")
+#opendbx-password (default "")
# Autogenerated configuration file template
#################################
-# allow-axfr-ips If disabled, DO allow zonetransfers from these IP addresses
+# allow-axfr-ips Allow zonetransfers only to these subnets
#
-# allow-axfr-ips=
+# allow-axfr-ips=0.0.0.0/0
#################################
-# allow-recursion List of netmasks that are allowed to recurse
+# allow-recursion List of subnets that are allowed to recurse
#
-# allow-recursion=
+# allow-recursion=0.0.0.0/0
+
+#################################
+# allow-recursion-override Set this so that local data fully overrides the recursor
+#
+# allow-recursion-override=no
#################################
# cache-ttl Seconds to store packets in the PacketCache
@@ -48,7 +69,7 @@
#################################
# config-dir Location of configuration directory (pdns.conf)
#
-# config-dir=/usr/local/etc/pdns
+# config-dir=/usr/local/etc
#################################
# config-name Name of this virtual configuration - will rename the binary image
@@ -71,6 +92,11 @@
# default-soa-name=a.misconfigured.powerdns.server
#################################
+# default-ttl Seconds a result is valid if not set otherwise
+#
+# default-ttl=3600
+
+#################################
# disable-axfr Disable zonetransfers but do allow TCP queries
#
# disable-axfr=no
@@ -86,6 +112,11 @@
# distributor-threads=3
#################################
+# do-ipv6-additional-processing Do AAAA additional processing
+#
+# do-ipv6-additional-processing=no
+
+#################################
# fancy-records Process URL and MBOXFW records
#
# fancy-records=no
@@ -111,7 +142,7 @@
# load-modules=
#################################
-# local-address Local IP address to which we bind
+# local-address Local IP addresses to which we bind
#
# local-address=0.0.0.0
@@ -126,7 +157,7 @@
# local-port=53
#################################
-# log-dns-details If PDNS should log failed update requests
+# log-dns-details If PDNS should log DNS non-erroneous details
#
# log-dns-details=
@@ -168,7 +199,7 @@
#################################
# module-dir Default directory for modules
#
-# module-dir=/usr/local/bin/../lib
+# module-dir=/usr/local/lib
#################################
# negquery-cache-ttl Seconds to store packets in the PacketCache
@@ -176,14 +207,19 @@
# negquery-cache-ttl=60
#################################
-# only-soa Make sure that no SOA serial is less than this number
+# no-shuffle Set this to prevent random shuffling of answers - for regression testing
#
-# only-soa=org
+# no-shuffle=off
#################################
# out-of-zone-additional-processing Do out of zone additional processing
#
-# out-of-zone-additional-processing=no
+# out-of-zone-additional-processing=yes
+
+#################################
+# pipebackend-abi-version Version of the pipe backend ABI
+#
+# pipebackend-abi-version=1
#################################
# query-cache-ttl Seconds to store packets in the PacketCache
@@ -191,6 +227,11 @@
# query-cache-ttl=20
#################################
+# query-local-address Source IP address for sending queries
+#
+# query-local-address=
+
+#################################
# query-logging Hint backends that queries should be logged
#
# query-logging=no
@@ -201,11 +242,6 @@
# queue-limit=1500
#################################
-# receiver-threads Number of receiver threads to launch
-#
-# receiver-threads=1
-
-#################################
# recursive-cache-ttl Seconds to store packets in the PacketCache
#
# recursive-cache-ttl=10
@@ -216,6 +252,11 @@
# recursor=no
#################################
+# send-root-referral Send out old-fashioned root-referral instead of ServFail in case of no authority
+#
+# send-root-referral=no
+
+#################################
# setgid If set, change group id to this gid for more security
#
# setgid=
@@ -246,26 +287,26 @@
# smtpredirector=a.misconfigured.powerdns.smtp.server
#################################
+# soa-expire-default Default SOA expire
+#
+# soa-expire-default=604800
+
+#################################
# soa-minimum-ttl Default SOA mininum ttl
#
# soa-minimum-ttl=3600
#################################
-# soa-refresh-default Default SOA refresh
+# soa-refresh-default Default SOA refresh
#
# soa-refresh-default=10800
#################################
-# soa-retry-default Default SOA retry
+# soa-retry-default Default SOA retry
#
# soa-retry-default=3600
#################################
-# soa-expire-default Default SOA expire
-#
-# soa-expire-default=604800
-
-#################################
# soa-serial-offset Make sure that no SOA serial is less than this number
#
# soa-serial-offset=0
@@ -291,6 +332,11 @@
# use-logfile=no
#################################
+# version-string PowerDNS version in packets - full, anonymous, powerdns or custom
+#
+# version-string=full
+
+#################################
# webserver Start a webserver for monitoring
#
# webserver=no
diff --git a/dns/powerdns/files/pdns_mysql.sql b/dns/powerdns/files/pdns_mysql.sql
deleted file mode 100644
index 0db1b8665734..000000000000
--- a/dns/powerdns/files/pdns_mysql.sql
+++ /dev/null
@@ -1,50 +0,0 @@
-CREATE TABLE domains (
- id INT auto_increment,
- name VARCHAR(255) NOT NULL,
- type VARCHAR(6) NOT NULL,
- master VARCHAR(40) DEFAULT NULL,
- account VARCHAR(40) DEFAULT NULL,
- notified_serial INT DEFAULT NULL,
- last_check INT DEFAULT NULL,
-CONSTRAINT pk_id
- PRIMARY KEY (id),
-CONSTRAINT unq_name
- UNIQUE (name)
-) type=InnoDB;
-
-
-CREATE TABLE records (
- id INT auto_increment,
- domain_id INT DEFAULT NULL,
- name VARCHAR(255) DEFAULT NULL,
- type VARCHAR(6) DEFAULT NULL,
- ttl INT DEFAULT NULL,
- prio INT DEFAULT NULL,
- content VARCHAR(255) DEFAULT NULL,
- change_date INT DEFAULT NULL,
-CONSTRAINT pk_id
- PRIMARY KEY (id),
-CONSTRAINT fk_domainid
- FOREIGN KEY (domain_id)
- REFERENCES domains(id)
- ON UPDATE CASCADE
- ON DELETE CASCADE
-) type=InnoDB;
-
-CREATE INDEX idx_rdomainid ON records(domain_id);
-CREATE INDEX idx_rname ON records(name);
-CREATE INDEX idx_rname_rtype ON records(name,type);
-
-
-CREATE TABLE supermasters (
- ip VARCHAR(40) NOT NULL,
- nameserver VARCHAR(255) NOT NULL,
- account VARCHAR(40) DEFAULT NULL
-);
-
-CREATE INDEX 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;
diff --git a/dns/powerdns/files/pdns_postgresql.sql b/dns/powerdns/files/pdns_postgresql.sql
deleted file mode 100644
index afeff3a139e0..000000000000
--- a/dns/powerdns/files/pdns_postgresql.sql
+++ /dev/null
@@ -1,52 +0,0 @@
-CREATE TABLE domains (
- id SERIAL,
- name VARCHAR(255) NOT NULL,
- type VARCHAR(6) NOT NULL,
- master VARCHAR(40) DEFAULT NULL,
- account VARCHAR(40) DEFAULT NULL,
- notified_serial INT DEFAULT NULL,
- last_check INT DEFAULT NULL,
-CONSTRAINT pk_id
- PRIMARY KEY (id),
-CONSTRAINT unq_name
- UNIQUE (name)
-);
-
-
-CREATE TABLE records (
- id SERIAL,
- domain_id INT DEFAULT NULL,
- name VARCHAR(255) DEFAULT NULL,
- type VARCHAR(6) DEFAULT NULL,
- ttl INT DEFAULT NULL,
- prio INT DEFAULT NULL,
- content VARCHAR(255) DEFAULT NULL,
- change_date INT DEFAULT NULL,
-CONSTRAINT pk_records_id
- PRIMARY KEY (id),
-CONSTRAINT fk_domainid
- FOREIGN KEY (domain_id)
- REFERENCES domains(id)
- ON UPDATE CASCADE
- ON DELETE CASCADE
-);
-
-CREATE INDEX idx_rdomainid ON records(domain_id);
-CREATE INDEX idx_rname ON records(name);
-CREATE INDEX idx_rname_rtype ON records(name,type);
-
-
-CREATE TABLE supermasters (
- ip VARCHAR(40) NOT NULL,
- nameserver VARCHAR(255) NOT NULL,
- account VARCHAR(40) DEFAULT NULL
-);
-
-CREATE INDEX idx_smip_smns 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;
diff --git a/dns/powerdns/files/pdns_sqlite.sql b/dns/powerdns/files/pdns_sqlite.sql
deleted file mode 100644
index a7f8be90470a..000000000000
--- a/dns/powerdns/files/pdns_sqlite.sql
+++ /dev/null
@@ -1,45 +0,0 @@
-CREATE TABLE domains (
- id INT AUTOINCREMENT,
- name VARCHAR(255) NOT NULL,
- type VARCHAR(6) NOT NULL,
- master VARCHAR(40) DEFAULT NULL,
- account VARCHAR(40) DEFAULT NULL,
- notified_serial INT DEFAULT NULL,
- last_check INT DEFAULT NULL,
-CONSTRAINT pk_id
- PRIMARY KEY (id),
-CONSTRAINT unq_name
- UNIQUE (name)
-);
-
-
-CREATE TABLE records (
- id INT AUTOINCREMENT,
- domain_id INT DEFAULT NULL,
- name VARCHAR(255) DEFAULT NULL,
- type VARCHAR(6) DEFAULT NULL,
- ttl INT DEFAULT NULL,
- prio INT DEFAULT NULL,
- content VARCHAR(255) DEFAULT NULL,
- change_date INT DEFAULT NULL,
-CONSTRAINT pk_id
- PRIMARY KEY (id),
-CONSTRAINT fk_domainid
- FOREIGN KEY (domain_id)
- REFERENCES domains(id)
- ON UPDATE CASCADE
- ON DELETE CASCADE
-);
-
-CREATE INDEX idx_rdomainid ON records(domain_id);
-CREATE INDEX idx_rname ON records(name);
-CREATE INDEX idx_rname_rtype ON records(name,type);
-
-
-CREATE TABLE supermasters (
- ip VARCHAR(40) NOT NULL,
- nameserver VARCHAR(255) NOT NULL,
- account VARCHAR(40) DEFAULT NULL
-);
-
-CREATE INDEX idx_smip_smns ON supermasters(ip,nameserver);
diff --git a/dns/powerdns/files/tables-mssql_or_sybase.sql b/dns/powerdns/files/tables-mssql_or_sybase.sql
new file mode 100644
index 000000000000..5b815186cfee
--- /dev/null
+++ b/dns/powerdns/files/tables-mssql_or_sybase.sql
@@ -0,0 +1,56 @@
+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,
+ "notified_serial" INTEGER NULL,
+ "last_check" INTEGER NULL,
+ "status" CHAR(1) DEFAULT 'A' NOT NULL,
+CONSTRAINT "pk_domains_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "unq_domains_name"
+ UNIQUE ("name")
+);
+
+CREATE INDEX "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 "pk_records_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "fk_records_domainid"
+ FOREIGN KEY ("domain_id")
+ REFERENCES "domains" ("id")
+);
+
+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 "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";
diff --git a/dns/powerdns/files/tables-mysql.sql b/dns/powerdns/files/tables-mysql.sql
new file mode 100644
index 000000000000..c57d45c1dee1
--- /dev/null
+++ b/dns/powerdns/files/tables-mysql.sql
@@ -0,0 +1,57 @@
+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 '',
+ "notified_serial" INTEGER DEFAULT NULL,
+ "last_check" INTEGER DEFAULT NULL,
+ "status" CHAR(1) NOT NULL DEFAULT 'A',
+CONSTRAINT "pk_domains_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "unq_domains_name"
+ UNIQUE ("name")
+) type=InnoDB;
+
+CREATE INDEX "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,
+ "change_date" INTEGER DEFAULT NULL,
+CONSTRAINT "pk_records_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "fk_records_domainid"
+ FOREIGN KEY ("domain_id")
+ REFERENCES "domains" ("id")
+ ON UPDATE CASCADE
+ ON DELETE CASCADE
+) type=InnoDB;
+
+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) NOT NULL DEFAULT ''
+);
+
+CREATE INDEX "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";
diff --git a/dns/powerdns/files/tables-pgsql.sql b/dns/powerdns/files/tables-pgsql.sql
new file mode 100644
index 000000000000..5d8afcb7032c
--- /dev/null
+++ b/dns/powerdns/files/tables-pgsql.sql
@@ -0,0 +1,57 @@
+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 '',
+ "notified_serial" INTEGER DEFAULT NULL,
+ "last_check" INTEGER DEFAULT NULL,
+ "status" CHAR(1) NOT NULL DEFAULT 'A',
+CONSTRAINT "pk_domains_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "unq_domains_name"
+ UNIQUE ("name")
+);
+
+CREATE INDEX "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,
+ "change_date" INTEGER DEFAULT NULL,
+CONSTRAINT "pk_records_id"
+ PRIMARY KEY ("id"),
+CONSTRAINT "fk_records_domainid"
+ FOREIGN KEY ("domain_id")
+ REFERENCES domains ("id")
+ ON UPDATE CASCADE
+ ON DELETE CASCADE
+);
+
+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) NOT NULL DEFAULT ''
+);
+
+CREATE INDEX "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";
diff --git a/dns/powerdns/files/tables-sqlite.sql b/dns/powerdns/files/tables-sqlite.sql
new file mode 100644
index 000000000000..0491ac280d7f
--- /dev/null
+++ b/dns/powerdns/files/tables-sqlite.sql
@@ -0,0 +1,51 @@
+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 '',
+ "notified_serial" INTEGER DEFAULT NULL,
+ "last_check" INTEGER DEFAULT NULL,
+ "status" CHAR(1) NOT NULL DEFAULT 'A',
+CONSTRAINT "unq_domains_name"
+ UNIQUE ("name")
+);
+
+CREATE INDEX "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,
+ "change_date" INTEGER DEFAULT NULL,
+CONSTRAINT "fk_records_domainid"
+ FOREIGN KEY ("domain_id")
+ REFERENCES "domains" ("id")
+ ON UPDATE CASCADE
+ ON DELETE CASCADE
+);
+
+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) NOT NULL DEFAULT ''
+);
+
+CREATE INDEX "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";
diff --git a/dns/powerdns/pkg-plist b/dns/powerdns/pkg-plist
index 272969263ac9..f106a0c8b260 100644
--- a/dns/powerdns/pkg-plist
+++ b/dns/powerdns/pkg-plist
@@ -14,6 +14,10 @@ sbin/pdns_server
%%WITHSQLITE%%lib/libgsqlitebackend.la
%%WITHSQLITE%%lib/libgsqlitebackend.so
%%WITHSQLITE%%lib/libgsqlitebackend.so.0
+%%WITHSQLITE3%%lib/libgsqlite3backend.a
+%%WITHSQLITE3%%lib/libgsqlite3backend.la
+%%WITHSQLITE3%%lib/libgsqlite3backend.so
+%%WITHSQLITE3%%lib/libgsqlite3backend.so.0
%%WITHOPENLDAP%%lib/libldapbackend.a
%%WITHOPENLDAP%%lib/libldapbackend.la
%%WITHOPENLDAP%%lib/libldapbackend.so
@@ -34,8 +38,9 @@ lib/libpipebackend.so.0
etc/pdns/pdns.conf-dist
@exec [ -f %B/pdns.conf ] || cp %B/%f %B/pdns.conf
%%PORTDOCS%%share/examples/powerdns/pdns.conf
-%%PORTDOCS%%share/examples/powerdns/pdns_mysql.sql
-%%PORTDOCS%%share/examples/powerdns/pdns_postgresql.sql
-%%PORTDOCS%%share/examples/powerdns/pdns_sqlite.sql
+%%PORTDOCS%%share/examples/powerdns/tables-mssql_or_sybase.sql
+%%PORTDOCS%%share/examples/powerdns/tables-mysql.sql
+%%PORTDOCS%%share/examples/powerdns/tables-pgsql.sql
+%%PORTDOCS%%share/examples/powerdns/tables-sqlite.sql
%%PORTDOCS%%@dirrm share/examples/powerdns
@dirrmtry etc/pdns