From: Pierangelo Masarati Date: Sat, 5 Apr 2003 16:53:57 +0000 (+0000) Subject: propagate selected changes to back-ldap X-Git-Tag: AUTOCONF_2_57~59 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5804183f0431c63a38f86ad6078f8f84e7225d5d;p=openldap propagate selected changes to back-ldap --- diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index eec3d54b37..d990ffb98f 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -83,6 +83,7 @@ static int meta_back_do_single_bind( struct metaconn *lc, Operation *op, + SlapReply *rs, int candidate ); @@ -94,7 +95,8 @@ meta_back_bind( Operation *op, SlapReply *rs ) int rc = -1, i, gotit = 0, ndnlen, isroot = 0; int op_type = META_OP_ALLOW_MULTIPLE; - int err = LDAP_SUCCESS; + + rs->sr_err = LDAP_SUCCESS; #ifdef NEW_LOGGING LDAP_LOG( BACK_META, ENTRY, "meta_back_bind: dn: %s.\n", @@ -173,9 +175,9 @@ meta_back_bind( Operation *op, SlapReply *rs ) op->oq_bind.rb_method = LDAP_AUTH_SIMPLE; } - lerr = meta_back_do_single_bind( lc, op, i ); + lerr = meta_back_do_single_bind( lc, op, rs, i ); if ( lerr != LDAP_SUCCESS ) { - err = lerr; + rs->sr_err = lerr; ( void )meta_clear_one_candidate( &lc->conns[ i ], 1 ); } else { rc = LDAP_SUCCESS; @@ -196,7 +198,7 @@ meta_back_bind( Operation *op, SlapReply *rs ) * err is the last error that occurred during a bind; * if at least (and at most?) one bind succeedes, fine. */ - if ( rc != LDAP_SUCCESS /* && err != LDAP_SUCCESS */ ) { + if ( rc != LDAP_SUCCESS /* && rs->sr_err != LDAP_SUCCESS */ ) { /* * deal with bind failure ... @@ -206,11 +208,11 @@ meta_back_bind( Operation *op, SlapReply *rs ) * no target was found within the naming context, * so bind must fail with invalid credentials */ - if ( err == LDAP_SUCCESS && gotit == 0 ) { - err = LDAP_INVALID_CREDENTIALS; + if ( rs->sr_err == LDAP_SUCCESS && gotit == 0 ) { + rs->sr_err = LDAP_INVALID_CREDENTIALS; } - rs->sr_err = ldap_back_map_result( err ); + rs->sr_err = ldap_back_map_result( rs ); send_ldap_result( op, rs ); return -1; } @@ -227,12 +229,12 @@ static int meta_back_do_single_bind( struct metaconn *lc, Operation *op, + SlapReply *rs, int candidate ) { struct metainfo *li = ( struct metainfo * )op->o_bd->be_private; struct berval mdn = { 0, NULL }; - int rc; ber_int_t msgid; /* @@ -266,19 +268,19 @@ meta_back_do_single_bind( } if ( op->o_ctrls ) { - rc = ldap_set_option( lc->conns[ candidate ].ld, + rs->sr_err = ldap_set_option( lc->conns[ candidate ].ld, LDAP_OPT_SERVER_CONTROLS, op->o_ctrls ); - if ( rc != LDAP_SUCCESS ) { - rc = ldap_back_map_result( rc ); + if ( rs->sr_err != LDAP_SUCCESS ) { + rs->sr_err = ldap_back_map_result( rs ); goto return_results; } } - rc = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val, + rs->sr_err = ldap_sasl_bind(lc->conns[ candidate ].ld, mdn.bv_val, LDAP_SASL_SIMPLE, &op->oq_bind.rb_cred, op->o_ctrls, NULL, &msgid); - if ( rc != LDAP_SUCCESS ) { - rc = ldap_back_map_result( rc ); + if ( rs->sr_err != LDAP_SUCCESS ) { + rs->sr_err = ldap_back_map_result( rs ); } else { /* @@ -311,7 +313,7 @@ return_results:; free( mdn.bv_val ); } - return rc; + return rs->sr_err; } /* @@ -459,12 +461,13 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs ) char *rmatch = NULL; for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) { - int err = LDAP_SUCCESS; char *msg = NULL; char *match = NULL; - ldap_get_option( lsc->ld, LDAP_OPT_ERROR_NUMBER, &err ); - if ( err != LDAP_SUCCESS ) { + rs->sr_err = LDAP_SUCCESS; + + ldap_get_option( lsc->ld, LDAP_OPT_ERROR_NUMBER, &rs->sr_err ); + if ( rs->sr_err != LDAP_SUCCESS ) { /* * better check the type of error. In some cases * (search ?) it might be better to return a @@ -475,7 +478,7 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs ) LDAP_OPT_ERROR_STRING, &msg ); ldap_get_option( lsc->ld, LDAP_OPT_MATCHED_DN, &match ); - err = ldap_back_map_result( err ); + rs->sr_err = ldap_back_map_result( rs ); #ifdef NEW_LOGGING LDAP_LOG( BACK_META, RESULTS, @@ -496,9 +499,9 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs ) /* * FIXME: need to rewrite "match" (need rwinfo) */ - switch ( err ) { + switch ( rs->sr_err ) { default: - rerr = err; + rerr = rs->sr_err; rmsg = msg; msg = NULL; rmatch = match; diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index 8381fb846c..d272ab42dc 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -233,8 +233,8 @@ meta_back_compare( Operation *op, SlapReply *rs ) goto finish; } - cres = ldap_result2error( lsc->ld, res, 1 ); - switch ( cres ) { + rs->sr_err = ldap_result2error( lsc->ld, res, 1 ); + switch ( rs->sr_err ) { case LDAP_COMPARE_TRUE: case LDAP_COMPARE_FALSE: @@ -251,7 +251,7 @@ meta_back_compare( Operation *op, SlapReply *rs ) break; default: - rres = ldap_back_map_result( cres ); + rres = ldap_back_map_result( rs ); if ( err != NULL ) { free( err ); diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 7cb947ec6c..77e97225e3 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -221,13 +221,13 @@ metaconn_free( */ static int init_one_conn( - Operation *op, - SlapReply *rs, + Operation *op, + SlapReply *rs, struct metatarget *lt, struct metasingleconn *lsc ) { - int err, vers; + int vers; /* * Already init'ed @@ -239,9 +239,9 @@ init_one_conn( /* * Attempts to initialize the connection to the target ds */ - err = ldap_initialize( &lsc->ld, lt->uri ); - if ( err != LDAP_SUCCESS ) { - return ldap_back_map_result( err ); + rs->sr_err = ldap_initialize( &lsc->ld, lt->uri ); + if ( rs->sr_err != LDAP_SUCCESS ) { + return ldap_back_map_result( rs ); } /* diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 310be19023..fe6e1151d0 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -105,8 +105,7 @@ meta_back_search( Operation *op, SlapReply *rs ) LDAPMessage *res, *e; int count, rc = 0, *msgid, sres = LDAP_NO_SUCH_OBJECT; char *match = NULL, *err = NULL; - char *mbase = NULL, *mmatch = NULL; - struct berval mfilter; + char *mmatch = NULL; BerVarray v2refs = NULL; int i, last = 0, candidates = 0; @@ -210,10 +209,12 @@ meta_back_search( Operation *op, SlapReply *rs ) * Inits searches */ for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) { - char *realbase = ( char * )op->o_req_dn.bv_val; - int realscope = op->oq_search.rs_scope; - ber_len_t suffixlen; - char **mapped_attrs; + char *realbase = ( char * )op->o_req_dn.bv_val; + int realscope = op->oq_search.rs_scope; + ber_len_t suffixlen = 0; + char *mbase = NULL; + struct berval mfilter = { 0L, NULL }; + char **mapped_attrs = NULL; if ( lsc->candidate != META_CANDIDATE ) { msgid[ i ] = -1; @@ -312,83 +313,53 @@ meta_back_search( Operation *op, SlapReply *rs ) goto finish; case REWRITE_REGEXEC_ERR: +#if 0 rs->sr_err = LDAP_OTHER; - rs->sr_text = "rewrite error"; + rs->sr_text = "Rewrite error"; send_ldap_result( op, rs ); rc = -1; goto finish; - } +#endif -#if 0 - /* - * Rewrite the search filter, if required - */ - switch ( rewrite_session( li->targets[ i ]->rwinfo, - "searchFilter", - filterstr->bv_val, conn, &mfilter.bv_val ) ) { - case REWRITE_REGEXEC_OK: - if ( mfilter.bv_val != NULL && mfilter.bv_val[ 0 ] != '\0') { - mfilter.bv_len = strlen( mfilter.bv_val ); - } else { - if ( mfilter.bv_val != NULL ) { - free( mfilter.bv_val ); - } - mfilter = *filterstr; - } -#ifdef NEW_LOGGING - LDAP_LOG( BACK_META, DETAIL1, - "[rw] searchFilter [%d]: \"%s\" -> \"%s\"\n", - i, filterstr->bv_val, mfilter.bv_val ); -#else /* !NEW_LOGGING */ - Debug( LDAP_DEBUG_ARGS, - "rw> searchFilter [%d]: \"%s\" -> \"%s\"\n", - i, filterstr->bv_val, mfilter.bv_val ); -#endif /* !NEW_LOGGING */ - break; - - case REWRITE_REGEXEC_UNWILLING: - send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Operation not allowed", - NULL, NULL ); - rc = -1; - goto finish; - - case REWRITE_REGEXEC_ERR: - send_ldap_result( conn, op, LDAP_OTHER, - NULL, "Rewrite error", NULL, NULL ); - rc = -1; - goto finish; + /* + * this target is no longer candidate + */ + msgid[ i ] = -1; + goto new_candidate; } /* - * Maps attributes in filter + * Maps filter */ - mapped_filter = ldap_back_map_filter( &li->targets[ i ]->at_map, - &li->targets[ i ]->oc_map, &mfilter, - BACKLDAP_MAP ); - if ( mapped_filter == NULL ) { - mapped_filter = ( char * )mfilter.bv_val; - } else { - if ( mfilter.bv_val != filterstr->bv_val ) { - free( mfilter.bv_val ); - } - } - mfilter.bv_val = NULL; - mfilter.bv_len = 0; -#endif - rc = ldap_back_filter_map_rewrite_( li->targets[ i ]->rwinfo, op->o_conn, &li->targets[ i ]->at_map, &li->targets[ i ]->oc_map, op->oq_search.rs_filter, &mfilter, BACKLDAP_MAP ); + if ( rc != 0 ) { + /* + * this target is no longer candidate + */ + msgid[ i ] = -1; + goto new_candidate; + } /* * Maps required attributes */ - mapped_attrs = ldap_back_map_attrs( &li->targets[ i ]->at_map, - op->oq_search.rs_attrs, BACKLDAP_MAP ); + rc = ldap_back_map_attrs( &li->targets[ i ]->at_map, + op->oq_search.rs_attrs, BACKLDAP_MAP, + &mapped_attrs ); + if ( rc != LDAP_SUCCESS ) { + /* + * this target is no longer candidate + */ + msgid[ i ] = -1; + goto new_candidate; + } + +#if 0 if ( mapped_attrs == NULL && op->oq_search.rs_attrs) { for ( count = 0; op->oq_search.rs_attrs[ count ].an_name.bv_val; count++ ); mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *)); @@ -397,6 +368,7 @@ meta_back_search( Operation *op, SlapReply *rs ) } mapped_attrs[ count ] = NULL; } +#endif /* * Starts the search @@ -553,9 +525,9 @@ new_candidate:; } } else { - sres = ldap_result2error( lsc->ld, + rs->sr_err = ldap_result2error( lsc->ld, res, 1 ); - sres = ldap_back_map_result( sres ); + sres = ldap_back_map_result( rs ); if ( err != NULL ) { free( err ); }