57726f
diff --git a/bin/Makefile.in b/bin/Makefile.in
57726f
index ce7a2da..4e6a824 100644
57726f
--- a/bin/Makefile.in
57726f
+++ b/bin/Makefile.in
57726f
@@ -11,8 +11,8 @@ srcdir =	@srcdir@
57726f
 VPATH =		@srcdir@
57726f
 top_srcdir =	@top_srcdir@
57726f
 
57726f
-SUBDIRS =	named named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate \
57726f
-		check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ tests
57726f
+SUBDIRS =	named named-sdb named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate \
57726f
+		check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ sdb_tools tests
57726f
 TARGETS =
57726f
 
57726f
 @BIND9_MAKE_RULES@
57726f
diff --git a/bin/named-sdb/Makefile.in b/bin/named-sdb/Makefile.in
57726f
index 03a72d5..4c1cb6d 100644
57726f
--- a/bin/named-sdb/Makefile.in
57726f
+++ b/bin/named-sdb/Makefile.in
57726f
@@ -30,10 +30,10 @@ VERSION=@BIND9_VERSION@
57726f
 #
57726f
 # Add database drivers here.
57726f
 #
57726f
-DBDRIVER_OBJS =
57726f
-DBDRIVER_SRCS =
57726f
+DBDRIVER_OBJS =	ldapdb.@O@ pgsqldb.@O@ sqlitedb.@O@ dirdb.@O@
57726f
+DBDRIVER_SRCS =	ldapdb.c pgsqldb.c sqlitedb.c dirdb.c
57726f
 DBDRIVER_INCLUDES =
57726f
-DBDRIVER_LIBS =
57726f
+DBDRIVER_LIBS =	-lldap -llber -lsqlite3 -lpq
57726f
 
57726f
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
57726f
 
57726f
@@ -80,7 +80,7 @@ NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
57726f
 
57726f
 SUBDIRS =	unix
57726f
 
57726f
-TARGETS =	named@EXEEXT@ lwresd@EXEEXT@
57726f
+TARGETS =	named-sdb@EXEEXT@
57726f
 
57726f
 GEOIPLINKOBJS = geoip.@O@
57726f
 GEOIP2LINKOBJS = geoip.@O@
57726f
@@ -154,7 +154,7 @@ server.@O@: server.c
57726f
 		-DPRODUCT=\"${PRODUCT}\" \
57726f
 		-DVERSION=\"${VERSION}\" -c ${srcdir}/server.c
57726f
 
57726f
-named@EXEEXT@: ${OBJS} ${DEPLIBS}
57726f
+named-sdb@EXEEXT@: ${OBJS} ${DEPLIBS}
57726f
 	export MAKE_SYMTABLE="yes"; \
57726f
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
57726f
 	${FINALBUILDCMD}
57726f
@@ -181,8 +181,6 @@ statschannel.@O@: bind9.xsl.h
57726f
 
57726f
 installdirs:
57726f
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
57726f
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man5
57726f
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
57726f
 
57726f
 install-man5: named.conf.5
57726f
 	${INSTALL_DATA} $^ ${DESTDIR}${mandir}/man5
57726f
@@ -192,16 +190,11 @@ install-man8: named.8 lwresd.8
57726f
 
57726f
 install-man: install-man5 install-man8
57726f
 
57726f
-install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs install-man
57726f
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
57726f
-	(cd ${DESTDIR}${sbindir}; rm -f lwresd@EXEEXT@; @LN@ named@EXEEXT@ lwresd@EXEEXT@)
57726f
+install:: ${TARGETS} installdirs
57726f
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-sdb@EXEEXT@ ${DESTDIR}${sbindir}
57726f
 
57726f
 uninstall::
57726f
-	rm -f ${DESTDIR}${mandir}/man5/named.conf.5
57726f
-	rm -f ${DESTDIR}${mandir}/man8/lwresd.8
57726f
-	rm -f ${DESTDIR}${mandir}/man8/named.8
57726f
-	rm -f ${DESTDIR}${sbindir}/lwresd@EXEEXT@
57726f
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
57726f
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named-sdb@EXEEXT@
57726f
 
57726f
 @DLZ_DRIVER_RULES@
57726f
 
57726f
diff --git a/bin/named-sdb/main.c b/bin/named-sdb/main.c
f79ca9
index c9fc3cc..148ebb3 100644
57726f
--- a/bin/named-sdb/main.c
57726f
+++ b/bin/named-sdb/main.c
f79ca9
@@ -97,6 +97,10 @@
57726f
  * Include header files for database drivers here.
57726f
  */
57726f
 /* #include "xxdb.h" */
57726f
+#include "ldapdb.h"
57726f
+#include "pgsqldb.h"
57726f
+#include "sqlitedb.h"
57726f
+#include "dirdb.h"
57726f
 
