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