b734fd
From fecc0fd86f598807129ea9fa1e4e7b74cf2aba21 Mon Sep 17 00:00:00 2001
b734fd
From: Petr Mensik <pemensik@redhat.com>
b734fd
Date: Mon, 11 Nov 2019 17:36:58 +0100
b734fd
Subject: [PATCH] Add support for servestale records
b734fd
b734fd
Serve-stale support includes two new database methods. Add wrapper into
b734fd
ldap database.
b734fd
---
b734fd
 configure.ac      |  5 +++++
b734fd
 src/ldap_driver.c | 24 ++++++++++++++++++++++++
b734fd
 2 files changed, 29 insertions(+)
b734fd
b734fd
diff --git a/configure.ac b/configure.ac
b734fd
index d05bad9..7997898 100644
b734fd
--- a/configure.ac
b734fd
+++ b/configure.ac
b734fd
@@ -120,6 +120,11 @@ int main(void) {
b734fd
 [AC_MSG_ERROR([Cross compiling is not supported.])]
b734fd
 )
b734fd
 
b734fd
+dnl dns_db_setservestalettl() can be backported, detect support
b734fd
+AC_CHECK_LIB([dns], [dns_db_setservestalettl],
b734fd
+  [AC_DEFINE([HAVE_DNS_SERVESTALE], 1, [Define if dns library provides dns_db_setservestalettl])]
b734fd
+)
b734fd
+
b734fd
 dnl Older autoconf (2.59, for example) doesn't define docdir
b734fd
 [[ ! -n "$docdir" ]] && docdir='${datadir}/doc/${PACKAGE_TARNAME}'
b734fd
 AC_SUBST([docdir])
b734fd
diff --git a/src/ldap_driver.c b/src/ldap_driver.c
b734fd
index b9161fe..dcf65d0 100644
b734fd
--- a/src/ldap_driver.c
b734fd
+++ b/src/ldap_driver.c
b734fd
@@ -823,6 +823,26 @@ nodefullname(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name)
b734fd
 	return dns_db_nodefullname(ldapdb->rbtdb, node, name);
b734fd
 }
b734fd
 
b734fd
+#ifdef HAVE_DNS_SERVESTALE
b734fd
+static isc_result_t
b734fd
+setservestalettl(dns_db_t *db, dns_ttl_t ttl) {
b734fd
+	ldapdb_t *ldapdb = (ldapdb_t *) db;
b734fd
+
b734fd
+	REQUIRE(VALID_LDAPDB(ldapdb));
b734fd
+
b734fd
+	return dns_db_setservestalettl(ldapdb->rbtdb, ttl);
b734fd
+}
b734fd
+
b734fd
+static isc_result_t
b734fd
+getservestalettl(dns_db_t *db, dns_ttl_t *ttl) {
b734fd
+	ldapdb_t *ldapdb = (ldapdb_t *) db;
b734fd
+
b734fd
+	REQUIRE(VALID_LDAPDB(ldapdb));
b734fd
+
b734fd
+	return dns_db_getservestalettl(ldapdb->rbtdb, ttl);
b734fd
+}
b734fd
+#endif
b734fd
+
b734fd
 static dns_dbmethods_t ldapdb_methods = {
b734fd
 	attach,
b734fd
 	detach,
b734fd
@@ -869,6 +889,10 @@ static dns_dbmethods_t ldapdb_methods = {
b734fd
 	hashsize,
b734fd
 	nodefullname,
b734fd
 	NULL, // getsize method not implemented (related BZ1353563)
b734fd
+#ifdef HAVE_DNS_SERVESTALE
b734fd
+	setservestalettl,
b734fd
+	getservestalettl,
b734fd
+#endif
b734fd
 };
b734fd
 
b734fd
 isc_result_t ATTR_NONNULLS
b734fd
-- 
b734fd
2.20.1
b734fd