mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-23 00:43:28 +00:00
[new port] dns/bind9-sdb-mysql: BIND 9 patch to supports zones
storage in a MySQL database bind9-sdb-mysql is provide a simple support for MySQL database in bind version 9. Currently it supports only zones stored in MySQL. PR: ports/56565 Submitted by: Clement Laforet <sheepkiller@cultdeadsheep.org>
This commit is contained in:
parent
c33228bd0e
commit
d70fadb978
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=88763
@ -6,6 +6,7 @@
|
||||
SUBDIR += bind84
|
||||
SUBDIR += bind9
|
||||
SUBDIR += bind9-dlz
|
||||
SUBDIR += bind9-sdb-mysql
|
||||
SUBDIR += ddclient
|
||||
SUBDIR += ddup
|
||||
SUBDIR += dhid
|
||||
|
117
dns/bind9-sdb-mysql/Makefile
Normal file
117
dns/bind9-sdb-mysql/Makefile
Normal file
@ -0,0 +1,117 @@
|
||||
# New ports collection makefile for: bind9-sdb-mysql
|
||||
# Date created: 6 Sep 2003
|
||||
# Whom: Clement Laforet <sheepkiller@cultdeadsheep.org>
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
PORTNAME= bind9
|
||||
PORTVERSION= 9.2.2
|
||||
CATEGORIES= dns ipv6
|
||||
MASTER_SITES= ${MASTER_SITE_ISC}
|
||||
MASTER_SITE_SUBDIR= bind9/${ISCVERSION}
|
||||
PKGNAMESUFFIX= -sdb-mysql
|
||||
DISTNAME= bind-${ISCVERSION}
|
||||
#
|
||||
# The original patch-files where gotten from:
|
||||
# PATCH_SITES= http://gw.netbastards.org/bm/
|
||||
# PATCHFILES= bind-9.2.2-mysql.patch
|
||||
# but moved to files/ because it contained hardcoded references to /usr/local
|
||||
#
|
||||
|
||||
MAINTAINER= sheepkiller@cultdeadsheep.org
|
||||
COMMENT= BIND DNS 9 server which supports a MySQL backend
|
||||
|
||||
# ISC releases things like 9.2.2rc1, which our versioning doesn't like
|
||||
ISCVERSION= 9.2.2
|
||||
|
||||
USE_MYSQL= YES
|
||||
USE_REINPLACE= YES
|
||||
GNU_CONFIGURE= yes
|
||||
CONFIGURE_ARGS= --localstatedir=/var --disable-linux-caps --disable-threads \
|
||||
--with-randomdev=/dev/random
|
||||
|
||||
.include <bsd.port.pre.mk>
|
||||
|
||||
.if ${OSVERSION} >= 400014
|
||||
USE_OPENSSL= yes
|
||||
CONFIGURE_ARGS+= --with-openssl=${OPENSSLBASE}
|
||||
.endif
|
||||
|
||||
.if defined(PORT_REPLACES_BASE_BIND9)
|
||||
PKGNAMESUFFIX= -base
|
||||
PREFIX= /usr
|
||||
BIND_DESTETC= /etc/namedb
|
||||
CONFIGURE_ARGS+= --prefix=${PREFIX} \
|
||||
--sysconfdir=${BIND_DESTETC} \
|
||||
--mandir=${MANPREFIX}/man
|
||||
.else
|
||||
BIND_DESTETC= ${PREFIX}/etc
|
||||
.endif
|
||||
|
||||
PLIST_SUB= BIND_DESTETC="${BIND_DESTETC}"
|
||||
|
||||
MAN1= dig.1 host.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= rndc.conf.5
|
||||
MAN8= dnssec-keygen.8 dnssec-makekeyset.8 dnssec-signkey.8 dnssec-signzone.8 \
|
||||
lwresd.8 named-checkconf.8 named-checkzone.8 named.8 nsupdate.8 \
|
||||
rndc-confgen.8 rndc.8
|
||||
|
||||
WRKSRC= ${WRKDIR}/bind-${ISCVERSION}
|
||||
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
|
||||
${REINPLACE_CMD} -e 's|<malloc\.h>|<stdlib.h>|g' ${WRKSRC}/bin/named/mysqldb.c
|
||||
|
||||
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>
|
2
dns/bind9-sdb-mysql/distinfo
Normal file
2
dns/bind9-sdb-mysql/distinfo
Normal file
@ -0,0 +1,2 @@
|
||||
MD5 (bind-9.2.2.tar.gz) = 6ea7d64a0856893ab3eb541ab7bbc725
|
||||
MD5 (bind-9.2.2-mysql.patch) = dca1f666d891ce36c77564bbf7eaeeb4
|
401
dns/bind9-sdb-mysql/files/patch-bind-9.2.2-mysql
Normal file
401
dns/bind9-sdb-mysql/files/patch-bind-9.2.2-mysql
Normal file
@ -0,0 +1,401 @@
|
||||
--- bin/named/Makefile.in 2001-06-01 03:45:00.000000000 +0300
|
||||
+++ bin/named/Makefile.in 2003-03-10 15:13:06.000000000 +0200
|
||||
@@ -26,10 +26,10 @@
|
||||
#
|
||||
# Add database drivers here.
|
||||
#
|
||||
-DBDRIVER_OBJS =
|
||||
-DBDRIVER_SRCS =
|
||||
-DBDRIVER_INCLUDES =
|
||||
-DBDRIVER_LIBS =
|
||||
+DBDRIVER_OBJS = mysqldb.@O@
|
||||
+DBDRIVER_SRCS = mysqldb.c
|
||||
+DBDRIVER_INCLUDES = -I${LOCALBASE}/include
|
||||
+DBDRIVER_LIBS = -L${LOCALBASE}/lib/mysql -lmysqlclient
|
||||
|
||||
CINCLUDES = -I${srcdir}/include -I${srcdir}/unix/include \
|
||||
${LWRES_INCLUDES} ${DNS_INCLUDES} \
|
||||
diff -uNr bin/named/include/mysqldb.h bin/named/include/mysqldb.h
|
||||
--- bin/named/include/mysqldb.h 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ bin/named/include/mysqldb.h 2003-03-10 15:09:19.000000000 +0200
|
||||
@@ -0,0 +1,7 @@
|
||||
+
|
||||
+#include <isc/types.h>
|
||||
+
|
||||
+isc_result_t mysqldb_init(void);
|
||||
+
|
||||
+void mysqldb_clear(void);
|
||||
+
|
||||
diff -uNr bin/named/main.c bin/named/main.c
|
||||
--- bin/named/main.c 2002-08-05 09:57:01.000000000 +0300
|
||||
+++ bin/named/main.c 2003-03-10 15:44:36.000000000 +0200
|
||||
@@ -62,6 +62,7 @@
|
||||
* Include header files for database drivers here.
|
||||
*/
|
||||
/* #include "xxdb.h" */
|
||||
+#include "mysqldb.h"
|
||||
|
||||
static isc_boolean_t want_stats = ISC_FALSE;
|
||||
static char program_name[ISC_DIR_NAMEMAX] = "named";
|
||||
@@ -527,6 +528,7 @@
|
||||
* Add calls to register sdb drivers here.
|
||||
*/
|
||||
/* xxdb_init(); */
|
||||
+ mysqldb_init ();
|
||||
|
||||
ns_server_create(ns_g_mctx, &ns_g_server);
|
||||
}
|
||||
@@ -541,6 +543,7 @@
|
||||
* Add calls to unregister sdb drivers here.
|
||||
*/
|
||||
/* xxdb_clear(); */
|
||||
+ mysqldb_clear ();
|
||||
|
||||
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
|
||||
ISC_LOG_NOTICE, "exiting");
|
||||
diff -uNr bin/named/mysqldb.c bin/named/mysqldb.c
|
||||
--- bin/named/mysqldb.c 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ bin/named/mysqldb.c 2003-03-10 15:09:11.000000000 +0200
|
||||
@@ -0,0 +1,342 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2002 Mihai Chelaru ( kefren@netbastards.org )
|
||||
+ *
|
||||
+ * 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 I DISCLAIM ALL WARRANTIES WITH
|
||||
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
+ * AND FITNESS. IN NO EVENT SHALL I 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.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+#include <config.h>
|
||||
+#include <stdio.h>
|
||||
+#include <malloc.h>
|
||||
+#include <mysql/mysql.h>
|
||||
+#include <isc/mem.h>
|
||||
+#include <dns/sdb.h>
|
||||
+#include <dns/result.h>
|
||||
+#include <named/globals.h>
|
||||
+
|
||||
+#include <mysqldb.h>
|
||||
+
|
||||
+#define ROWS 20
|
||||
+#define MAXCOLUMN 200
|
||||
+
|
||||
+/*
|
||||
+#define ONEDATABASE
|
||||
+#define MDEBUG
|
||||
+*/
|
||||
+struct mysqlrow {
|
||||
+ char *s[ROWS];
|
||||
+};
|
||||
+
|
||||
+static dns_sdbimplementation_t *mysqldb = NULL;
|
||||
+
|
||||
+struct mydbinfo {
|
||||
+ MYSQL *conn;
|
||||
+ char *database;
|
||||
+ char *table;
|
||||
+ char *host;
|
||||
+ char *user;
|
||||
+ char *passwd;
|
||||
+};
|
||||
+
|
||||
+/* My internal functions */
|
||||
+
|
||||
+int mysql_dbcon(struct mydbinfo *);
|
||||
+
|
||||
+int
|
||||
+mysql_dbcon(struct mydbinfo * dbi)
|
||||
+{
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Connecting\n");
|
||||
+#endif
|
||||
+ dbi->conn=mysql_init(NULL);
|
||||
+ if (dbi->conn == NULL) return 0;
|
||||
+ if (!mysql_real_connect(dbi->conn, dbi->host, dbi->user, dbi->passwd, dbi->database, 3306, NULL, 0))
|
||||
+ return 0;
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Connected\n");
|
||||
+#endif
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+/* External functions */
|
||||
+
|
||||
+static isc_result_t
|
||||
+mysqldb_lookup(const char *zone, const char *name, void *dbdata, dns_sdblookup_t * lookup)
|
||||
+{
|
||||
+ char *querystring = NULL, seclook[150];
|
||||
+ struct mydbinfo *dbi = (struct mydbinfo *) dbdata;
|
||||
+ MYSQL_RES *result;
|
||||
+ struct mysqlrow myrow;
|
||||
+ int i, j, totlen;
|
||||
+ MYSQL_ROW row;
|
||||
+ int num_fields, putrr_success=0;
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Lookup in %.200s for %.200s ", zone, name);
|
||||
+#endif
|
||||
+ querystring = (char *) malloc(200);
|
||||
+ if (!querystring)
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ snprintf(querystring, 200, "SELECT TTL,RDTYPE,RDATA FROM %s where name='%.150s'", dbi->table, name);
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Query = %s\n", querystring);
|
||||
+#endif
|
||||
+ mysql_ping(dbi->conn);
|
||||
+ if (mysql_query(dbi->conn, querystring)) {
|
||||
+ printf("Query Error in lookup\n");
|
||||
+ free(querystring);
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ free(querystring);
|
||||
+ result = mysql_store_result(dbi->conn);
|
||||
+
|
||||
+ num_fields = mysql_num_fields(result);
|
||||
+ if (num_fields > ROWS) {
|
||||
+ printf("Incorrect database format\n");
|
||||
+ mysql_free_result(result);
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ /* allocate to fetch */
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ if (!(myrow.s[i] = (char *) malloc(MAXCOLUMN))) {
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ free(myrow.s[i]);
|
||||
+ mysql_free_result(result);
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ }
|
||||
+ /* Ok. we found no reason why to not let fetch */
|
||||
+ while ((row = mysql_fetch_row(result))) {
|
||||
+ unsigned long *lengths;
|
||||
+ lengths = mysql_fetch_lengths(result);
|
||||
+ totlen = 0;
|
||||
+ for (i = 0; i < num_fields; i++) {
|
||||
+ totlen += lengths[i];
|
||||
+ snprintf(myrow.s[i], MAXCOLUMN, "%.*s", (int) lengths[i], row[i] ? row[i] : "NULL");
|
||||
+ }
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Lookup: %s %s %s\n", myrow.s[0], myrow.s[1], myrow.s[2]);
|
||||
+#endif
|
||||
+ if (dns_sdb_putrr(lookup, myrow.s[1], strtol(myrow.s[0], NULL, 10), myrow.s[2]) != ISC_R_SUCCESS) {
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ free(myrow.s[i]);
|
||||
+ mysql_free_result(result);
|
||||
+ printf("Lookup Failure\n");
|
||||
+ return ISC_R_FAILURE;
|
||||
+ } else putrr_success=1;
|
||||
+ }
|
||||
+#ifdef MDEBUG
|
||||
+ printf ("Bailing out lookup\n");
|
||||
+#endif
|
||||
+ /* Ok. success. bail out. */
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ free(myrow.s[i]);
|
||||
+ mysql_free_result(result);
|
||||
+
|
||||
+ /* Check if there is any *.foo.com available and return it in case that this is not a *.foo.com call */
|
||||
+ if ((!putrr_success)&&(name[0]!='*')) {
|
||||
+#ifdef MDEBUG
|
||||
+printf ("Cannot find it. Trying to check * record\n");
|
||||
+#endif
|
||||
+ snprintf (seclook,150,"*.%s",zone);
|
||||
+ return mysqldb_lookup (zone, seclook, dbdata, lookup);
|
||||
+ }
|
||||
+
|
||||
+ /* else return SUCCESS */
|
||||
+ return ISC_R_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+static isc_result_t
|
||||
+mysqldb_allnodes(const char *zone, void *dbdata, dns_sdballnodes_t * allnodes)
|
||||
+{
|
||||
+ char *querystring = NULL;
|
||||
+ struct mydbinfo *dbi = (struct mydbinfo *) dbdata;
|
||||
+ MYSQL_RES *result;
|
||||
+ struct mysqlrow myrow;
|
||||
+ MYSQL_ROW row;
|
||||
+ int num_fields;
|
||||
+ int i, totlen, j;
|
||||
+#ifdef MDEBUG
|
||||
+ printf("All Nodes\n");
|
||||
+#endif
|
||||
+ querystring = (char *) malloc(200);
|
||||
+ if (!querystring)
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ snprintf(querystring, 200, "SELECT TTL,NAME,RDTYPE,RDATA FROM %s where name like('%%%.150s')", dbi->table, zone);
|
||||
+ mysql_ping(dbi->conn);
|
||||
+ if (mysql_query(dbi->conn, querystring)) {
|
||||
+ printf("Query Error\n");
|
||||
+ free(querystring);
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ free(querystring);
|
||||
+ result = mysql_store_result(dbi->conn);
|
||||
+
|
||||
+ num_fields = mysql_num_fields(result);
|
||||
+ if (num_fields > ROWS) {
|
||||
+ printf("Incorrect database format\n");
|
||||
+ mysql_free_result(result);
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ /* allocate to fetch */
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ if (!(myrow.s[i] = (char *) malloc(MAXCOLUMN))) {
|
||||
+ for (j = 0; j < i; j++)
|
||||
+ free(myrow.s[i]);
|
||||
+ mysql_free_result(result);
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ }
|
||||
+ /* Ok. we found no reason why to not let fetch */
|
||||
+ while ((row = mysql_fetch_row(result))) {
|
||||
+ unsigned long *lengths;
|
||||
+ lengths = mysql_fetch_lengths(result);
|
||||
+ totlen = 0;
|
||||
+ for (i = 0; i < num_fields; i++) {
|
||||
+ totlen += lengths[i];
|
||||
+ snprintf(myrow.s[i], MAXCOLUMN, "%.*s", (int) lengths[i], row[i] ? row[i] : "NULL");
|
||||
+ }
|
||||
+#ifdef MDEBUG
|
||||
+ printf("All Nodes: %s %s %s %s\n", myrow.s[0], myrow.s[1], myrow.s[2], myrow.s[3]);
|
||||
+#endif
|
||||
+ if (dns_sdb_putnamedrr(allnodes, myrow.s[1], myrow.s[2], strtol(myrow.s[0], NULL, 10), myrow.s[3]) != ISC_R_SUCCESS) {
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ free(myrow.s[i]);
|
||||
+ mysql_free_result(result);
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Ok. success. bail out. */
|
||||
+ mysql_free_result(result);
|
||||
+ for (i = 0; i < ROWS; i++)
|
||||
+ free(myrow.s[i]);
|
||||
+ return ISC_R_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * Open database argv[i]=database,table,hostname,user,passwd
|
||||
+ */
|
||||
+
|
||||
+static isc_result_t
|
||||
+mysqldb_create(const char *zone, int argc, char **argv, void *driverdata, void **dbdata)
|
||||
+{
|
||||
+ struct mydbinfo *dbi;
|
||||
+ #ifdef ONEDATABASE
|
||||
+ static MYSQL *dbconstat;
|
||||
+ #endif
|
||||
+
|
||||
+ /* Argument count checking */
|
||||
+ if (argc < 5)
|
||||
+ return ISC_R_FAILURE;
|
||||
+
|
||||
+ /* dbi init */
|
||||
+
|
||||
+ dbi = (struct mydbinfo *) isc_mem_get(ns_g_mctx, sizeof(struct mydbinfo));
|
||||
+ if (!dbi)
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ dbi->database = NULL;
|
||||
+ dbi->table = NULL;
|
||||
+ dbi->host = NULL;
|
||||
+ dbi->user = NULL;
|
||||
+ dbi->passwd = NULL;
|
||||
+
|
||||
+ dbi->database = isc_mem_strdup(ns_g_mctx, argv[0]);
|
||||
+ dbi->table = isc_mem_strdup(ns_g_mctx, argv[1]);
|
||||
+ dbi->host = isc_mem_strdup(ns_g_mctx, argv[2]);
|
||||
+ dbi->user = isc_mem_strdup(ns_g_mctx, argv[3]);
|
||||
+ dbi->passwd = isc_mem_strdup(ns_g_mctx, argv[4]);
|
||||
+
|
||||
+ if ((!dbi->database) || (!dbi->table) || (!dbi->host) || (!dbi->user) || (!dbi->passwd)) {
|
||||
+ printf("Cannot strdup\n");
|
||||
+ if (dbi->conn)
|
||||
+ mysql_close(dbi->conn);
|
||||
+ if (dbi->database)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->database);
|
||||
+ if (dbi->table)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->table);
|
||||
+ if (dbi->host)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->host);
|
||||
+ if (dbi->user)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->user);
|
||||
+ if (dbi->passwd)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->passwd);
|
||||
+ isc_mem_put(ns_g_mctx, dbi, sizeof(struct mydbinfo));
|
||||
+ return ISC_R_NOMEMORY;
|
||||
+ }
|
||||
+ /* connect to database */
|
||||
+ #ifdef ONEDATABASE
|
||||
+ if (!((dbconstat) && (!mysql_ping(dbconstat))))
|
||||
+ #endif
|
||||
+ if (!mysql_dbcon(dbi)) {
|
||||
+ printf("Cannot connect to database\n");
|
||||
+ return ISC_R_FAILURE;
|
||||
+ }
|
||||
+ #ifdef ONEDATABASE
|
||||
+ if (dbconstat) dbi->conn = dbconstat; else dbconstat = dbi->conn;
|
||||
+ #endif
|
||||
+ *dbdata = dbi;
|
||||
+ return ISC_R_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mysqldb_destroy(const char *zone, void *driverdata, void **dbdata)
|
||||
+{
|
||||
+ struct mydbinfo *dbi;
|
||||
+
|
||||
+ dbi = (struct mydbinfo *) (*dbdata);
|
||||
+ if (!dbi)
|
||||
+ return;
|
||||
+ if (dbi->conn)
|
||||
+ mysql_close(dbi->conn);
|
||||
+ if (dbi->database)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->database);
|
||||
+ if (dbi->table)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->table);
|
||||
+ if (dbi->host)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->host);
|
||||
+ if (dbi->user)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->user);
|
||||
+ if (dbi->passwd)
|
||||
+ isc_mem_free(ns_g_mctx, dbi->passwd);
|
||||
+ isc_mem_put(ns_g_mctx, dbi, sizeof(struct mydbinfo));
|
||||
+#ifdef MDEBUG
|
||||
+ printf("Destroyed\n");
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* SDB methods */
|
||||
+
|
||||
+static dns_sdbmethods_t mysqldb_methods = {
|
||||
+ mysqldb_lookup,
|
||||
+ NULL, /* authority */
|
||||
+ mysqldb_allnodes,
|
||||
+ mysqldb_create,
|
||||
+ mysqldb_destroy
|
||||
+};
|
||||
+
|
||||
+
|
||||
+
|
||||
+isc_result_t
|
||||
+mysqldb_init()
|
||||
+{
|
||||
+ unsigned int flags = 0;
|
||||
+ return dns_sdb_register("mysql", &mysqldb_methods, NULL, flags, ns_g_mctx, &mysqldb);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+mysqldb_clear()
|
||||
+{
|
||||
+ if (mysqldb)
|
||||
+ dns_sdb_unregister(&mysqldb);
|
||||
+}
|
4
dns/bind9-sdb-mysql/pkg-descr
Normal file
4
dns/bind9-sdb-mysql/pkg-descr
Normal file
@ -0,0 +1,4 @@
|
||||
bind9-sdb-mysql provides a MySQL Simplified Database Interface (sdb) to bind9.
|
||||
So, zones can be stored in a MySQL database.
|
||||
|
||||
WWW: http://gw.netbastards.org/bm/
|
22
dns/bind9-sdb-mysql/pkg-message
Normal file
22
dns/bind9-sdb-mysql/pkg-message
Normal file
@ -0,0 +1,22 @@
|
||||
*************************************************************************
|
||||
* _ _____ _____ _____ _ _ _____ ___ ___ _ _ *
|
||||
* / \|_ _|_ _| ____| \ | |_ _|_ _/ _ \| \ | | *
|
||||
* / _ \ | | | | | _| | \| | | | | | | | | \| | *
|
||||
* / ___ \| | | | | |___| |\ | | | | | |_| | |\ | *
|
||||
* /_/ \_\_| |_| |_____|_| \_| |_| |___\___/|_| \_| *
|
||||
* *
|
||||
* BIND 9 requires a good source of randomness to operate. *
|
||||
* It also requires configuration of rndc, including a *
|
||||
* "secret" key. If you are using FreeBSD 4.x, visit *
|
||||
* http://people.freebsd.org/~dougb/randomness.html for *
|
||||
* information on how to set up entropy gathering. Users *
|
||||
* of FreeBSD 5.x do not need to perform this step. If *
|
||||
* you are running BIND 9 in a chroot environment, make *
|
||||
* sure that there is a /dev/random device in the chroot. *
|
||||
* *
|
||||
* The easiest, and most secure way to configure rndc is *
|
||||
* to run 'rndc-confgen -a' which will generate the proper *
|
||||
* conf file, with a new random key, and appropriate file *
|
||||
* permissions. *
|
||||
* *
|
||||
*************************************************************************
|
214
dns/bind9-sdb-mysql/pkg-plist
Normal file
214
dns/bind9-sdb-mysql/pkg-plist
Normal file
@ -0,0 +1,214 @@
|
||||
bin/dig
|
||||
bin/host
|
||||
bin/isc-config.sh
|
||||
bin/nslookup
|
||||
bin/nsupdate
|
||||
include/dns/a6.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/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/nxt.h
|
||||
include/dns/peer.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/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/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/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/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/sockaddr.h
|
||||
include/isc/socket.h
|
||||
include/isc/stdio.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/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/isccfg/cfg.h
|
||||
include/isccfg/check.h
|
||||
include/isccfg/log.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
|
||||
lib/libdns.a
|
||||
lib/libisc.a
|
||||
lib/libisccc.a
|
||||
lib/libisccfg.a
|
||||
lib/liblwres.a
|
||||
sbin/dnssec-keygen
|
||||
sbin/dnssec-makekeyset
|
||||
sbin/dnssec-signkey
|
||||
sbin/dnssec-signzone
|
||||
sbin/lwresd
|
||||
sbin/named
|
||||
sbin/named-checkconf
|
||||
sbin/named-checkzone
|
||||
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.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/dns
|
||||
@dirrm include/dst
|
||||
@unexec rmdir %D/include/isc 2>/dev/null || true
|
||||
@dirrm include/isccc
|
||||
@dirrm include/isccfg
|
||||
@dirrm include/lwres
|
Loading…
Reference in New Issue
Block a user