From dfbbd11bd3d74f889deef1b805e89d7e39f31173 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 4 Apr 2003 00:43:40 +0000 Subject: [PATCH] remove more unnecessary args --- servers/slapd/back-ldap/add.c | 2 +- servers/slapd/back-ldap/back-ldap.h | 4 +- servers/slapd/back-ldap/bind.c | 10 +-- servers/slapd/back-ldap/compare.c | 2 +- servers/slapd/back-ldap/delete.c | 2 +- servers/slapd/back-ldap/modify.c | 2 +- servers/slapd/back-ldap/modrdn.c | 2 +- servers/slapd/back-ldap/search.c | 8 ++- servers/slapd/back-meta/add.c | 2 +- servers/slapd/back-meta/back-meta.h | 1 - servers/slapd/back-meta/bind.c | 86 ++++++++++++-------------- servers/slapd/back-meta/cache-search.c | 2 +- servers/slapd/back-meta/compare.c | 2 +- servers/slapd/back-meta/conn.c | 2 +- servers/slapd/back-meta/delete.c | 2 +- servers/slapd/back-meta/modify.c | 2 +- servers/slapd/back-meta/modrdn.c | 2 +- servers/slapd/back-meta/search.c | 2 +- 18 files changed, 65 insertions(+), 70 deletions(-) diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index d2ec162cdd..24b3ad9226 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -184,7 +184,7 @@ ldap_back_add( free( mdn.bv_val ); } - return( ldap_back_op_result( li, lc, op, rs, msgid, j, 1 ) ); + return( ldap_back_op_result( lc, op, rs, msgid, j, 1 ) ); } #ifdef ENABLE_REWRITE diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index a329382bed..3692f28047 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -94,8 +94,8 @@ struct ldapinfo { struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs); int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs); int ldap_back_map_result(int err); -int ldap_back_op_result(struct ldapinfo *li, struct ldapconn *lc, - Operation *op, SlapReply *rs, ber_int_t msgid, int rc, int sendok); +int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs, + ber_int_t msgid, int rc, int sendok); int back_ldap_LTX_init_module(int argc, char *argv[]); void ldap_back_dn_massage(struct ldapinfo *li, struct berval *dn, diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 769ce838ae..8430059d3c 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -115,7 +115,7 @@ ldap_back_bind( /* method is always LDAP_AUTH_SIMPLE if we got here */ rc = ldap_sasl_bind(lc->ld, mdn.bv_val, LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred, op->o_ctrls, NULL, &msgid); - rc = ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ); + rc = ldap_back_op_result( lc, op, rs, msgid, rc, 1 ); if (rc == LDAP_SUCCESS) { lc->bound = 1; if ( mdn.bv_val != op->o_req_dn.bv_val ) { @@ -425,7 +425,6 @@ ldap_back_getconn(Operation *op, SlapReply *rs) int ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs ) { - struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private; int rc; ber_int_t msgid; @@ -433,7 +432,7 @@ ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs ) if ( !lc->bound ) { rc = ldap_sasl_bind(lc->ld, lc->bound_dn.bv_val, LDAP_SASL_SIMPLE, &lc->cred, NULL, NULL, &msgid); - rc = ldap_back_op_result( li, lc, op, rs, msgid, rc, 0 ); + rc = ldap_back_op_result( lc, op, rs, msgid, rc, 0 ); if (rc == LDAP_SUCCESS) { lc->bound = 1; } @@ -506,9 +505,10 @@ ldap_back_map_result(int err) } int -ldap_back_op_result(struct ldapinfo *li, struct ldapconn *lc, - Operation *op, SlapReply *rs, ber_int_t msgid, int err, int sendok) +ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs, + ber_int_t msgid, int err, int sendok) { + struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private; char *match = NULL; LDAPMessage *res; int rc; diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index f17dfaf9c8..86e274b603 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -119,5 +119,5 @@ ldap_back_compare( free( mdn.bv_val ); } - return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) ); + return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) ); } diff --git a/servers/slapd/back-ldap/delete.c b/servers/slapd/back-ldap/delete.c index e34137613f..e97ff05263 100644 --- a/servers/slapd/back-ldap/delete.c +++ b/servers/slapd/back-ldap/delete.c @@ -101,5 +101,5 @@ ldap_back_delete( free( mdn.bv_val ); } - return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) ); + return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) ); } diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 0695021bf8..7c802806d0 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -166,6 +166,6 @@ cleanup:; ch_free( mods ); ch_free( modv ); - return ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ); + return ldap_back_op_result( lc, op, rs, msgid, rc, 1 ); } diff --git a/servers/slapd/back-ldap/modrdn.c b/servers/slapd/back-ldap/modrdn.c index a00f4a8860..74a6813914 100644 --- a/servers/slapd/back-ldap/modrdn.c +++ b/servers/slapd/back-ldap/modrdn.c @@ -148,5 +148,5 @@ ldap_back_modrdn( free( mnewSuperior.bv_val ); } - return( ldap_back_op_result( li, lc, op, rs, msgid, rc, 1 ) ); + return( ldap_back_op_result( lc, op, rs, msgid, rc, 1 ) ); } diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 535d06707c..8e719bf022 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -148,6 +148,8 @@ ldap_back_search( case REWRITE_REGEXEC_OK: if ( mbase.bv_val == NULL ) { mbase = op->o_req_dn; + } else { + mbase.bv_len = strlen( mbase.bv_val ); } #ifdef NEW_LOGGING LDAP_LOG( BACK_LDAP, DETAIL1, @@ -205,7 +207,7 @@ ldap_back_search( : NULL, op->oq_search.rs_slimit, &msgid); if ( rc != LDAP_SUCCESS ) { fail:; - rc = ldap_back_op_result(li, lc, op, rs, msgid, rc, 0); + rc = ldap_back_op_result(lc, op, rs, msgid, rc, 0); goto finish; } @@ -389,6 +391,10 @@ ldap_build_entry( struct berval *bv; const char *text; + /* safe assumptions ... */ + assert( ent ); + ent->e_bv.bv_val = NULL; + if ( ber_scanf( &ber, "{m{", bdn ) == LBER_ERROR ) { return LDAP_DECODING_ERROR; } diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 8e1fc4eecc..2cf5cb4961 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -97,7 +97,7 @@ meta_back_add( Operation *op, SlapReply *rs ) /* * get the current connection */ - lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE, + lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE, &op->o_req_ndn, &candidate ); if ( !lc ) { send_ldap_result( op, rs ); diff --git a/servers/slapd/back-meta/back-meta.h b/servers/slapd/back-meta/back-meta.h index a81767eb3f..d7d2f85920 100644 --- a/servers/slapd/back-meta/back-meta.h +++ b/servers/slapd/back-meta/back-meta.h @@ -165,7 +165,6 @@ struct metainfo { #define META_OP_REQUIRE_ALL 0x02 extern struct metaconn * meta_back_getconn( - struct metainfo *li, Operation *op, SlapReply *rs, int op_type, diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 5cff3a9427..eec3d54b37 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -81,28 +81,13 @@ static LDAP_REBIND_PROC meta_back_rebind; static int meta_back_do_single_bind( - struct metainfo *li, struct metaconn *lc, Operation *op, - struct berval *dn, - struct berval *ndn, - struct berval *cred, - int method, int candidate ); int meta_back_bind( Operation *op, SlapReply *rs ) - /* - Backend *be, - Connection *conn, - Operation *op, - struct berval *dn, - struct berval *ndn, - int method, - struct berval *cred, - struct berval *edn -) */ { struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; struct metaconn *lc; @@ -111,11 +96,6 @@ meta_back_bind( Operation *op, SlapReply *rs ) int op_type = META_OP_ALLOW_MULTIPLE; int err = LDAP_SUCCESS; - struct berval *realdn = &op->o_req_dn; - struct berval *realndn = &op->o_req_ndn; - struct berval *realcred = &op->oq_bind.rb_cred; - int realmethod = op->oq_bind.rb_method; - #ifdef NEW_LOGGING LDAP_LOG( BACK_META, ENTRY, "meta_back_bind: dn: %s.\n", op->o_req_dn.bv_val, 0, 0 ); @@ -129,7 +109,7 @@ meta_back_bind( Operation *op, SlapReply *rs ) ber_dupbv( &op->oq_bind.rb_edn, be_root_dn( op->o_bd ) ); op_type = META_OP_REQUIRE_ALL; } - lc = meta_back_getconn( li, op, rs, op_type, + lc = meta_back_getconn( op, rs, op_type, &op->o_req_ndn, NULL ); if ( !lc ) { #ifdef NEW_LOGGING @@ -151,7 +131,12 @@ meta_back_bind( Operation *op, SlapReply *rs ) lc->bound_target = META_BOUND_NONE; ndnlen = op->o_req_ndn.bv_len; for ( i = 0; i < li->ntargets; i++ ) { - int lerr; + int lerr; + struct berval orig_dn = op->o_req_dn; + struct berval orig_ndn = op->o_req_ndn; + struct berval orig_cred = op->oq_bind.rb_cred; + int orig_method = op->oq_bind.rb_method; + /* * Skip non-candidates @@ -182,25 +167,24 @@ meta_back_bind( Operation *op, SlapReply *rs ) } if ( isroot && li->targets[ i ]->pseudorootdn.bv_val != NULL ) { - realdn = &li->targets[ i ]->pseudorootdn; - realndn = &li->targets[ i ]->pseudorootdn; - realcred = &li->targets[ i ]->pseudorootpw; - realmethod = LDAP_AUTH_SIMPLE; - } else { - realdn = &op->o_req_dn; - realndn = &op->o_req_ndn; - realcred = &op->oq_bind.rb_cred; - realmethod = op->oq_bind.rb_method; + op->o_req_dn = li->targets[ i ]->pseudorootdn; + op->o_req_ndn = li->targets[ i ]->pseudorootdn; + op->oq_bind.rb_cred = li->targets[ i ]->pseudorootpw; + op->oq_bind.rb_method = LDAP_AUTH_SIMPLE; } - lerr = meta_back_do_single_bind( li, lc, op, - realdn, realndn, realcred, realmethod, i ); + lerr = meta_back_do_single_bind( lc, op, i ); if ( lerr != LDAP_SUCCESS ) { err = lerr; ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 ); } else { rc = LDAP_SUCCESS; } + + op->o_req_dn = orig_dn; + op->o_req_ndn = orig_ndn; + op->oq_bind.rb_cred = orig_cred; + op->oq_bind.rb_method = orig_method; } if ( isroot ) { @@ -241,16 +225,12 @@ meta_back_bind( Operation *op, SlapReply *rs ) */ static int meta_back_do_single_bind( - struct metainfo *li, struct metaconn *lc, Operation *op, - struct berval *dn, - struct berval *ndn, - struct berval *cred, - int method, int candidate ) { + struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; struct berval mdn = { 0, NULL }; int rc; ber_int_t msgid; @@ -259,18 +239,22 @@ meta_back_do_single_bind( * Rewrite the bind dn if needed */ switch ( rewrite_session( li->targets[ candidate ]->rwinfo, - "bindDn", dn->bv_val, lc->conn, &mdn.bv_val ) ) { + "bindDn", op->o_req_dn.bv_val, + lc->conn, &mdn.bv_val ) ) { case REWRITE_REGEXEC_OK: if ( mdn.bv_val == NULL ) { - mdn = *dn; + mdn = op->o_req_dn; + } else { + mdn.bv_len = strlen( mdn.bv_val ); } #ifdef NEW_LOGGING LDAP_LOG( BACK_META, DETAIL1, - "[rw] bindDn: \"%s\" -> \"%s\"\n", dn->bv_val, mdn.bv_val, 0 ); + "[rw] bindDn: \"%s\" -> \"%s\"\n", + op->o_req_dn.bv_val, mdn.bv_val, 0 ); #else /* !NEW_LOGGING */ Debug( LDAP_DEBUG_ARGS, "rw> bindDn: \"%s\" -> \"%s\"\n%s", - dn->bv_val, mdn.bv_val, "" ); + op->o_req_dn.bv_val, mdn.bv_val, "" ); #endif /* !NEW_LOGGING */ break; @@ -291,33 +275,39 @@ meta_back_do_single_bind( } rc = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val, - LDAP_SASL_SIMPLE, cred, op->o_ctrls, NULL, &msgid); + LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred, + op->o_ctrls, NULL, &msgid); if ( rc != LDAP_SUCCESS ) { rc = ldap_back_map_result( rc ); + } else { - ber_dupbv( &lc->conns[ candidate ].bound_dn, dn ); + /* + * FIXME: handle response!!! + */ + ber_dupbv( &lc->conns[ candidate ].bound_dn, &op->o_req_dn ); lc->conns[ candidate ].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, cred ); + 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 ( li->cache.ttl != META_DNCACHE_DISABLED - && ndn->bv_len != 0 ) { + && op->o_req_ndn.bv_len != 0 ) { ( void )meta_dncache_update_entry( &li->cache, - ndn, candidate ); + &op->o_req_ndn, candidate ); } } return_results:; - if ( mdn.bv_val != dn->bv_val ) { + if ( mdn.bv_val != op->o_req_dn.bv_val ) { free( mdn.bv_val ); } diff --git a/servers/slapd/back-meta/cache-search.c b/servers/slapd/back-meta/cache-search.c index 97bb31df02..9e31a226ab 100644 --- a/servers/slapd/back-meta/cache-search.c +++ b/servers/slapd/back-meta/cache-search.c @@ -1002,7 +1002,7 @@ metaConnect( { struct metaconn* lc; result->type = SUCCESS; - lc = meta_back_getconn( li, conn, op, op_type, nbase, NULL ); + lc = meta_back_getconn( conn, op, op_type, nbase, NULL ); if (!lc) { result->type = CONN_ERR; return 0; diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 3da152810f..8381fb846c 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -86,7 +86,7 @@ meta_back_compare( Operation *op, SlapReply *rs ) int cres = LDAP_SUCCESS, rres = LDAP_SUCCESS; int *msgid; - lc = meta_back_getconn( li, op, rs, META_OP_ALLOW_MULTIPLE, + lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE, &op->o_req_ndn, NULL ); if ( !lc ) { send_ldap_result( op, rs ); diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 58dc1f0448..7cb947ec6c 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -339,13 +339,13 @@ init_one_conn( */ struct metaconn * meta_back_getconn( - struct metainfo *li, Operation *op, SlapReply *rs, int op_type, struct berval *ndn, int *candidate ) { + struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; struct metaconn *lc, lc_curr; int cached = -1, i = -1, err = LDAP_SUCCESS; int new_conn = 0; diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index bc8041e62f..4313bce7b9 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -84,7 +84,7 @@ meta_back_delete( Operation *op, SlapReply *rs ) char *mdn = NULL; - lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE, + lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE, &op->o_req_ndn, &candidate ); if ( !lc ) { send_ldap_result( op, rs ); diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index e8f4487174..c6f801a24b 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -88,7 +88,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) char *mdn; struct berval mapped; - lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE, + lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE, &op->o_req_ndn, &candidate ); if ( !lc ) { rc = -1; diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index 79ab4ec477..10fa1c5a18 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -97,7 +97,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) char *mdn = NULL, *mnewSuperior = NULL; - lc = meta_back_getconn( li, op, rs, META_OP_REQUIRE_SINGLE, + lc = meta_back_getconn( op, rs, META_OP_REQUIRE_SINGLE, &op->o_req_ndn, &candidate ); if ( !lc ) { rc = -1; diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 78a297194a..310be19023 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -136,7 +136,7 @@ meta_back_search( Operation *op, SlapReply *rs ) * FIXME: in case of values return filter, we might want * to map attrs and maybe rewrite value */ - lc = meta_back_getconn( li, op, rs, META_OP_ALLOW_MULTIPLE, + lc = meta_back_getconn( op, rs, META_OP_ALLOW_MULTIPLE, &op->o_req_ndn, NULL ); if ( !lc ) { send_ldap_result( op, rs ); -- 2.39.5