aboutsummaryrefslogtreecommitdiff
path: root/dns
diff options
context:
space:
mode:
authorWesley Shields <wxs@FreeBSD.org>2008-08-27 01:01:00 +0000
committerWesley Shields <wxs@FreeBSD.org>2008-08-27 01:01:00 +0000
commit17e061a129b6be5a913ce112f5b7f193d73f05c1 (patch)
tree286a7eb9053c39b9b31fef32cbf84d598f5be127 /dns
parentd3a548b23d210e5d881630b0469cc299bcc73693 (diff)
downloadports-17e061a129b6be5a913ce112f5b7f193d73f05c1.tar.gz
ports-17e061a129b6be5a913ce112f5b7f193d73f05c1.zip
Notes
Diffstat (limited to 'dns')
-rw-r--r--dns/Makefile1
-rw-r--r--dns/bind9-sdb-postgresql/Makefile143
-rw-r--r--dns/bind9-sdb-postgresql/distinfo6
-rw-r--r--dns/bind9-sdb-postgresql/files/patch-bin__named__Makefile.in17
-rw-r--r--dns/bind9-sdb-postgresql/files/patch-bin__named__main.c26
-rw-r--r--dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.c351
-rw-r--r--dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.h28
-rw-r--r--dns/bind9-sdb-postgresql/pkg-descr3
-rw-r--r--dns/bind9-sdb-postgresql/pkg-message18
-rw-r--r--dns/bind9-sdb-postgresql/pkg-plist232
10 files changed, 825 insertions, 0 deletions
diff --git a/dns/Makefile b/dns/Makefile
index d9e1251912a3..62f215fc7861 100644
--- a/dns/Makefile
+++ b/dns/Makefile
@@ -8,6 +8,7 @@
SUBDIR += bind9
SUBDIR += bind9-dlz
SUBDIR += bind9-sdb-ldap
+ SUBDIR += bind9-sdb-postgresql
SUBDIR += bind94
SUBDIR += bind95
SUBDIR += bindgraph
diff --git a/dns/bind9-sdb-postgresql/Makefile b/dns/bind9-sdb-postgresql/Makefile
new file mode 100644
index 000000000000..5e38e95261bd
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/Makefile
@@ -0,0 +1,143 @@
+# New ports collection makefile for: bind9-sdb-postgresql
+# Date created: 16 Aug 2008
+# Whom: Josh Carroll <josh.carroll@gmail.com>
+#
+# $FreeBSD$
+#
+
+PORTNAME= bind9
+PORTVERSION= 9.4.2.2
+CATEGORIES= dns net ipv6
+MASTER_SITES= ${MASTER_SITE_ISC}
+MASTER_SITE_SUBDIR= bind9/${ISCVERSION}
+PKGNAMESUFFIX= -sdb-postgresql
+DISTNAME= bind-${ISCVERSION}
+DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${DISTNAME}${EXTRACT_SUFX}.asc
+EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX}
+
+MAINTAINER= josh.carroll@gmail.com
+COMMENT= Bind9, patched for use with a PostgreSQL-based backend
+
+CONFLICTS= bind9-9.[35].* bind9-dlz-* bind9-sdb-ldap-* host-*
+
+# ISC releases things like 9.3.0rc1, which our versioning doesn't like
+ISCVERSION= 9.4.2-P2
+
+GNU_CONFIGURE= yes
+CONFIGURE_ARGS= --localstatedir=/var --disable-linux-caps --with-openssl \
+ --with-randomdev=/dev/random
+
+USE_OPENSSL= yes
+USE_PGSQL= yes
+
+OPTIONS= REPLACE_BASE "Replace base BIND with this version" off \
+ LARGE_FILE "64-bit file support" off \
+ SIGCHASE "dig/host/nslookup will do DNSSEC validation" off \
+ IPV6 "IPv6 Support (autodetected by default)" off
+
+.include <bsd.port.pre.mk>
+
+# We are ok by default from 7.0-RELEASE on
+.if ${OSVERSION} >= 700055
+OPTIONS+= THREADS "Compile with thread support" on
+.else
+OPTIONS+= THREADS "Compile w/threads (Not Recommended <FreeBSD-7)" off
+.endif
+
+.if defined(WITH_OPENSSL_PORT)
+CONFIGURE_ARGS+= --with-openssl=${LOCALBASE}
+.else
+CONFIGURE_ARGS+= --with-openssl
+.endif
+
+.if defined(WITH_LARGE_FILE)
+CONFIGURE_ARGS+= --enable-largefile
+.endif
+
+.if defined(WITH_SIGCHASE)
+CONFIGURE_ARGS+= STD_CDEFINES="-DDIG_SIGCHASE=1"
+.endif
+
+.if defined(WITH_IPV6)
+CONFIGURE_ARGS+= --enable-ipv6
+.endif
+
+.if !defined(WITHOUT_THREADS)
+CONFIGURE_ARGS+= --enable-threads
+.else
+CONFIGURE_ARGS+= --disable-threads
+.endif
+
+.if defined(WITH_REPLACE_BASE)
+PKGNAMESUFFIX= -sdb-postgresql-base
+PREFIX= /usr
+BIND_DESTETC= /etc/namedb
+CONFIGURE_ARGS+= --prefix=${PREFIX} \
+ --sysconfdir=${BIND_DESTETC}
+.else
+BIND_DESTETC= ${PREFIX}/etc
+.endif
+
+PLIST_SUB= BIND_DESTETC="${BIND_DESTETC}"
+
+MAN1= dig.1 host.1 nslookup.1
+MAN3= lwres.3 lwres_addr_parse.3 lwres_buffer.3 lwres_buffer_add.3 \
+ lwres_buffer_back.3 lwres_buffer_clear.3 lwres_buffer_first.3 \
+ lwres_buffer_forward.3 lwres_buffer_getmem.3 lwres_buffer_getuint16.3 \
+ lwres_buffer_getuint32.3 lwres_buffer_getuint8.3 lwres_buffer_init.3 \
+ lwres_buffer_invalidate.3 lwres_buffer_putmem.3 \
+ lwres_buffer_putuint16.3 lwres_buffer_putuint32.3 \
+ lwres_buffer_putuint8.3 lwres_buffer_subtract.3 lwres_conf_clear.3 \
+ lwres_conf_get.3 lwres_conf_init.3 lwres_conf_parse.3 \
+ lwres_conf_print.3 lwres_config.3 lwres_context.3 \
+ lwres_context_allocmem.3 lwres_context_create.3 \
+ lwres_context_destroy.3 lwres_context_freemem.3 \
+ lwres_context_initserial.3 lwres_context_nextserial.3 \
+ lwres_context_sendrecv.3 lwres_endhostent.3 lwres_endhostent_r.3 \
+ lwres_freeaddrinfo.3 lwres_freehostent.3 lwres_gabn.3 \
+ lwres_gabnrequest_free.3 lwres_gabnrequest_parse.3 \
+ lwres_gabnrequest_render.3 lwres_gabnresponse_free.3 \
+ lwres_gabnresponse_parse.3 lwres_gabnresponse_render.3 \
+ lwres_gai_strerror.3 lwres_getaddrinfo.3 lwres_getaddrsbyname.3 \
+ lwres_gethostbyaddr.3 lwres_gethostbyaddr_r.3 lwres_gethostbyname.3 \
+ lwres_gethostbyname2.3 lwres_gethostbyname_r.3 lwres_gethostent.3 \
+ lwres_gethostent_r.3 lwres_getipnode.3 lwres_getipnodebyaddr.3 \
+ lwres_getipnodebyname.3 lwres_getnamebyaddr.3 lwres_getnameinfo.3 \
+ lwres_getrrsetbyname.3 lwres_gnba.3 lwres_gnbarequest_free.3 \
+ lwres_gnbarequest_parse.3 lwres_gnbarequest_render.3 \
+ lwres_gnbaresponse_free.3 lwres_gnbaresponse_parse.3 \
+ lwres_gnbaresponse_render.3 lwres_herror.3 lwres_hstrerror.3 \
+ lwres_inetntop.3 lwres_lwpacket_parseheader.3 \
+ lwres_lwpacket_renderheader.3 lwres_net_ntop.3 lwres_noop.3 \
+ lwres_nooprequest_free.3 lwres_nooprequest_parse.3 \
+ lwres_nooprequest_render.3 lwres_noopresponse_free.3 \
+ lwres_noopresponse_parse.3 lwres_noopresponse_render.3 \
+ lwres_packet.3 lwres_resutil.3 lwres_sethostent.3 \
+ lwres_sethostent_r.3 lwres_string_parse.3
+MAN5= named.conf.5 rndc.conf.5
+MAN8= dnssec-keygen.8 dnssec-signzone.8 lwresd.8 named-checkconf.8 \
+ named-checkzone.8 named.8 nsupdate.8 rndc-confgen.8 rndc.8
+MLINKS= named-checkzone.8 named-compilezone.8
+
+post-patch:
+.for FILE in check/named-checkconf.8 named/named.8 nsupdate/nsupdate.8 \
+ rndc/rndc.8
+ @${MV} ${WRKSRC}/bin/${FILE} ${WRKSRC}/bin/${FILE}.Dist
+ @${SED} -e 's#/etc/named.conf#${BIND_DESTETC}/named.conf#g' \
+ -e 's#/etc/rndc.conf#${BIND_DESTETC}/rndc.conf#g' \
+ ${WRKSRC}/bin/${FILE}.Dist > ${WRKSRC}/bin/${FILE}
+.endfor
+
+post-install:
+ ${INSTALL_DATA} ${WRKSRC}/bin/rndc/rndc.conf \
+ ${BIND_DESTETC}/rndc.conf.sample
+.if !defined(NOPORTDOCS)
+ ${MKDIR} ${DOCSDIR}/arm ${DOCSDIR}/misc
+ ${INSTALL_DATA} ${WRKSRC}/doc/arm/Bv9ARM*html ${DOCSDIR}/arm
+ ${INSTALL_DATA} ${WRKSRC}/doc/misc/[a-z]* ${DOCSDIR}/misc
+ ${CP} ${WRKSRC}/CHANGES ${WRKSRC}/COPYRIGHT ${WRKSRC}/FAQ \
+ ${WRKSRC}/README ${DOCSDIR}/
+.endif
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.post.mk>
diff --git a/dns/bind9-sdb-postgresql/distinfo b/dns/bind9-sdb-postgresql/distinfo
new file mode 100644
index 000000000000..6bb862be3a34
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/distinfo
@@ -0,0 +1,6 @@
+MD5 (bind-9.4.2-P2.tar.gz) = 74464f8af260ad71a19a3400a1ae00bb
+SHA256 (bind-9.4.2-P2.tar.gz) = eddf17749abb469bd67213c151450c8e07414d7fcf5a4cd0dc6c03da9656d74d
+SIZE (bind-9.4.2-P2.tar.gz) = 6456550
+MD5 (bind-9.4.2-P2.tar.gz.asc) = 996776035ce9531fef6c3097dd282502
+SHA256 (bind-9.4.2-P2.tar.gz.asc) = 111fa20580d5553d5c40f4d001130f1e33382736b3c32fa6912ffa76d81e73de
+SIZE (bind-9.4.2-P2.tar.gz.asc) = 486
diff --git a/dns/bind9-sdb-postgresql/files/patch-bin__named__Makefile.in b/dns/bind9-sdb-postgresql/files/patch-bin__named__Makefile.in
new file mode 100644
index 000000000000..ab71555ce86d
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/files/patch-bin__named__Makefile.in
@@ -0,0 +1,17 @@
+--- ./bin/named/Makefile.in.orig 2005-09-04 20:18:10.000000000 -0400
++++ ./bin/named/Makefile.in 2008-08-26 12:01:22.000000000 -0400
+@@ -26,10 +26,10 @@
+ #
+ # Add database drivers here.
+ #
+-DBDRIVER_OBJS =
+-DBDRIVER_SRCS =
+-DBDRIVER_INCLUDES =
+-DBDRIVER_LIBS =
++DBDRIVER_OBJS = pgsqldb.@O@
++DBDRIVER_SRCS = pgsqldb.c
++DBDRIVER_INCLUDES = -I../../contrib/sdb/pgsql -I${LOCALBASE}/include
++DBDRIVER_LIBS = -L${LOCALBASE}/lib -lpq
+
+ DLZ_DRIVER_DIR = ${top_srcdir}/contrib/dlz/drivers
+
diff --git a/dns/bind9-sdb-postgresql/files/patch-bin__named__main.c b/dns/bind9-sdb-postgresql/files/patch-bin__named__main.c
new file mode 100644
index 000000000000..3b5a00835e19
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/files/patch-bin__named__main.c
@@ -0,0 +1,26 @@
+--- ./bin/named/main.c.orig 2006-11-10 13:51:14.000000000 -0500
++++ ./bin/named/main.c 2008-08-26 12:01:22.000000000 -0400
+@@ -72,6 +72,7 @@
+ * Include header files for database drivers here.
+ */
+ /* #include "xxdb.h" */
++#include <pgsqldb.h>
+
+ /*
+ * Include DLZ drivers if appropriate.
+@@ -681,6 +682,7 @@
+ * Add calls to register sdb drivers here.
+ */
+ /* xxdb_init(); */
++ pgsqldb_init();
+
+ #ifdef DLZ
+ /*
+@@ -707,6 +709,7 @@
+ * Add calls to unregister sdb drivers here.
+ */
+ /* xxdb_clear(); */
++ pgsqldb_clear();
+
+ #ifdef DLZ
+ /*
diff --git a/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.c b/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.c
new file mode 100644
index 000000000000..2c07fca31a2f
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.c
@@ -0,0 +1,351 @@
+--- ./bin/named/pgsqldb.c.orig 2008-08-26 12:01:22.000000000 -0400
++++ ./bin/named/pgsqldb.c 2008-08-26 12:01:22.000000000 -0400
+@@ -0,0 +1,348 @@
++/*
++ * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
++ * Copyright (C) 2000, 2001 Internet Software Consortium.
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
++ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
++ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
++ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
++ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
++ * PERFORMANCE OF THIS SOFTWARE.
++ */
++
++/* $Id: pgsqldb.c,v 1.13 2004/03/05 05:04:32 marka Exp $ */
++
++#include <config.h>
++
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++
++#include <libpq-fe.h>
++
++#include <isc/mem.h>
++#include <isc/print.h>
++#include <isc/result.h>
++#include <isc/util.h>
++
++#include <dns/sdb.h>
++#include <dns/result.h>
++
++#include <named/globals.h>
++
++#include "pgsqldb.h"
++
++/*
++ * A simple database driver that interfaces to a PostgreSQL database. This
++ * is not complete, and not designed for general use. It opens one
++ * connection to the database per zone, which is inefficient. It also may
++ * not handle quoting correctly.
++ *
++ * The table must contain the fields "name", "rdtype", and "rdata", and
++ * is expected to contain a properly constructed zone. The program "zonetodb"
++ * creates such a table.
++ */
++
++static dns_sdbimplementation_t *pgsqldb = NULL;
++
++struct dbinfo {
++ PGconn *conn;
++ char *database;
++ char *table;
++ char *host;
++ char *user;
++ char *passwd;
++};
++
++static void
++pgsqldb_destroy(const char *zone, void *driverdata, void **dbdata);
++
++/*
++ * Canonicalize a string before writing it to the database.
++ * "dest" must be an array of at least size 2*strlen(source) + 1.
++ */
++static void
++quotestring(const char *source, char *dest) {
++ while (*source != 0) {
++ if (*source == '\'')
++ *dest++ = '\'';
++ /* SQL doesn't treat \ as special, but PostgreSQL does */
++ else if (*source == '\\')
++ *dest++ = '\\';
++ *dest++ = *source++;
++ }
++ *dest++ = 0;
++}
++
++/*
++ * Connect to the database.
++ */
++static isc_result_t
++db_connect(struct dbinfo *dbi) {
++ dbi->conn = PQsetdbLogin(dbi->host, NULL, NULL, NULL, dbi->database,
++ dbi->user, dbi->passwd);
++
++ if (PQstatus(dbi->conn) == CONNECTION_OK)
++ return (ISC_R_SUCCESS);
++ else
++ return (ISC_R_FAILURE);
++}
++
++/*
++ * Check to see if the connection is still valid. If not, attempt to
++ * reconnect.
++ */
++static isc_result_t
++maybe_reconnect(struct dbinfo *dbi) {
++ if (PQstatus(dbi->conn) == CONNECTION_OK)
++ return (ISC_R_SUCCESS);
++
++ return (db_connect(dbi));
++}
++
++/*
++ * This database operates on absolute names.
++ *
++ * Queries are converted into SQL queries and issued synchronously. Errors
++ * are handled really badly.
++ */
++static isc_result_t
++pgsqldb_lookup(const char *zone, const char *name, void *dbdata,
++ dns_sdblookup_t *lookup)
++{
++ isc_result_t result;
++ struct dbinfo *dbi = dbdata;
++ PGresult *res;
++ char str[1500];
++ char *canonname;
++ int i;
++
++ UNUSED(zone);
++
++ canonname = isc_mem_get(ns_g_mctx, strlen(name) * 2 + 1);
++ if (canonname == NULL)
++ return (ISC_R_NOMEMORY);
++ quotestring(name, canonname);
++ snprintf(str, sizeof(str),
++ "SELECT TTL,RDTYPE,RDATA FROM \"%s\" WHERE "
++ "lower(NAME) = lower('%s')", dbi->table, canonname);
++ isc_mem_put(ns_g_mctx, canonname, strlen(name) * 2 + 1);
++
++ result = maybe_reconnect(dbi);
++ if (result != ISC_R_SUCCESS)
++ return (result);
++
++ res = PQexec(dbi->conn, str);
++ if (!res || PQresultStatus(res) != PGRES_TUPLES_OK) {
++ PQclear(res);
++ return (ISC_R_FAILURE);
++ }
++ if (PQntuples(res) == 0) {
++ PQclear(res);
++ return (ISC_R_NOTFOUND);
++ }
++
++ for (i = 0; i < PQntuples(res); i++) {
++ char *ttlstr = PQgetvalue(res, i, 0);
++ char *type = PQgetvalue(res, i, 1);
++ char *data = PQgetvalue(res, i, 2);
++ dns_ttl_t ttl;
++ char *endp;
++ ttl = strtol(ttlstr, &endp, 10);
++ if (*endp != '\0') {
++ PQclear(res);
++ return (DNS_R_BADTTL);
++ }
++ result = dns_sdb_putrr(lookup, type, ttl, data);
++ if (result != ISC_R_SUCCESS) {
++ PQclear(res);
++ return (ISC_R_FAILURE);
++ }
++ }
++
++ PQclear(res);
++ return (ISC_R_SUCCESS);
++}
++
++/*
++ * Issue an SQL query to return all nodes in the database and fill the
++ * allnodes structure.
++ */
++static isc_result_t
++pgsqldb_allnodes(const char *zone, void *dbdata, dns_sdballnodes_t *allnodes) {
++ struct dbinfo *dbi = dbdata;
++ PGresult *res;
++ isc_result_t result;
++ char str[1500];
++ int i;
++
++ UNUSED(zone);
++
++ snprintf(str, sizeof(str),
++ "SELECT TTL,NAME,RDTYPE,RDATA FROM \"%s\" ORDER BY NAME",
++ dbi->table);
++
++ result = maybe_reconnect(dbi);
++ if (result != ISC_R_SUCCESS)
++ return (result);
++
++ res = PQexec(dbi->conn, str);
++ if (!res || PQresultStatus(res) != PGRES_TUPLES_OK ) {
++ PQclear(res);
++ return (ISC_R_FAILURE);
++ }
++ if (PQntuples(res) == 0) {
++ PQclear(res);
++ return (ISC_R_NOTFOUND);
++ }
++
++ for (i = 0; i < PQntuples(res); i++) {
++ char *ttlstr = PQgetvalue(res, i, 0);
++ char *name = PQgetvalue(res, i, 1);
++ char *type = PQgetvalue(res, i, 2);
++ char *data = PQgetvalue(res, i, 3);
++ dns_ttl_t ttl;
++ char *endp;
++ ttl = strtol(ttlstr, &endp, 10);
++ if (*endp != '\0') {
++ PQclear(res);
++ return (DNS_R_BADTTL);
++ }
++ result = dns_sdb_putnamedrr(allnodes, name, type, ttl, data);
++ if (result != ISC_R_SUCCESS) {
++ PQclear(res);
++ return (ISC_R_FAILURE);
++ }
++ }
++
++ PQclear(res);
++ return (ISC_R_SUCCESS);
++}
++
++/*
++ * Create a connection to the database and save any necessary information
++ * in dbdata.
++ *
++ * argv[0] is the name of the database
++ * argv[1] is the name of the table
++ * argv[2] (if present) is the name of the host to connect to
++ * argv[3] (if present) is the name of the user to connect as
++ * argv[4] (if present) is the name of the password to connect with
++ */
++static isc_result_t
++pgsqldb_create(const char *zone, int argc, char **argv,
++ void *driverdata, void **dbdata)
++{
++ struct dbinfo *dbi;
++ isc_result_t result;
++
++ UNUSED(zone);
++ UNUSED(driverdata);
++
++ if (argc < 2)
++ return (ISC_R_FAILURE);
++
++ dbi = isc_mem_get(ns_g_mctx, sizeof(struct dbinfo));
++ if (dbi == NULL)
++ return (ISC_R_NOMEMORY);
++ dbi->conn = NULL;
++ dbi->database = NULL;
++ dbi->table = NULL;
++ dbi->host = NULL;
++ dbi->user = NULL;
++ dbi->passwd = NULL;
++
++#define STRDUP_OR_FAIL(target, source) \
++ do { \
++ target = isc_mem_strdup(ns_g_mctx, source); \
++ if (target == NULL) { \
++ result = ISC_R_NOMEMORY; \
++ goto cleanup; \
++ } \
++ } while (0);
++
++ STRDUP_OR_FAIL(dbi->database, argv[0]);
++ STRDUP_OR_FAIL(dbi->table, argv[1]);
++ if (argc > 2)
++ STRDUP_OR_FAIL(dbi->host, argv[2]);
++ if (argc > 3)
++ STRDUP_OR_FAIL(dbi->user, argv[3]);
++ if (argc > 4)
++ STRDUP_OR_FAIL(dbi->passwd, argv[4]);
++
++ result = db_connect(dbi);
++ if (result != ISC_R_SUCCESS)
++ goto cleanup;
++
++ *dbdata = dbi;
++ return (ISC_R_SUCCESS);
++
++ cleanup:
++ pgsqldb_destroy(zone, driverdata, (void **)&dbi);
++ return (result);
++}
++
++/*
++ * Close the connection to the database.
++ */
++static void
++pgsqldb_destroy(const char *zone, void *driverdata, void **dbdata) {
++ struct dbinfo *dbi = *dbdata;
++
++ UNUSED(zone);
++ UNUSED(driverdata);
++
++ if (dbi->conn != NULL)
++ PQfinish(dbi->conn);
++ if (dbi->database != NULL)
++ isc_mem_free(ns_g_mctx, dbi->database);
++ if (dbi->table != NULL)
++ isc_mem_free(ns_g_mctx, dbi->table);
++ if (dbi->host != NULL)
++ isc_mem_free(ns_g_mctx, dbi->host);
++ if (dbi->user != NULL)
++ isc_mem_free(ns_g_mctx, dbi->user);
++ if (dbi->passwd != NULL)
++ isc_mem_free(ns_g_mctx, dbi->passwd);
++ if (dbi->database != NULL)
++ isc_mem_free(ns_g_mctx, dbi->database);
++ isc_mem_put(ns_g_mctx, dbi, sizeof(struct dbinfo));
++}
++
++/*
++ * Since the SQL database corresponds to a zone, the authority data should
++ * be returned by the lookup() function. Therefore the authority() function
++ * is NULL.
++ */
++static dns_sdbmethods_t pgsqldb_methods = {
++ pgsqldb_lookup,
++ NULL, /* authority */
++ pgsqldb_allnodes,
++ pgsqldb_create,
++ pgsqldb_destroy
++};
++
++/*
++ * Wrapper around dns_sdb_register().
++ */
++isc_result_t
++pgsqldb_init(void) {
++ unsigned int flags;
++ flags = 0;
++ return (dns_sdb_register("pgsql", &pgsqldb_methods, NULL, flags,
++ ns_g_mctx, &pgsqldb));
++}
++
++/*
++ * Wrapper around dns_sdb_unregister().
++ */
++void
++pgsqldb_clear(void) {
++ if (pgsqldb != NULL)
++ dns_sdb_unregister(&pgsqldb);
++}
diff --git a/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.h b/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.h
new file mode 100644
index 000000000000..c5cf8b311f5d
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/files/patch-bin__named__pgsqldb.h
@@ -0,0 +1,28 @@
+--- ./bin/named/pgsqldb.h.orig 2008-08-26 12:01:22.000000000 -0400
++++ ./bin/named/pgsqldb.h 2008-08-26 12:01:22.000000000 -0400
+@@ -0,0 +1,25 @@
++/*
++ * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
++ * Copyright (C) 2000, 2001 Internet Software Consortium.
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
++ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
++ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
++ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
++ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
++ * PERFORMANCE OF THIS SOFTWARE.
++ */
++
++/* $Id: pgsqldb.h,v 1.3 2004/03/05 05:04:32 marka Exp $ */
++
++#include <isc/types.h>
++
++isc_result_t pgsqldb_init(void);
++
++void pgsqldb_clear(void);
++
diff --git a/dns/bind9-sdb-postgresql/pkg-descr b/dns/bind9-sdb-postgresql/pkg-descr
new file mode 100644
index 000000000000..a434da185e35
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/pkg-descr
@@ -0,0 +1,3 @@
+BIND version 9 Nameserver, with PostgreSQL backend support.
+
+WWW: http://www.isc.org/index.pl?/sw/bind/index.php
diff --git a/dns/bind9-sdb-postgresql/pkg-message b/dns/bind9-sdb-postgresql/pkg-message
new file mode 100644
index 000000000000..bb713abdd1d3
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/pkg-message
@@ -0,0 +1,18 @@
+*************************************************************************
+* _ _____ _____ _____ _ _ _____ ___ ___ _ _ *
+* / \|_ _|_ _| ____| \ | |_ _|_ _/ _ \| \ | | *
+* / _ \ | | | | | _| | \| | | | | | | | | \| | *
+* / ___ \| | | | | |___| |\ | | | | | |_| | |\ | *
+* /_/ \_\_| |_| |_____|_| \_| |_| |___\___/|_| \_| *
+* *
+* If you are running BIND 9 in a chroot environment, make *
+* sure that there is a /dev/random device in the chroot. *
+* *
+* BIND 9 also requires configuration of rndc, including a *
+* "secret" key. The easiest, and most secure way to configure *
+* rndc is to run 'rndc-confgen -a' to generate the proper conf *
+* file, with a new random key, and appropriate file permissions. *
+* *
+* The /etc/rc.d/named script in the base will do both for you. *
+* *
+*************************************************************************
diff --git a/dns/bind9-sdb-postgresql/pkg-plist b/dns/bind9-sdb-postgresql/pkg-plist
new file mode 100644
index 000000000000..df5e1f170f8d
--- /dev/null
+++ b/dns/bind9-sdb-postgresql/pkg-plist
@@ -0,0 +1,232 @@
+bin/dig
+bin/host
+bin/isc-config.sh
+bin/nslookup
+bin/nsupdate
+include/bind9/check.h
+include/bind9/getaddresses.h
+include/bind9/version.h
+include/dns/acl.h
+include/dns/adb.h
+include/dns/byaddr.h
+include/dns/cache.h
+include/dns/callbacks.h
+include/dns/cert.h
+include/dns/compress.h
+include/dns/db.h
+include/dns/dbiterator.h
+include/dns/dbtable.h
+include/dns/diff.h
+include/dns/dispatch.h
+include/dns/dnssec.h
+include/dns/ds.h
+include/dns/enumclass.h
+include/dns/enumtype.h
+include/dns/events.h
+include/dns/fixedname.h
+include/dns/journal.h
+include/dns/keyflags.h
+include/dns/keytable.h
+include/dns/keyvalues.h
+include/dns/lib.h
+include/dns/log.h
+include/dns/master.h
+include/dns/masterdump.h
+include/dns/message.h
+include/dns/name.h
+include/dns/ncache.h
+include/dns/nsec.h
+include/dns/peer.h
+include/dns/portlist.h
+include/dns/rbt.h
+include/dns/rcode.h
+include/dns/rdata.h
+include/dns/rdataclass.h
+include/dns/rdatalist.h
+include/dns/rdataset.h
+include/dns/rdatasetiter.h
+include/dns/rdataslab.h
+include/dns/rdatastruct.h
+include/dns/rdatatype.h
+include/dns/request.h
+include/dns/resolver.h
+include/dns/result.h
+include/dns/rootns.h
+include/dns/sdb.h
+include/dns/secalg.h
+include/dns/secproto.h
+include/dns/soa.h
+include/dns/ssu.h
+include/dns/tcpmsg.h
+include/dns/time.h
+include/dns/tkey.h
+include/dns/tsig.h
+include/dns/ttl.h
+include/dns/types.h
+include/dns/validator.h
+include/dns/version.h
+include/dns/view.h
+include/dns/xfrin.h
+include/dns/zone.h
+include/dns/zonekey.h
+include/dns/zt.h
+include/dst/dst.h
+include/dst/lib.h
+include/dst/result.h
+include/isc/app.h
+include/isc/assertions.h
+include/isc/atomic.h
+include/isc/base64.h
+include/isc/bitstring.h
+include/isc/boolean.h
+include/isc/buffer.h
+include/isc/bufferlist.h
+include/isc/commandline.h
+include/isc/condition.h
+include/isc/dir.h
+include/isc/entropy.h
+include/isc/error.h
+include/isc/event.h
+include/isc/eventclass.h
+include/isc/file.h
+include/isc/formatcheck.h
+include/isc/fsaccess.h
+include/isc/hash.h
+include/isc/heap.h
+include/isc/hex.h
+include/isc/hmacmd5.h
+include/isc/int.h
+include/isc/interfaceiter.h
+include/isc/lang.h
+include/isc/lex.h
+include/isc/lfsr.h
+include/isc/lib.h
+include/isc/list.h
+include/isc/log.h
+include/isc/magic.h
+include/isc/md5.h
+include/isc/mem.h
+include/isc/msgcat.h
+include/isc/msgs.h
+include/isc/mutex.h
+include/isc/mutexblock.h
+include/isc/net.h
+include/isc/netaddr.h
+include/isc/netdb.h
+include/isc/offset.h
+include/isc/once.h
+include/isc/ondestroy.h
+include/isc/os.h
+include/isc/parseint.h
+include/isc/platform.h
+include/isc/print.h
+include/isc/quota.h
+include/isc/random.h
+include/isc/ratelimiter.h
+include/isc/refcount.h
+include/isc/region.h
+include/isc/resource.h
+include/isc/result.h
+include/isc/resultclass.h
+include/isc/rwlock.h
+include/isc/serial.h
+include/isc/sha1.h
+include/isc/sha2.h
+include/isc/sockaddr.h
+include/isc/socket.h
+include/isc/stdio.h
+include/isc/stdlib.h
+include/isc/stdtime.h
+include/isc/string.h
+include/isc/symtab.h
+include/isc/syslog.h
+include/isc/task.h
+include/isc/taskpool.h
+include/isc/thread.h
+include/isc/time.h
+include/isc/timer.h
+include/isc/types.h
+include/isc/util.h
+include/isc/version.h
+include/isccc/alist.h
+include/isccc/base64.h
+include/isccc/cc.h
+include/isccc/ccmsg.h
+include/isccc/events.h
+include/isccc/lib.h
+include/isccc/result.h
+include/isccc/sexpr.h
+include/isccc/symtab.h
+include/isccc/symtype.h
+include/isccc/types.h
+include/isccc/util.h
+include/isccc/version.h
+include/isccfg/aclconf.h
+include/isccfg/cfg.h
+include/isccfg/grammar.h
+include/isccfg/log.h
+include/isccfg/namedconf.h
+include/isccfg/version.h
+include/lwres/context.h
+include/lwres/int.h
+include/lwres/ipv6.h
+include/lwres/lang.h
+include/lwres/list.h
+include/lwres/lwbuffer.h
+include/lwres/lwpacket.h
+include/lwres/lwres.h
+include/lwres/net.h
+include/lwres/netdb.h
+include/lwres/platform.h
+include/lwres/result.h
+include/lwres/version.h
+lib/libbind9.a
+lib/libdns.a
+lib/libisc.a
+lib/libisccc.a
+lib/libisccfg.a
+lib/liblwres.a
+sbin/dnssec-keygen
+sbin/dnssec-signzone
+sbin/lwresd
+sbin/named
+sbin/named-checkconf
+sbin/named-checkzone
+sbin/named-compilezone
+sbin/rndc
+sbin/rndc-confgen
+%%PORTDOCS%%%%DOCSDIR%%/CHANGES
+%%PORTDOCS%%%%DOCSDIR%%/COPYRIGHT
+%%PORTDOCS%%%%DOCSDIR%%/FAQ
+%%PORTDOCS%%%%DOCSDIR%%/README
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch01.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch02.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch03.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch04.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch05.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch06.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch07.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch08.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch09.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch10.html
+%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.html
+%%PORTDOCS%%%%DOCSDIR%%/misc/dnssec
+%%PORTDOCS%%%%DOCSDIR%%/misc/format-options.pl
+%%PORTDOCS%%%%DOCSDIR%%/misc/ipv6
+%%PORTDOCS%%%%DOCSDIR%%/misc/migration
+%%PORTDOCS%%%%DOCSDIR%%/misc/migration-4to9
+%%PORTDOCS%%%%DOCSDIR%%/misc/options
+%%PORTDOCS%%%%DOCSDIR%%/misc/rfc-compliance
+%%PORTDOCS%%%%DOCSDIR%%/misc/roadmap
+%%PORTDOCS%%%%DOCSDIR%%/misc/sdb
+%%PORTDOCS%%@dirrm %%DOCSDIR%%/arm
+%%PORTDOCS%%@dirrm %%DOCSDIR%%/misc
+%%PORTDOCS%%@dirrm %%DOCSDIR%%
+@unexec rm -f %%BIND_DESTETC%%/rndc.conf.sample
+@dirrm include/bind9
+@dirrm include/dns
+@dirrm include/dst
+@dirrmtry include/isc
+@dirrm include/isccc
+@dirrm include/isccfg
+@dirrm include/lwres