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