]> git.sur5r.net Git - openldap/commitdiff
ensure all metasingleconns are init'ed
authorPierangelo Masarati <ando@openldap.org>
Fri, 18 Apr 2003 10:02:00 +0000 (10:02 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 18 Apr 2003 10:02:00 +0000 (10:02 +0000)
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/init.c

index 84cd524a64d5099c7db1b1cf716a57e8ee8a67a2..483f045d1b848c7ede89f4449f867863695ea0e6 100644 (file)
@@ -237,6 +237,7 @@ meta_back_do_single_bind(
        struct berval   mdn = { 0, NULL };
        ber_int_t       msgid;
        dncookie        dc;
+       struct metasingleconn   *lsc = &lc->conns[ candidate ];
        
        /*
         * Rewrite the bind dn if needed
@@ -252,7 +253,7 @@ meta_back_do_single_bind(
        }
 
        if ( op->o_ctrls ) {
-               rs->sr_err = ldap_set_option( lc->conns[ candidate ].ld, 
+               rs->sr_err = ldap_set_option( lsc->ld, 
                                LDAP_OPT_SERVER_CONTROLS, op->o_ctrls );
                if ( rs->sr_err != LDAP_SUCCESS ) {
                        rs->sr_err = ldap_back_map_result( rs );
@@ -260,7 +261,7 @@ meta_back_do_single_bind(
                }
        }
        
-       rs->sr_err = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val,
+       rs->sr_err = ldap_sasl_bind(lsc->ld, mdn.bv_val,
                        LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred,
                        op->o_ctrls, NULL, &msgid);
        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -270,18 +271,20 @@ meta_back_do_single_bind(
                /*
                 * FIXME: handle response!!!
                 */
-               ber_dupbv( &lc->conns[ candidate ].bound_dn, &op->o_req_dn );
-               lc->conns[ candidate ].bound = META_BOUND;
+               if ( lsc->bound_dn.bv_val != NULL ) {
+                       ber_memfree( lsc->bound_dn.bv_val );
+               }
+               ber_dupbv( &lsc->bound_dn, &op->o_req_dn );
+               lsc->bound = META_BOUND;
                lc->bound_target = candidate;
 
                if ( li->savecred ) {
-                       if ( lc->conns[ candidate ].cred.bv_val )
-                               ch_free( lc->conns[ candidate ].cred.bv_val );
-                       ber_dupbv( &lc->conns[ candidate ].cred,
-                                       &op->oq_bind.rb_cred );
-                       ldap_set_rebind_proc( lc->conns[ candidate ].ld, 
-                                       meta_back_rebind, 
-                                       &lc->conns[ candidate ] );
+                       if ( lsc->cred.bv_val ) {
+                               memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
+                               ber_memfree( lsc->cred.bv_val );
+                       }
+                       ber_dupbv( &lsc->cred, &op->oq_bind.rb_cred );
+                       ldap_set_rebind_proc( lsc->ld, meta_back_rebind, lsc );
                }
 
                if ( li->cache.ttl != META_DNCACHE_DISABLED
@@ -351,11 +354,18 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                 * bind clears the previous bind).
                 */
                if ( lsc->bound_dn.bv_val ) {
-                       ch_free( lsc->bound_dn.bv_val );
+                       ber_memfree( lsc->bound_dn.bv_val );
                        lsc->bound_dn.bv_val = NULL;
                        lsc->bound_dn.bv_len = 0;
                }
                
+               if ( /* FIXME: need li ... li->savecred && */ 
+                               lsc->cred.bv_val ) {
+                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
+                       ber_memfree( lsc->cred.bv_val );
+                       lsc->cred.bv_val = NULL;
+                       lsc->cred.bv_len = 0;
+               }
 
                rc = ldap_bind_s( lsc->ld, 0, NULL, LDAP_AUTH_SIMPLE );
                if ( rc != LDAP_SUCCESS ) {
index f13352e7bbd654911bb9dd80a4b7683b52b6ef21..ddc1031e66e6909ec2507d8c613079ae3374bf78 100644 (file)
@@ -188,6 +188,15 @@ metaconn_alloc( int ntargets )
        }
        lc->conns[ ntargets ].candidate = META_LAST_CONN;
 
+       for ( ; ntargets-- > 0; ) {
+               lc->conns[ ntargets ].ld = NULL;
+               lc->conns[ ntargets ].bound_dn.bv_val = NULL;
+               lc->conns[ ntargets ].bound_dn.bv_len = 0;
+               lc->conns[ ntargets ].cred.bv_val = NULL;
+               lc->conns[ ntargets ].cred.bv_len = 0;
+               lc->conns[ ntargets ].bound = META_UNBOUND;
+       }
+
        lc->bound_target = META_BOUND_NONE;
 
        return lc;
@@ -271,7 +280,8 @@ init_one_conn(
                /*
                 * Rewrite the bind dn if needed
                 */
-               if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn, &lsc->bound_dn) ) {
+               if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn,
+                                       &lsc->bound_dn) ) {
                        send_ldap_result( op, rs );
                        return rs->sr_err;
                }
index b98d44cbab3a239affef28e6c57203663b0831bd..20c783902a985b05211e63fc459fff8220c43cf2 100644 (file)
@@ -226,6 +226,10 @@ conn_free(
                if ( lsc->bound_dn.bv_val ) {
                        ber_memfree( lsc->bound_dn.bv_val );
                }
+               if ( lsc->cred.bv_val ) {
+                       memset( lsc->cred.bv_val, 0, lsc->cred.bv_len );
+                       ber_memfree( lsc->cred.bv_val );
+               }
        }
        free( lc->conns );
        free( lc );