Skip to content
Snippets Groups Projects
Commit 5f25c109 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

new rebind proc

new SASL locking
parent 5ac196e3
No related branches found
No related tags found
No related merge requests found
......@@ -16,11 +16,13 @@
#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>
/*
......@@ -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 ) {
......
......@@ -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);
......
......@@ -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 <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
......@@ -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
*/
......
......@@ -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;
}
......@@ -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;
......
......@@ -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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment