From: Pierangelo Masarati Date: Fri, 18 Apr 2003 10:02:00 +0000 (+0000) Subject: ensure all metasingleconns are init'ed X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~315 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7de67df355e59377404676e45a816a6bb81e236f;p=openldap ensure all metasingleconns are init'ed --- diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 84cd524a64..483f045d1b 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -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 ) { diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index f13352e7bb..ddc1031e66 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -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; } diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index b98d44cbab..20c783902a 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -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 );