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

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