Adam Tkac 15c5cd
diff -up bind-9.5.0a6/configure.in.sdb bind-9.5.0a6/configure.in
Adam Tkac 15c5cd
--- bind-9.5.0a6/configure.in.sdb	2007-06-19 01:47:16.000000000 +0200
Adam Tkac 15c5cd
+++ bind-9.5.0a6/configure.in	2007-11-15 10:10:06.000000000 +0100
Adam Tkac 15c5cd
@@ -2735,6 +2735,7 @@ AC_CONFIG_FILES([
Adam Tkac 15c5cd
 	bin/tests/system/tkey/Makefile
Adam Tkac 15c5cd
 	bin/tests/headerdep_test.sh
Adam Tkac 15c5cd
 	bin/dnssec/Makefile
Adam Tkac 15c5cd
+	bin/sdb_tools/Makefile
Adam Tkac 15c5cd
 	doc/Makefile
Adam Tkac 15c5cd
 	doc/arm/Makefile
Adam Tkac 15c5cd
 	doc/misc/Makefile
Adam Tkac 15c5cd
diff -up bind-9.5.0a6/bin/Makefile.in.sdb bind-9.5.0a6/bin/Makefile.in
Adam Tkac 15c5cd
--- bind-9.5.0a6/bin/Makefile.in.sdb	2007-06-20 01:46:59.000000000 +0200
Adam Tkac 15c5cd
+++ bind-9.5.0a6/bin/Makefile.in	2007-11-15 10:10:06.000000000 +0100
Adam Tkac 15c5cd
@@ -19,7 +19,7 @@ srcdir =	@srcdir@
Adam Tkac 15c5cd
 VPATH =		@srcdir@
Adam Tkac 15c5cd
 top_srcdir =	@top_srcdir@
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
-SUBDIRS =	named rndc dig dnssec tests nsupdate check
Adam Tkac 15c5cd
+SUBDIRS =	named rndc dig dnssec tests nsupdate check sdb_tools
Adam Tkac 15c5cd
 TARGETS =
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 @BIND9_MAKE_RULES@
Adam Tkac 15c5cd
diff -up bind-9.5.0a6/bin/named/Makefile.in.sdb bind-9.5.0a6/bin/named/Makefile.in
Adam Tkac 15c5cd
--- bind-9.5.0a6/bin/named/Makefile.in.sdb	2007-11-15 10:10:06.000000000 +0100
Adam Tkac 15c5cd
+++ bind-9.5.0a6/bin/named/Makefile.in	2007-11-15 10:11:56.000000000 +0100
Adam Tkac 15c5cd
@@ -26,10 +26,10 @@ top_srcdir =	@top_srcdir@
Adam Tkac 15c5cd
 #
Adam Tkac 15c5cd
 # Add database drivers here.
Adam Tkac 15c5cd
 #
Adam Tkac 15c5cd
-DBDRIVER_OBJS =
Adam Tkac 15c5cd
-DBDRIVER_SRCS =
Adam Tkac 15c5cd
+DBDRIVER_OBJS =      ldapdb.o     pgsqldb.o    dirdb.o
Adam Tkac 15c5cd
+DBDRIVER_SRCS =      ldapdb.c     pgsqldb.c    dirdb.c
Adam Tkac 15c5cd
 DBDRIVER_INCLUDES =
Adam Tkac 15c5cd
-DBDRIVER_LIBS =
Adam Tkac 15c5cd
+DBDRIVER_LIBS =      -lldap -llber  -lpq
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
@@ -43,7 +43,7 @@ CINCLUDES =	-I${srcdir}/include -I${srcd
Adam Tkac 15c5cd
 		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
Adam Tkac 15c5cd
 		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES}
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
-CDEFINES =      @USE_DLZ@
Adam Tkac 15c5cd
+CDEFINES =
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 CWARNINGS =
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
@@ -66,21 +66,20 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} 
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
Adam Tkac 15c5cd
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} \
Adam Tkac 15c5cd
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
Adam Tkac 15c5cd
+		@LIBS@
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 SUBDIRS =	unix
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
-TARGETS =	named@EXEEXT@ lwresd@EXEEXT@
Adam Tkac 15c5cd
+TARGETS =	named@EXEEXT@ named-sdb@EXEEXT@ lwresd@EXEEXT@
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 OBJS =		builtin.o client.o config.o control.o \
Adam Tkac 15c5cd
 		controlconf.o interfacemgr.o \
