Blame SOURCES/autofs-5.1.0-add-serialization-to-sasl-init.patch

304803
autofs-5.1.0 - add serialization to sasl init
304803
304803
From: Ian Kent <ikent@redhat.com>
304803
304803
Attempt to resolve crash in sasl initialization. We know that the
304803
initial connection calls to connect to an LDAP server are not
304803
thread safe and it looks like the sasl code doesn't take that into
304803
consideration so adding serialization with a mutex is probably a
304803
sensible thing to do.
304803
---
304803
 CHANGELOG             |    1 +
304803
 modules/lookup_ldap.c |   13 +++++++++++++
304803
 2 files changed, 14 insertions(+)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -126,6 +126,7 @@
304803
 - cleanup options in amd_parse.c
304803
 - allow empty value for some map options.
304803
 - allow empty value in macro selectors.
304803
+- add serialization to sasl init.
304803
 
304803
 25/07/2012 autofs-5.0.7
304803
 =======================
304803
--- autofs-5.0.7.orig/modules/lookup_ldap.c
304803
+++ autofs-5.0.7/modules/lookup_ldap.c
304803
@@ -578,7 +578,9 @@ static int do_bind(unsigned logopt, LDAP
304803
 	      ctxt->auth_required, ctxt->sasl_mech);
304803
 
304803
 	if (ctxt->auth_required & LDAP_NEED_AUTH) {
304803
+		ldapinit_mutex_lock();
304803
 		rv = autofs_sasl_bind(logopt, ldap, ctxt);
304803
+		ldapinit_mutex_unlock();
304803
 		debug(logopt, MODPREFIX "autofs_sasl_bind returned %d", rv);
304803
 	} else {
304803
 		rv = bind_ldap_simple(logopt, ldap, uri, ctxt);
304803
@@ -922,7 +924,9 @@ static LDAP *do_reconnect(unsigned logop
304803
 #ifdef WITH_SASL
304803
 		/* Dispose of the sasl authentication connection and try again. */
304803
 		if (!ldap && ctxt->auth_required & LDAP_NEED_AUTH) {
304803
+			ldapinit_mutex_lock();
304803
 			autofs_sasl_dispose(ctxt);
304803
+			ldapinit_mutex_unlock();
304803
 			ldap = connect_to_server(logopt, ctxt->server, ctxt);
304803
 		}
304803
 #endif
304803
@@ -958,7 +962,9 @@ static LDAP *do_reconnect(unsigned logop
304803
 	 * current server again before trying other servers in the list.
304803
 	 */
304803
 	if (!ldap && ctxt->auth_required & LDAP_NEED_AUTH) {
304803
+		ldapinit_mutex_lock();
304803
 		autofs_sasl_dispose(ctxt);
304803
+		ldapinit_mutex_unlock();
304803
 		ldap = connect_to_server(logopt, ctxt->uri->uri, ctxt);
304803
 	}
304803
 #endif
304803
@@ -969,7 +975,9 @@ static LDAP *do_reconnect(unsigned logop
304803
 
304803
 find_server:
304803
 #ifdef WITH_SASL
304803
+	ldapinit_mutex_lock();
304803
 	autofs_sasl_dispose(ctxt);
304803
+	ldapinit_mutex_unlock();
304803
 #endif
304803
 
304803
 	/* Current server failed, try the rest or dc connection */
304803
@@ -1742,11 +1750,14 @@ int lookup_init(const char *mapfmt, int
304803
 
304803
 #ifdef WITH_SASL
304803
 	/* Init the sasl callbacks */
304803
+	ldapinit_mutex_lock();
304803
 	if (!autofs_sasl_client_init(LOGOPT_NONE)) {
304803
 		error(LOGOPT_ANY, "failed to init sasl client");
304803
+		ldapinit_mutex_unlock();
304803
 		free_context(ctxt);
304803
 		return 1;
304803
 	}
304803
+	ldapinit_mutex_unlock();
304803
 #endif
304803
 
304803
 	if (is_amd_format)
304803
@@ -3678,8 +3689,10 @@ int lookup_done(void *context)
304803
 	struct lookup_context *ctxt = (struct lookup_context *) context;
304803
 	int rv = close_parse(ctxt->parse);
304803
 #ifdef WITH_SASL
304803
+	ldapinit_mutex_lock();
304803
 	autofs_sasl_dispose(ctxt);
304803
 	autofs_sasl_done();
304803
+	ldapinit_mutex_unlock();
304803
 #endif
304803
 	free_context(ctxt);
304803
 	return rv;