]> git.sur5r.net Git - openldap/commitdiff
new rebind proc
authorKurt Zeilenga <kurt@openldap.org>
Fri, 15 Jun 2001 00:14:56 +0000 (00:14 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 15 Jun 2001 00:14:56 +0000 (00:14 +0000)
new SASL locking

libraries/libldap/cyrus.c
libraries/libldap/init.c
libraries/libldap/ldap-int.h
libraries/libldap/options.c
libraries/libldap/request.c
libraries/libldap/sasl.c

index 3fc3c7e14499fbf9714611a599ef679fba705f35..abed0261a44a88bd18126d9af02f72d6aa56add8 100644 (file)
 #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 ) {
index ae70a5830ec2780c0cc79235aa7dafce88a96cdc..a823946c7c894753d97316343df01f3cc50b1939 100644 (file)
@@ -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);
 
index a3e13b3d004607bf82efb1a3ac535e72783bcf08..0bd22e560d16822ddafe86936437bdc3d0ac7cc1 100644 (file)
@@ -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
  */
index 041897494dc6c9fa1ae8140e4883b34a69962b0e..455af6ba658bc02776b1a18e696325b458eb553b 100644 (file)
@@ -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;
 }
index 6a707ec466ac947973f351eb8a9d546af82e34a0..3876b14c1f93cb9942e4d0d4a2fa594d22ee9d10 100644 (file)
@@ -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;
index e22b11ce96fa47f9859a9e20705a0b37471f5a5e..12cb3816638676ba485978f53ffef7c5731fa1a6 100644 (file)
@@ -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;
 }