57726f
 #ifdef CONTRIB_DLZ
57726f
 /*
f79ca9
@@ -1134,6 +1138,11 @@ setup(void) {
57726f
 		ns_main_earlyfatal("isc_app_start() failed: %s",
57726f
 				   isc_result_totext(result));
57726f
 
57726f
+	ldapdb_clear();
57726f
+	pgsqldb_clear();
57726f
+	dirdb_clear();
57726f
+	sqlitedb_clear();
57726f
+
57726f
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
 		      ISC_LOG_NOTICE, "starting %s %s%s%s <id:%s>",
57726f
 		      ns_g_product, ns_g_version,
f79ca9
@@ -1334,6 +1343,75 @@ setup(void) {
57726f
 				   isc_result_totext(result));
57726f
 #endif
57726f
 
57726f
+        result = ldapdb_init();
57726f
+        if (result != ISC_R_SUCCESS)
57726f
+        {
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB ldap module initialisation failed: %s.",
57726f
+                          isc_result_totext(result)
57726f
+                );
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB ldap zone database will be unavailable."
57726f
+                );
57726f
+        }else
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_NOTICE, "SDB ldap zone database module loaded."
57726f
+                         );
57726f
+
57726f
+        result = pgsqldb_init();
57726f
+        if (result != ISC_R_SUCCESS)
57726f
+        {
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB pgsql module initialisation failed: %s.",
57726f
+                          isc_result_totext(result)
57726f
+                );
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB pgsql zone database will be unavailable."
57726f
+                );
57726f
+        }else
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_NOTICE, "SDB postgreSQL DB zone database module loaded."
57726f
+                         );
57726f
+
57726f
+        result = sqlitedb_init();
57726f
+        if (result != ISC_R_SUCCESS)
57726f
+        {
57726f
+             isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB sqlite3 module initialisation failed: %s.",
57726f
+                          isc_result_totext(result)
57726f
+                );
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB sqlite3 zone database will be unavailable."
57726f
+                );
57726f
+        }else
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_NOTICE, "SDB sqlite3 DB zone database module loaded."
57726f
+                         );
57726f
+
57726f
+        result = dirdb_init();
57726f
+        if (result != ISC_R_SUCCESS)
57726f
+        {
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB directory DB module initialisation failed: %s.",
57726f
+                          isc_result_totext(result)
57726f
+                );
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_ERROR, 
57726f
+                          "SDB directory DB zone database will be unavailable."
57726f
+                );
57726f
+        }else
57726f
+            isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
+                          ISC_LOG_NOTICE, "SDB directory DB zone database module loaded."
57726f
+                         );
57726f
+
57726f
+
57726f
 	ns_server_create(ns_g_mctx, &ns_g_server);
57726f
 
57726f
 #ifdef HAVE_LIBSECCOMP
f79ca9
@@ -1376,6 +1454,11 @@ cleanup(void) {
57726f
 
57726f
 	dns_name_destroy();
57726f
 
57726f
+	ldapdb_clear();
57726f
+	pgsqldb_clear();
57726f
+	sqlitedb_clear();
57726f
+	dirdb_clear();
57726f
+
57726f
 	isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
57726f
 		      ISC_LOG_NOTICE, "exiting");
57726f
 	ns_log_shutdown();
57726f
diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in
57726f
index 03a72d5..47cc046 100644
57726f
--- a/bin/named/Makefile.in
57726f
+++ b/bin/named/Makefile.in
57726f
@@ -45,10 +45,10 @@ DLZDRIVER_LIBS =	@DLZ_DRIVER_LIBS@
57726f
 CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
57726f
 		${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
57726f
 		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
57726f
-		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} ${MAXMINDDB_CFLAGS} \
57726f
+		${MAXMINDDB_CFLAGS} \
57726f
 		@DST_OPENSSL_INC@
57726f
 
57726f
-CDEFINES =      @CONTRIB_DLZ@ @USE_GSSAPI@ @CRYPTO@
57726f
+CDEFINES =      @USE_GSSAPI@ @CRYPTO@
57726f
 
57726f
 CWARNINGS =
57726f
 
57726f
@@ -72,11 +72,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
57726f
 
57726f
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
57726f
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} \
57726f
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
57726f
+		@LIBS@
57726f
 
57726f
 NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
57726f
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCNOSYMLIBS} \
57726f
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
57726f
+		@LIBS@
57726f
 
57726f
 SUBDIRS =	unix
57726f
 
57726f
@@ -94,8 +94,7 @@ OBJS =		builtin.@O@ client.@O@ config.@O@ control.@O@ \
57726f
 		tkeyconf.@O@ tsigconf.@O@ update.@O@ xfrout.@O@ \
57726f
 		zoneconf.@O@ \
57726f
 		lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
57726f
-		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
57726f
-		${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
57726f
+		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@
57726f
 
57726f
 UOBJS =		unix/os.@O@ unix/dlz_dlopen_driver.@O@
57726f
 
57726f
@@ -113,8 +112,7 @@ SRCS =		builtin.c client.c config.c control.c \
57726f
 		tkeyconf.c tsigconf.c update.c xfrout.c \
57726f
 		zoneconf.c \
57726f
 		lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
57726f
-		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
57726f
-		${DLZDRIVER_SRCS} ${DBDRIVER_SRCS}
57726f
+		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c
57726f
 
57726f
 MANPAGES =	named.8 lwresd.8 named.conf.5
57726f
 
57726f
@@ -203,7 +201,5 @@ uninstall::
57726f
 	rm -f ${DESTDIR}${sbindir}/lwresd@EXEEXT@
57726f
 	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
57726f
 
57726f
-@DLZ_DRIVER_RULES@
57726f
-
57726f
 named-symtbl.@O@: named-symtbl.c
57726f
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c named-symtbl.c
57726f
diff --git a/bin/sdb_tools/Makefile.in b/bin/sdb_tools/Makefile.in
57726f
index c7e0868..95ab742 100644
57726f
--- a/bin/sdb_tools/Makefile.in
57726f
+++ b/bin/sdb_tools/Makefile.in
57726f
@@ -32,11 +32,11 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
57726f
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
57726f
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} ${DBDRIVER_LIBS} @LIBS@
57726f
 
57726f
-TARGETS =	zone2ldap@EXEEXT@ zonetodb@EXEEXT@
57726f
+TARGETS =	zone2ldap@EXEEXT@ zonetodb@EXEEXT@ zone2sqlite@EXEEXT@
57726f
 
57726f
-OBJS	=	zone2ldap.@O@ zonetodb.@O@
57726f
+OBJS	=	zone2ldap.@O@ zonetodb.@O@ zone2sqlite.@O@
57726f
 
57726f
-SRCS    =       zone2ldap.c zonetodb.c
57726f
+SRCS    =       zone2ldap.c zonetodb.c zone2sqlite.c
57726f
 
57726f
 MANPAGES =      zone2ldap.1
57726f
 
57726f
@@ -50,6 +50,9 @@ zone2ldap@EXEEXT@: zone2ldap.@O@ ${DEPLIBS}
57726f
 zonetodb@EXEEXT@: zonetodb.@O@  ${DEPLIBS}
57726f
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zonetodb.@O@ -lpq ${LIBS}
57726f
 
57726f
+zone2sqlite@EXEEXT@: zone2sqlite.@O@  ${DEPLIBS}
57726f
+	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ zone2sqlite.@O@ -lsqlite3 -lssl ${LIBS}
57726f
+
57726f
 clean distclean manclean maintainer-clean::
57726f
 	rm -f ${TARGETS} ${OBJS}
57726f
 
57726f
@@ -60,4 +63,5 @@ installdirs:
57726f
 install:: ${TARGETS} installdirs
57726f
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2ldap@EXEEXT@ ${DESTDIR}${sbindir}
57726f
 	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zonetodb@EXEEXT@  ${DESTDIR}${sbindir}
57726f
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2sqlite@EXEEXT@ ${DESTDIR}${sbindir}
57726f
 	${INSTALL_DATA} ${srcdir}/zone2ldap.1 ${DESTDIR}${mandir}/man1/zone2ldap.1
57726f
diff --git a/configure.ac b/configure.ac
f79ca9
index f85f45f..7d28c52 100644
57726f
--- a/configure.ac
57726f
+++ b/configure.ac
f79ca9
@@ -5400,6 +5400,8 @@ AC_CONFIG_FILES([
57726f
 	bin/named/unix/Makefile
57726f
 	bin/named-pkcs11/Makefile
57726f
 	bin/named-pkcs11/unix/Makefile
57726f
+	bin/named-sdb/Makefile
57726f
+	bin/named-sdb/unix/Makefile
57726f
 	bin/nsupdate/Makefile
57726f
 	bin/pkcs11/Makefile
57726f
 	bin/python/Makefile
f79ca9
@@ -5424,6 +5426,7 @@ AC_CONFIG_FILES([
57726f
 	bin/python/isc/tests/policy_test.py
f79ca9
 	bin/python/isc/utils.py
57726f
 	bin/rndc/Makefile
57726f
+	bin/sdb_tools/Makefile
57726f
 	bin/tests/Makefile
57726f
 	bin/tests/headerdep_test.sh
57726f
 	bin/tests/optional/Makefile