Blame SOURCES/openldap-ldapi-sasl.patch

adf540
From 69709289b083c53ba41d2cef7d65120220f8c59b Mon Sep 17 00:00:00 2001
adf540
From: Sumit Bose <sbose@redhat.com>
adf540
Date: Tue, 7 May 2013 17:02:57 +0200
adf540
Subject: [PATCH] LDAPI SASL fix
adf540
adf540
Resolves: #960222
adf540
---
adf540
 libraries/libldap/cyrus.c | 19 ++++++++++++++++---
adf540
 1 Datei geändert, 16 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
adf540
adf540
diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c
adf540
index 28c241b..a9acf36 100644
adf540
--- a/libraries/libldap/cyrus.c
adf540
+++ b/libraries/libldap/cyrus.c
adf540
@@ -394,6 +394,8 @@ ldap_int_sasl_bind(
adf540
 	struct berval	ccred = BER_BVNULL;
adf540
 	int saslrc, rc;
adf540
 	unsigned credlen;
adf540
+	char my_hostname[HOST_NAME_MAX + 1];
adf540
+	int free_saslhost = 0;
adf540
 
adf540
 	Debug( LDAP_DEBUG_TRACE, "ldap_int_sasl_bind: %s\n",
adf540
 		mechs ? mechs : "<null>", 0, 0 );
adf540
@@ -454,14 +456,25 @@ ldap_int_sasl_bind(
adf540
 
adf540
 			/* If we don't need to canonicalize just use the host
adf540
 			 * from the LDAP URI.
adf540
+			 * Always use the result of gethostname() for LDAPI.
adf540
 			 */
adf540
-			if ( nocanon )
adf540
+			if (ld->ld_defconn->lconn_server->lud_scheme != NULL &&
adf540
+			    strcmp("ldapi", ld->ld_defconn->lconn_server->lud_scheme) == 0) {
adf540
+				rc = gethostname(my_hostname, HOST_NAME_MAX + 1);
adf540
+				if (rc == 0) {
adf540
+					saslhost = my_hostname;
adf540
+				} else {
adf540
+					saslhost = "localhost";
adf540
+				}
adf540
+			} else if ( nocanon )
adf540
 				saslhost = ld->ld_defconn->lconn_server->lud_host;
adf540
-			else 
adf540
+			else {
adf540
 				saslhost = ldap_host_connected_to( ld->ld_defconn->lconn_sb,
adf540
 				"localhost" );
adf540
+				free_saslhost = 1;
adf540
+			}
adf540
 			rc = ldap_int_sasl_open( ld, ld->ld_defconn, saslhost );
adf540
-			if ( !nocanon )
adf540
+			if ( free_saslhost )
adf540
 				LDAP_FREE( saslhost );
adf540
 		}
adf540
 
adf540
-- 
adf540
1.7.11.7
adf540