From 18f31148befba19b7c98918260463509ec176fac Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Wed, 10 May 2000 22:43:08 +0000
Subject: [PATCH] Working (but likely not robust) DNS SRV backend!

---
 servers/slapd/back-dnssrv/request.c | 14 ++++++++++++--
 tests/data/slapd-dnssrv.conf        | 16 ++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 tests/data/slapd-dnssrv.conf

diff --git a/servers/slapd/back-dnssrv/request.c b/servers/slapd/back-dnssrv/request.c
index bf91ab0982..039e03b276 100644
--- a/servers/slapd/back-dnssrv/request.c
+++ b/servers/slapd/back-dnssrv/request.c
@@ -24,6 +24,7 @@ dnssrv_back_request(
     const char *ndn )
 {
 	int i;
+	int rc;
 	char *domain = NULL;
 	char *hostlist = NULL;
 	char **hosts = NULL;
@@ -40,8 +41,9 @@ dnssrv_back_request(
 		domain == NULL ? "" : domain,
 		0 );
 	
-	if( ldap_domain2hostlist( dn, &domain ) ) {
-		Debug( LDAP_DEBUG_TRACE, "DNSSRV: no such object\n", 0, 0, 0 );
+	if( rc = ldap_domain2hostlist( domain, &hostlist ) ) {
+		Debug( LDAP_DEBUG_TRACE, "DNSSRV: domain2hostlist returned %d\n",
+			rc, 0, 0 );
 		send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
 			NULL, "could not locate DNS SRV records", NULL, NULL );
 		goto done;
@@ -73,6 +75,14 @@ dnssrv_back_request(
 		}
 	}
 
+	Statslog( LDAP_DEBUG_STATS,
+	    "conn=%ld op=%d DNSSRV dn=\"%s\" domain=%d url=\"%s\"\n",
+	    op->o_connid, op->o_opid, dn, domain, urls[0]->bv_val );
+
+	Debug( LDAP_DEBUG_TRACE, "DNSSRV: dn=\"%s\" -> url=\"%s\"\n",
+		dn == NULL ? "" : dn,
+		urls[0]->bv_val, 0 );
+
 	send_ldap_result( conn, op, LDAP_REFERRAL,
 		NULL, NULL, urls, NULL );
 
diff --git a/tests/data/slapd-dnssrv.conf b/tests/data/slapd-dnssrv.conf
new file mode 100644
index 0000000000..5361a9aa1d
--- /dev/null
+++ b/tests/data/slapd-dnssrv.conf
@@ -0,0 +1,16 @@
+# $OpenLDAP$
+#
+# DNS SRV slapd config -- for testing
+#
+include		./data/slapd.at.conf
+include		./data/slapd.oc.conf
+schemacheck	on
+pidfile     ./test-db/slapd.pid
+argsfile    ./test-db/slapd.args
+
+#######################################################################
+# ldbm database definitions
+#######################################################################
+
+database	dnssrv
+suffix		""
-- 
GitLab