#include <ac/ctype.h>
#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 <sasl.h>
/*
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 ) {
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);
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 */
#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
};
#define LDAP_VALID(ld) ( (ld)->ld_valid == LDAP_VALID_SESSION )
-#if defined(HAVE_RES_QUERY) && defined(LDAP_R_COMPILE)
+#ifdef LDAP_R_COMPILE
#include <ldap_pvt_thread.h>
+
+#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
/*
* in cyrus.c
*/
+
LDAP_F (int) ldap_int_sasl_init LDAP_P(( void ));
LDAP_F (int) ldap_int_sasl_open LDAP_P((
LDAP_SASL_INTERACT_PROC *interact,
void *defaults ));
+
/*
* in tls.c
*/
#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
/* 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;
}
}
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;
}
*/
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;
++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;
#include "ldap-int.h"
-
/*
* ldap_sasl_bind - bind to the ldap server (and X.500).
* The dn (usually NULL), mechanism, and credentials are provided.
{
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,
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;
}