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

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