[Pkg-openldap-devel] [openldap] 200/209: ITS#8648 init SASL library in global init

Ryan Tandy rtandy-guest at moszumanska.debian.org
Tue Jul 18 03:51:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

rtandy-guest pushed a commit to branch upstream
in repository openldap.

commit d59310f86295d5ca0e2947efc78a08448610a074
Author: Ryan Tandy <ryan at nardis.ca>
Date:   Fri May 5 03:08:07 2017 +0000

    ITS#8648 init SASL library in global init
---
 libraries/libldap/cyrus.c | 17 +++--------------
 libraries/libldap/init.c  |  6 ++++++
 2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c
index c633498..cc12502 100644
--- a/libraries/libldap/cyrus.c
+++ b/libraries/libldap/cyrus.c
@@ -69,11 +69,11 @@ static const sasl_callback_t client_callbacks[] = {
 	{ SASL_CB_LIST_END, NULL, NULL }
 };
 
+/*
+ * ldap_int_initialize is responsible for calling this only once.
+ */
 int ldap_int_sasl_init( void )
 {
-	/* XXX not threadsafe */
-	static int sasl_initialized = 0;
-
 #ifdef HAVE_SASL_VERSION
 	/* stringify the version number, sasl.h doesn't do it for us */
 #define VSTR0(maj, min, pat)	#maj "." #min "." #pat
@@ -96,9 +96,6 @@ int ldap_int_sasl_init( void )
 	}
 	}
 #endif
-	if ( sasl_initialized ) {
-		return 0;
-	}
 
 /* SASL 2 takes care of its own memory completely internally */
 #if SASL_VERSION_MAJOR < 2 && !defined(CSRIMALLOC)
@@ -118,7 +115,6 @@ int ldap_int_sasl_init( void )
 #endif
 
 	if ( sasl_client_init( NULL ) == SASL_OK ) {
-		sasl_initialized = 1;
 		return 0;
 	}
 
@@ -329,11 +325,6 @@ ldap_int_sasl_open(
 		return ld->ld_errno;
 	}
 
-	if ( ldap_int_sasl_init() ) {
-		ld->ld_errno = LDAP_LOCAL_ERROR;
-		return ld->ld_errno;
-	}
-
 #if SASL_VERSION_MAJOR >= 2
 	rc = sasl_client_new( "ldap", host, NULL, NULL,
 		client_callbacks, 0, &ctx );
@@ -913,8 +904,6 @@ int
 ldap_int_sasl_get_option( LDAP *ld, int option, void *arg )
 {
 	if ( option == LDAP_OPT_X_SASL_MECHLIST ) {
-		if ( ldap_int_sasl_init() )
-			return -1;
 		*(char ***)arg = (char **)sasl_global_listmech();
 		return 0;
 	}
diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c
index 413121d..39ad7ce 100644
--- a/libraries/libldap/init.c
+++ b/libraries/libldap/init.c
@@ -658,6 +658,12 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
 	if ( ldap_int_tblsize == 0 ) ldap_int_ip_init();
 #endif
 
+#ifdef HAVE_CYRUS_SASL
+	if ( ldap_int_sasl_init() != 0 ) {
+		return;
+	}
+#endif
+
 	ldap_int_initialize_global_options(gopts, dbglvl);
 
 	if( getenv("LDAPNOINIT") != NULL ) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git



More information about the Pkg-openldap-devel mailing list