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