e55890
diff --git a/bin/Makefile.in b/bin/Makefile.in
e55890
index ce7a2da..4e6a824 100644
e55890
--- a/bin/Makefile.in
e55890
+++ b/bin/Makefile.in
e55890
@@ -11,8 +11,8 @@ srcdir =	@srcdir@
e55890
 VPATH =		@srcdir@
e55890
 top_srcdir =	@top_srcdir@
e55890
 
e55890
-SUBDIRS =	named named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate \
e55890
-		check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ tests
e55890
+SUBDIRS =	named named-sdb named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate \
e55890
+		check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ sdb_tools tests
e55890
 TARGETS =
e55890
 
e55890
 @BIND9_MAKE_RULES@
e55890
diff --git a/bin/named-sdb/Makefile.in b/bin/named-sdb/Makefile.in
e55890
index 6d2bfd1..d3f42e8 100644
e55890
--- a/bin/named-sdb/Makefile.in
e55890
+++ b/bin/named-sdb/Makefile.in
e55890
@@ -30,10 +30,10 @@ VERSION=@BIND9_VERSION@
e55890
 #
e55890
 # Add database drivers here.
e55890
 #
e55890
-DBDRIVER_OBJS =
e55890
-DBDRIVER_SRCS =
e55890
+DBDRIVER_OBJS =	ldapdb.@O@ pgsqldb.@O@ sqlitedb.@O@ dirdb.@O@
e55890
+DBDRIVER_SRCS =	ldapdb.c pgsqldb.c sqlitedb.c dirdb.c
e55890
 DBDRIVER_INCLUDES =
e55890
-DBDRIVER_LIBS =
e55890
+DBDRIVER_LIBS =	-lldap -llber -lsqlite3 -lpq
e55890
 
e55890
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
e55890
 
e55890
@@ -79,7 +79,7 @@ NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 
e55890
 SUBDIRS =	unix
e55890
 
e55890
-TARGETS =	named@EXEEXT@ lwresd@EXEEXT@
e55890
+TARGETS =	named-sdb@EXEEXT@
e55890
 
e55890
 GEOIPLINKOBJS = geoip.@O@
e55890
 
e55890
@@ -146,7 +146,7 @@ server.@O@: server.c
e55890
 		-DPRODUCT=\"${PRODUCT}\" \
e55890
 		-DVERSION=\"${VERSION}\" -c ${srcdir}/server.c
e55890
 
e55890
-named@EXEEXT@: ${OBJS} ${DEPLIBS}
e55890
+named-sdb@EXEEXT@: ${OBJS} ${DEPLIBS}
e55890
 	export MAKE_SYMTABLE="yes"; \
e55890
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
@@ -173,8 +173,6 @@ statschannel.@O@: bind9.xsl.h
e55890
 
e55890
 installdirs:
e55890
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
e55890
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man5
e55890
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
e55890
 
e55890
 install-man5: named.conf.5
e55890
 	${INSTALL_DATA} $^ ${DESTDIR}${mandir}/man5
e55890
@@ -184,16 +182,11 @@ install-man8: named.8 lwresd.8
e55890
 
e55890
 install-man: install-man5 install-man8
e55890
 
e55890
-install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs install-man
e55890
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
e55890
-	(cd ${DESTDIR}${sbindir}; rm -f lwresd@EXEEXT@; @LN@ named@EXEEXT@ lwresd@EXEEXT@)
e55890
+install:: ${TARGETS} installdirs
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-sdb@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 
e55890
 uninstall::
e55890
-	rm -f ${DESTDIR}${mandir}/man5/named.conf.5
e55890
-	rm -f ${DESTDIR}${mandir}/man8/lwresd.8
e55890
-	rm -f ${DESTDIR}${mandir}/man8/named.8
e55890
-	rm -f ${DESTDIR}${sbindir}/lwresd@EXEEXT@
e55890
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
e55890
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named-sdb@EXEEXT@
e55890
 
e55890
 @DLZ_DRIVER_RULES@
e55890
 
e55890
diff --git a/bin/named-sdb/main.c b/bin/named-sdb/main.c
e55890
index bb639d9..555c4d9 100644
e55890
--- a/bin/named-sdb/main.c
e55890
+++ b/bin/named-sdb/main.c
e55890
@@ -91,6 +91,10 @@
e55890
  * Include header files for database drivers here.
e55890
  */
e55890
 /* #include "xxdb.h" */
e55890
+#include "ldapdb.h"
e55890
+#include "pgsqldb.h"
e55890
+#include "sqlitedb.h"
e55890
+#include "dirdb.h"
e55890
 
