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

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