Adam Tkac 15c5cd
-		listenlist.o log.o logconf.o main.o notify.o \
Adam Tkac 15c5cd
+		listenlist.o log.o logconf.o notify.o \
Adam Tkac 15c5cd
 		query.o server.o sortlist.o \
Adam Tkac 15c5cd
 		tkeyconf.o tsigconf.o update.o xfrout.o \
Adam Tkac 15c5cd
 		zoneconf.o \
Adam Tkac 15c5cd
 		lwaddr.o lwresd.o lwdclient.o lwderror.o lwdgabn.o \
Adam Tkac 15c5cd
 		lwdgnba.o lwdgrbn.o lwdnoop.o lwsearch.o \
Adam Tkac 15c5cd
-		${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 UOBJS =		unix/os.o
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
@@ -88,7 +87,7 @@ GENERATED =	bind9.xsl.h
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 SRCS =		builtin.c client.c config.c control.c \
Adam Tkac 15c5cd
 		controlconf.c interfacemgr.c \
Adam Tkac 15c5cd
-		listenlist.c log.c logconf.c main.c notify.c \
Adam Tkac 15c5cd
+		listenlist.c log.c logconf.c main.c main-sdb.c notify.c \
Adam Tkac 15c5cd
 		query.c server.c sortlist.c \
Adam Tkac 15c5cd
 		tkeyconf.c tsigconf.c update.c xfrout.c \
Adam Tkac 15c5cd
 		zoneconf.c \
Adam Tkac 15c5cd
@@ -116,15 +115,26 @@ main.o: main.c
Adam Tkac 15c5cd
 		-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
Adam Tkac 15c5cd
 		-DNS_SYSCONFDIR=\"${sysconfdir}\" -c ${srcdir}/main.c
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
+main-sdb.o : main-sdb.c
Adam Tkac 15c5cd
+	${CC} ${ALL_CFLAGS} @USE_DLZ@ \
Adam Tkac 15c5cd
+		-DVERSION=\"${VERSION}\" \
Adam Tkac 15c5cd
+		-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
Adam Tkac 15c5cd
+		-DNS_SYSCONFDIR=\"${sysconfdir}\" -c ${srcdir}/main-sdb.c
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
 config.o: config.c
Adam Tkac 15c5cd
 	${CC} ${ALL_CFLAGS} \
Adam Tkac 15c5cd
 		-DVERSION=\"${VERSION}\" \
Adam Tkac 15c5cd
 		-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
Adam Tkac 15c5cd
 		-c ${srcdir}/config.c
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
-named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
Adam Tkac 15c5cd
+named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS} main.o
Adam Tkac 15c5cd
+	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
Adam Tkac 15c5cd
+	${OBJS} main.o ${UOBJS} ${LIBS}
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
+named-sdb@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS} main-sdb.o ${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
Adam Tkac 15c5cd
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
Adam Tkac 15c5cd
-	${OBJS} ${UOBJS} ${LIBS}
Adam Tkac 15c5cd
+	${OBJS} main-sdb.o ${DLZDRIVER_OBJS} ${DBDRIVER_OBJS} ${UOBJS} ${LIBS} \
Adam Tkac 15c5cd
+	${DLZDRIVER_LIBS} ${DBDRIVER_LIBS}
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 lwresd@EXEEXT@: named@EXEEXT@
Adam Tkac 15c5cd
 	rm -f lwresd@EXEEXT@
Adam Tkac 15c5cd
@@ -149,8 +159,9 @@ installdirs:
Adam Tkac 15c5cd
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man5
Adam Tkac 15c5cd
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
-install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs
Adam Tkac 15c5cd
+install:: named@EXEEXT@ named-sdb@EXEEXT@ lwresd@EXEEXT@ installdirs
Adam Tkac 15c5cd
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
Adam Tkac 15c5cd
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-sdb@EXEEXT@ ${DESTDIR}${sbindir}
Adam Tkac 15c5cd
 	(cd ${DESTDIR}${sbindir}; rm -f lwresd@EXEEXT@; @LN@ named@EXEEXT@ lwresd@EXEEXT@)
Adam Tkac 15c5cd
 	${INSTALL_DATA} ${srcdir}/named.8 ${DESTDIR}${mandir}/man8
Adam Tkac 15c5cd
 	${INSTALL_DATA} ${srcdir}/lwresd.8 ${DESTDIR}${mandir}/man8
Adam Tkac 15c5cd
diff -up bind-9.5.0a6/bin/named/main-sdb.c.sdb bind-9.5.0a6/bin/named/main-sdb.c
Adam Tkac 15c5cd
--- bind-9.5.0a6/bin/named/main-sdb.c.sdb	2007-11-15 10:10:06.000000000 +0100
Adam Tkac 15c5cd
+++ bind-9.5.0a6/bin/named/main-sdb.c	2007-11-15 10:10:06.000000000 +0100
Adam Tkac 15c5cd
@@ -72,6 +72,9 @@
Adam Tkac 15c5cd
  * Include header files for database drivers here.
Adam Tkac 15c5cd
  */
Adam Tkac 15c5cd
 /* #include "xxdb.h" */
Adam Tkac 15c5cd
+#include "ldapdb.h"
Adam Tkac 15c5cd
+#include "pgsqldb.h"
Adam Tkac 15c5cd
+#include "dirdb.h"
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 /*
Adam Tkac 15c5cd
  * Include DLZ drivers if appropriate.
Adam Tkac 15c5cd
@@ -641,6 +644,10 @@ setup(void) {
Adam Tkac 15c5cd
 		ns_main_earlyfatal("isc_app_start() failed: %s",
Adam Tkac 15c5cd
 				   isc_result_totext(result));
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
+	ldapdb_clear();
Adam Tkac 15c5cd
+	pgsqldb_clear();
Adam Tkac 15c5cd
+	dirdb_clear();
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
 		      ISC_LOG_NOTICE, "starting BIND %s%s", ns_g_version,
Adam Tkac 15c5cd
 		      saved_command_line);
Adam Tkac 15c5cd
@@ -702,6 +709,57 @@ setup(void) {
Adam Tkac 15c5cd
 				   isc_result_totext(result));
Adam Tkac 15c5cd
 #endif
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
+        result = ldapdb_init();
Adam Tkac 15c5cd
+        if (result != ISC_R_SUCCESS)
Adam Tkac 15c5cd
+        {
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB ldap module initialisation failed: %s.",
Adam Tkac 15c5cd
+                          isc_result_totext(result)
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB ldap zone database will be unavailable."
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+        }else
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_NOTICE, "SDB ldap zone database module loaded."
Adam Tkac 15c5cd
+                         );
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
+        result = pgsqldb_init();
Adam Tkac 15c5cd
+        if (result != ISC_R_SUCCESS)
Adam Tkac 15c5cd
+        {
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB pgsql module initialisation failed: %s.",
Adam Tkac 15c5cd
+                          isc_result_totext(result)
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB pgsql zone database will be unavailable."
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+        }else
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_NOTICE, "SDB postgreSQL DB zone database module loaded."
Adam Tkac 15c5cd
+                         );
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
+        result = dirdb_init();
Adam Tkac 15c5cd
+        if (result != ISC_R_SUCCESS)
Adam Tkac 15c5cd
+        {
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB directory DB module initialisation failed: %s.",
Adam Tkac 15c5cd
+                          isc_result_totext(result)
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_ERROR, 
Adam Tkac 15c5cd
+                          "SDB directory DB zone database will be unavailable."
Adam Tkac 15c5cd
+                );
Adam Tkac 15c5cd
+        }else
Adam Tkac 15c5cd
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
+                          ISC_LOG_NOTICE, "SDB directory DB zone database module loaded."
Adam Tkac 15c5cd
+                         );
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
 	ns_server_create(ns_g_mctx, &ns_g_server);
Adam Tkac 15c5cd
 }
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
@@ -727,6 +785,10 @@ cleanup(void) {
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
 	dns_name_destroy();
Adam Tkac 15c5cd
 
Adam Tkac 15c5cd
+        ldapdb_clear();
Adam Tkac 15c5cd
+        pgsqldb_clear();
Adam Tkac 15c5cd
+        dirdb_clear();
Adam Tkac 15c5cd
+
Adam Tkac 15c5cd
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
Adam Tkac 15c5cd
 		      ISC_LOG_NOTICE, "exiting");
Adam Tkac 15c5cd
 	ns_log_shutdown();