e55890
 #ifdef CONTRIB_DLZ
e55890
 /*
e55890
@@ -1061,6 +1065,11 @@ setup(void) {
e55890
 		ns_main_earlyfatal("isc_app_start() failed: %s",
e55890
 				   isc_result_totext(result));
e55890
 
e55890
+	ldapdb_clear();
e55890
+	pgsqldb_clear();
e55890
+	dirdb_clear();
e55890
+	sqlitedb_clear();
e55890
+
e55890
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
 		      ISC_LOG_NOTICE, "starting %s %s%s%s <id:%s>",
e55890
 		      ns_g_product, ns_g_version,
e55890
@@ -1261,6 +1270,75 @@ setup(void) {
e55890
 				   isc_result_totext(result));
e55890
 #endif
e55890
 
e55890
+        result = ldapdb_init();
e55890
+        if (result != ISC_R_SUCCESS)
e55890
+        {
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB ldap module initialisation failed: %s.",
e55890
+                          isc_result_totext(result)
e55890
+                );
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB ldap zone database will be unavailable."
e55890
+                );
e55890
+        }else
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_NOTICE, "SDB ldap zone database module loaded."
e55890
+                         );
e55890
+
e55890
+        result = pgsqldb_init();
e55890
+        if (result != ISC_R_SUCCESS)
e55890
+        {
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB pgsql module initialisation failed: %s.",
e55890
+                          isc_result_totext(result)
e55890
+                );
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB pgsql zone database will be unavailable."
e55890
+                );
e55890
+        }else
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_NOTICE, "SDB postgreSQL DB zone database module loaded."
e55890
+                         );
e55890
+
e55890
+        result = sqlitedb_init();
e55890
+        if (result != ISC_R_SUCCESS)
e55890
+        {
e55890
+             isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB sqlite3 module initialisation failed: %s.",
e55890
+                          isc_result_totext(result)
e55890
+                );
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB sqlite3 zone database will be unavailable."
e55890
+                );
e55890
+        }else
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_NOTICE, "SDB sqlite3 DB zone database module loaded."
e55890
+                         );
e55890
+
e55890
+        result = dirdb_init();
e55890
+        if (result != ISC_R_SUCCESS)
e55890
+        {
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB directory DB module initialisation failed: %s.",
e55890
+                          isc_result_totext(result)
e55890
+                );
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_ERROR, 
e55890
+                          "SDB directory DB zone database will be unavailable."
e55890
+                );
e55890
+        }else
e55890
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
+                          ISC_LOG_NOTICE, "SDB directory DB zone database module loaded."
e55890
+                         );
e55890
+
e55890
+
e55890
 	ns_server_create(ns_g_mctx, &ns_g_server);
e55890
 
e55890
 #ifdef HAVE_LIBSECCOMP
e55890
@@ -1303,6 +1381,11 @@ cleanup(void) {
e55890
 
e55890
 	dns_name_destroy();
e55890
 
e55890
+	ldapdb_clear();
e55890
+	pgsqldb_clear();
e55890
+	sqlitedb_clear();
e55890
+	dirdb_clear();
e55890
+
e55890
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
e55890
 		      ISC_LOG_NOTICE, "exiting");
e55890
 	ns_log_shutdown();
e55890
diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in
e55890
index 6d2bfd1..86f8587 100644
e55890
--- a/bin/named/Makefile.in
e55890
+++ b/bin/named/Makefile.in
e55890
@@ -45,9 +45,9 @@ DLZDRIVER_LIBS =	@DLZ_DRIVER_LIBS@
e55890
 CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
e55890
 		${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
e55890
 		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
e55890
-		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} @DST_OPENSSL_INC@
e55890
+		@DST_OPENSSL_INC@
e55890
 
e55890
-CDEFINES =      @CONTRIB_DLZ@ @CRYPTO@
e55890
+CDEFINES =      @CRYPTO@
e55890
 
e55890
 CWARNINGS =
e55890
 
e55890
@@ -71,11 +71,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
e55890
 
e55890
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} \
e55890
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
e55890
+		@LIBS@
e55890
 
e55890
 NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCNOSYMLIBS} \
e55890
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
e55890
+		@LIBS@
e55890
 
e55890
 SUBDIRS =	unix
e55890
 
e55890
@@ -90,8 +90,7 @@ OBJS =		builtin.@O@ client.@O@ config.@O@ control.@O@ \
e55890
 		tkeyconf.@O@ tsigconf.@O@ update.@O@ xfrout.@O@ \
e55890
 		zoneconf.@O@ \
e55890
 		lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
e55890
-		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
e55890
-		${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
e55890
+		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@
e55890
 
e55890
 UOBJS =		unix/os.@O@ unix/dlz_dlopen_driver.@O@
e55890
 
e55890
@@ -106,8 +105,7 @@ SRCS =		builtin.c client.c config.c control.c \
e55890
 		tkeyconf.c tsigconf.c update.c xfrout.c \
e55890
 		zoneconf.c \
e55890
 		lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
e55890
-		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
e55890
-		${DLZDRIVER_SRCS} ${DBDRIVER_SRCS}
e55890
+		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c
e55890
 
e55890
 MANPAGES =	named.8 lwresd.8 named.conf.5
e55890
 
e55890
@@ -195,7 +193,5 @@ uninstall::
e55890
 	rm -f ${DESTDIR}${sbindir}/lwresd@EXEEXT@
e55890
 	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
e55890
 
e55890
-@DLZ_DRIVER_RULES@
e55890
-
e55890
 named-symtbl.@O@: named-symtbl.c
e55890
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c named-symtbl.c
e55890
diff --git a/bin/sdb_tools/Makefile.in b/bin/sdb_tools/Makefile.in
e55890
index c7e0868..95ab742 100644
e55890
--- a/bin/sdb_tools/Makefile.in
e55890
+++ b/bin/sdb_tools/Makefile.in
e55890
@@ -32,11 +32,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
e55890
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} ${DBDRIVER_LIBS} @LIBS@
e55890
 
e55890
-TARGETS =	zone2ldap@EXEEXT@ zonetodb@EXEEXT@
e55890
+TARGETS =	zone2ldap@EXEEXT@ zonetodb@EXEEXT@ zone2sqlite@EXEEXT@
e55890
 
e55890
-OBJS	=	zone2ldap.@O@ zonetodb.@O@
e55890
+OBJS	=	zone2ldap.@O@ zonetodb.@O@ zone2sqlite.@O@
e55890
 
e55890
-SRCS    =       zone2ldap.c zonetodb.c
e55890
+SRCS    =       zone2ldap.c zonetodb.c zone2sqlite.c
e55890
 
e55890
 MANPAGES =      zone2ldap.1
e55890
 
e55890
@@ -50,6 +50,9 @@ zone2ldap@EXEEXT@: zone2ldap.@O@ ${DEPLIBS}
e55890
 zonetodb@EXEEXT@: zonetodb.@O@  ${DEPLIBS}
e55890
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zonetodb.@O@ -lpq ${LIBS}
e55890
 
e55890
+zone2sqlite@EXEEXT@: zone2sqlite.@O@  ${DEPLIBS}
e55890
+	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ zone2sqlite.@O@ -lsqlite3 -lssl ${LIBS}
e55890
+
e55890
 clean distclean manclean maintainer-clean::
e55890
 	rm -f ${TARGETS} ${OBJS}
e55890
 
e55890
@@ -60,4 +63,5 @@ installdirs:
e55890
 install:: ${TARGETS} installdirs
e55890
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2ldap@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zonetodb@EXEEXT@  ${DESTDIR}${sbindir}
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2sqlite@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 	${INSTALL_DATA} ${srcdir}/zone2ldap.1 ${DESTDIR}${mandir}/man1/zone2ldap.1
e55890
diff --git a/configure.in b/configure.in
e55890
index 62536a6..f571a4f 100644
e55890
--- a/configure.in
e55890
+++ b/configure.in
e55890
@@ -5445,6 +5445,8 @@ AC_CONFIG_FILES([
e55890
 	bin/named/unix/Makefile
e55890
 	bin/named-pkcs11/Makefile
e55890
 	bin/named-pkcs11/unix/Makefile
e55890
+	bin/named-sdb/Makefile
e55890
+	bin/named-sdb/unix/Makefile
e55890
 	bin/nsupdate/Makefile
e55890
 	bin/pkcs11/Makefile
e55890
 	bin/python/Makefile
e55890
@@ -5469,6 +5471,7 @@ AC_CONFIG_FILES([
e55890
 	bin/python/isc/tests/dnskey_test.py
e55890
 	bin/python/isc/tests/policy_test.py
e55890
 	bin/rndc/Makefile
e55890
+	bin/sdb_tools/Makefile
e55890
 	bin/tests/Makefile
e55890
 	bin/tests/headerdep_test.sh
e55890
 	bin/tests/optional/Makefile