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