autofs-5.0.5 - fix sasl bind host name selection

From: Ian Kent <ikent@redhat.com>

A host name is needed when starting a sasl client. But the ldap
library can return a list of host names with the port appended
following a colon. With IPv6 the host name itself may have colons
so a forward search can no longer be used to find the colon
delimiting the port number and a reverse search can't be used
because it may end up including more than one host name.
---

 CHANGELOG            |    1 +
 modules/cyrus-sasl.c |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/CHANGELOG b/CHANGELOG
index 15dbfae..8db51fc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -76,6 +76,7 @@
 - fix lsb service name in init script.
 - fix map source check in file lookup.
 - fix simple bind without SASL support.
+- fix sasl bind host name selection.
 
 03/09/2009 autofs-5.0.5
 -----------------------
diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
index b5c87b6..b456333 100644
--- a/modules/cyrus-sasl.c
+++ b/modules/cyrus-sasl.c
@@ -738,6 +738,13 @@ sasl_bind_mech(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt, const c
 		return NULL;
 	}
 
+	/*
+	 * We need a host name to start the client.
+	 * But the ldap library can return a list of host names so
+	 * just use the first one.
+	 */
+	if ((tmp = strchr(host, ' ')))
+		*tmp = '\0';
 	if ((tmp = strrchr(host, ':'))) {
 		if (*(tmp - 1) != ']') {
 			*tmp = '\0';