From: Kurt Zeilenga Date: Fri, 15 Jun 2001 00:14:56 +0000 (+0000) Subject: new rebind proc X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1310 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5f25c10980d24df1ea2d4eb9e3696529737522c6;p=openldap new rebind proc new SASL locking --- diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 3fc3c7e144..abed0261a4 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -16,11 +16,13 @@ #include #include "ldap-int.h" + +#ifdef HAVE_CYRUS_SASL + #ifdef LDAP_R_COMPILE -#include "ldap_pvt_thread.h" +ldap_pvt_thread_mutex_t ldap_int_sasl_mutex; #endif -#ifdef HAVE_CYRUS_SASL #include /* @@ -62,6 +64,8 @@ int ldap_int_sasl_init( void ) ldap_pvt_sasl_mutex_lock, ldap_pvt_sasl_mutex_unlock, ldap_pvt_sasl_mutex_dispose ); + + ldap_pvt_thread_mutex_init( &ldap_int_sasl_mutex ); #endif if ( sasl_client_init( client_callbacks ) == SASL_OK ) { diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index ae70a5830e..a823946c7c 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -397,7 +397,8 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl gopts->ldo_defport = LDAP_PORT; gopts->ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT; - gopts->ldo_rebindproc = NULL; + gopts->ldo_rebind_proc = NULL; + gopts->ldo_rebind_params = NULL; LDAP_BOOL_ZERO(gopts); diff --git a/libraries/libldap/ldap-int.h b/libraries/libldap/ldap-int.h index a3e13b3d00..0bd22e560d 100644 --- a/libraries/libldap/ldap-int.h +++ b/libraries/libldap/ldap-int.h @@ -147,7 +147,8 @@ struct ldapoptions { LDAPControl **ldo_cctrls; /* LDAP rebind callback function */ - LDAP_REBIND_PROC *ldo_rebindproc; + LDAP_REBIND_PROC *ldo_rebind_proc; + void *ldo_rebind_params; #ifdef HAVE_TLS /* tls context */ @@ -268,7 +269,8 @@ struct ldap { #define ld_sctrls ld_options.ldo_sctrls #define ld_cctrls ld_options.ldo_cctrls -#define ld_rebindproc ld_options.ldo_rebindproc +#define ld_rebind_proc ld_options.ldo_rebind_proc +#define ld_rebind_params ld_options.ldo_rebind_params #define ld_version ld_options.ldo_version @@ -298,10 +300,17 @@ struct ldap { }; #define LDAP_VALID(ld) ( (ld)->ld_valid == LDAP_VALID_SESSION ) -#if defined(HAVE_RES_QUERY) && defined(LDAP_R_COMPILE) +#ifdef LDAP_R_COMPILE #include + +#ifdef HAVE_RES_QUERY LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex; -#endif /* HAVE_RES_QUERY && LDAP_R_COMPILE */ +#endif /* HAVE_RES_QUERY */ + +#ifdef HAVE_CYRUS_SASL +LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex; +#endif +#endif /* * in init.c @@ -515,6 +524,7 @@ LDAP_F (void) ldap_free_urllist LDAP_P(( /* * in cyrus.c */ + LDAP_F (int) ldap_int_sasl_init LDAP_P(( void )); LDAP_F (int) ldap_int_sasl_open LDAP_P(( @@ -543,6 +553,7 @@ LDAP_F (int) ldap_int_sasl_bind LDAP_P(( LDAP_SASL_INTERACT_PROC *interact, void *defaults )); + /* * in tls.c */ diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c index 041897494d..455af6ba65 100644 --- a/libraries/libldap/options.c +++ b/libraries/libldap/options.c @@ -17,6 +17,7 @@ #include "ldap-int.h" #define LDAP_OPT_REBIND_PROC 0x4e814d +#define LDAP_OPT_REBIND_PARAMS 0x4e814e static const LDAPAPIFeatureInfo features[] = { #ifdef LDAP_API_FEATURE_X_OPENLDAP @@ -420,7 +421,10 @@ ldap_set_option( /* Only accessed from inside this function by ldap_set_rebind_proc() */ case LDAP_OPT_REBIND_PROC: { - lo->ldo_rebindproc = (LDAP_REBIND_PROC *)invalue; + lo->ldo_rebind_proc = (LDAP_REBIND_PROC *)invalue; + } return LDAP_OPT_SUCCESS; + case LDAP_OPT_REBIND_PARAMS: { + lo->ldo_rebind_params = (void *)invalue; } return LDAP_OPT_SUCCESS; } @@ -593,7 +597,12 @@ ldap_set_option( } int -ldap_set_rebind_proc( LDAP *ld, LDAP_REBIND_PROC *rebind_proc) +ldap_set_rebind_proc( LDAP *ld, LDAP_REBIND_PROC *proc, void *params ) { - return( ldap_set_option( ld, LDAP_OPT_REBIND_PROC, (void *)rebind_proc)); + int rc; + rc = ldap_set_option( ld, LDAP_OPT_REBIND_PROC, (void *)proc ); + if( rc != LDAP_OPT_SUCCESS ) return rc; + + rc = ldap_set_option( ld, LDAP_OPT_REBIND_PARAMS, (void *)params ); + return rc; } diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 6a707ec466..3876b14c1f 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -289,7 +289,7 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, */ lc->lconn_rebind_inprogress = 1; /* V3 rebind function */ - if ( ld->ld_rebindproc != NULL) { + if ( ld->ld_rebind_proc != NULL) { LDAPURLDesc *srvfunc; if( ( srvfunc = ldap_url_dup( srvlist)) == NULL) { ld->ld_errno = LDAP_NO_MEMORY; @@ -299,8 +299,10 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc *srvlist, int use_ldsb, ++lc->lconn_refcnt; /* avoid premature free */ ld->ld_defconn = lc; - Debug( LDAP_DEBUG_TRACE, "Call application rebindproc\n", 0, 0, 0); - err = (*ld->ld_rebindproc)( ld, bind->ri_url, bind->ri_request, bind->ri_msgid); + Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0); + err = (*ld->ld_rebind_proc)( ld, + bind->ri_url, bind->ri_request, bind->ri_msgid, + ld->ld_rebind_params); ld->ld_defconn = savedefconn; --lc->lconn_refcnt; diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index e22b11ce96..12cb381663 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -37,7 +37,6 @@ #include "ldap-int.h" - /* * ldap_sasl_bind - bind to the ldap server (and X.500). * The dn (usually NULL), mechanism, and credentials are provided. @@ -417,13 +416,17 @@ ldap_sasl_interactive_bind_s( { int rc; +#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) + ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); +#endif + if( mechs == NULL || *mechs == '\0' ) { char *smechs; rc = ldap_pvt_sasl_getmechs( ld, &smechs ); if( rc != LDAP_SUCCESS ) { - return rc; + goto done; } Debug( LDAP_DEBUG_TRACE, @@ -442,5 +445,10 @@ ldap_sasl_interactive_bind_s( serverControls, clientControls, flags, interact, defaults ); +done: +#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) + ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); +#endif + return rc; }