Blame SOURCES/autofs-5.0.8-extend-libldap-serialization.patch

304803
autofs-5.0.8 - extend libldap serialization
304803
304803
From: Leonardo Chiquitto <leonardo.lists@gmail.com>
304803
304803
It's necessary to serialize calls to ldap_unbind() as well as the
304803
initial bind.
304803
---
304803
 CHANGELOG             |    1 +
304803
 modules/lookup_ldap.c |   20 ++++++++++++++++----
304803
 2 files changed, 17 insertions(+), 4 deletions(-)
304803
304803
--- autofs-5.0.7.orig/CHANGELOG
304803
+++ autofs-5.0.7/CHANGELOG
304803
@@ -107,6 +107,7 @@
304803
 - use open(2) instead of access(2) to trigger dependent mounts.
304803
 - fix crash due to thread unsafe use of libldap.
304803
 - fix deadlock in init_ldap_connection.
304803
+- extend fix for crash due to thread unsafe use of libldap.
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
@@ -53,8 +53,9 @@ static struct ldap_schema common_schema[
304803
 static unsigned int common_schema_count = sizeof(common_schema)/sizeof(struct ldap_schema);
304803
 
304803
 /*
304803
- * Initialization of LDAP and OpenSSL must be always serialized to
304803
- * avoid corruption of context structures inside these libraries.
304803
+ * Initialization and de-initialization of LDAP and OpenSSL must be
304803
+ * always serialized to avoid corruption of context structures inside
304803
+ * these libraries.
304803
  */
304803
 pthread_mutex_t ldapinit_mutex = PTHREAD_MUTEX_INITIALIZER;
304803
 
304803
@@ -203,7 +204,7 @@ int bind_ldap_simple(unsigned logopt, LD
304803
 	return 0;
304803
 }
304803
 
304803
-int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
304803
+int __unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
304803
 {
304803
 	int rv;
304803
 
304803
@@ -220,6 +221,17 @@ int unbind_ldap_connection(unsigned logo
304803
 	return rv;
304803
 }
304803
 
304803
+int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
304803
+{
304803
+	int rv;
304803
+
304803
+	ldapinit_mutex_lock();
304803
+	rv = __unbind_ldap_connection(logopt, ldap, ctxt);
304803
+	ldapinit_mutex_unlock();
304803
+
304803
+	return rv;
304803
+}
304803
+
304803
 LDAP *__init_ldap_connection(unsigned logopt, const char *uri, struct lookup_context *ctxt)
304803
 {
304803
 	LDAP *ldap = NULL;
304803
@@ -280,7 +292,7 @@ LDAP *__init_ldap_connection(unsigned lo
304803
 
304803
 		rv = ldap_start_tls_s(ldap, NULL, NULL);
304803
 		if (rv != LDAP_SUCCESS) {
304803
-			unbind_ldap_connection(logopt, ldap, ctxt);
304803
+			__unbind_ldap_connection(logopt, ldap, ctxt);
304803
 			if (ctxt->tls_required) {
304803
 				error(logopt, MODPREFIX
304803
 				      "TLS required but START_TLS failed: %s",