Blame SOURCES/openldap-ldapi-sasl.patch

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