From 899398b937cee0de686a2391a817faa2bed402d7 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 10 Feb 2009 13:58:09 +0000 Subject: [PATCH] partially addresses an issue with ITS#5931: intermediate responses seem to be handled, as well as entries with controls; syncrepl does not work yet --- servers/slapd/back-meta/search.c | 88 +++++++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 13 deletions(-) diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 95b8f85379..94945f11e1 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -1212,6 +1212,46 @@ really_bad:; rs->sr_ctrls = NULL; } + } else if ( rc == LDAP_RES_INTERMEDIATE ) { + if ( candidates[ i ].sr_type == REP_INTERMEDIATE ) { + /* don't retry any more... */ + candidates[ i ].sr_type = REP_RESULT; + } + + candidates[ i ].sr_msgid = META_MSGID_IGNORE; + + /* FIXME: response controls + * are passed without checks */ + rs->sr_err = ldap_parse_intermediate( msc->msc_ld, + msg, + &rs->sr_rspoid, + &rs->sr_rspdata, + &rs->sr_ctrls, + 0 ); + if ( rs->sr_err != LDAP_SUCCESS ) { + candidates[ i ].sr_type = REP_RESULT; + ldap_msgfree( res ); + res = NULL; + goto really_bad; + } + + slap_send_ldap_intermediate( op, rs ); + + if ( rs->sr_rspoid != NULL ) { + ber_memfree( rs->sr_rspoid ); + rs->sr_rspoid = NULL; + } + + if ( rs->sr_rspdata != NULL ) { + ber_bvfree( rs->sr_rspdata ); + rs->sr_rspdata = NULL; + } + + if ( rs->sr_ctrls != NULL ) { + ldap_controls_free( rs->sr_ctrls ); + rs->sr_ctrls = NULL; + } + } else if ( rc == LDAP_RES_SEARCH_RESULT ) { char buf[ SLAP_TEXT_BUFLEN ]; char **references = NULL; @@ -1412,16 +1452,6 @@ really_bad:; assert( ncandidates > 0 ); --ncandidates; - } else if ( rc == LDAP_RES_INTERMEDIATE ) { - /* TODO: ITS#5931 */ - - /* ignore right now */ - Debug( LDAP_DEBUG_ANY, - "%s meta_back_search[%ld]: " - "intermediate response message not supported yet.\n", - op->o_log_prefix, - i, 0 ); - } else if ( rc == LDAP_RES_BIND ) { meta_search_candidate_t retcode; @@ -1780,9 +1810,19 @@ meta_send_entry( dn = BER_BVNULL; const char *text; dncookie dc; + ber_len_t len; + ber_tag_t tag; int rc; - if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) { + if ( ber_scanf( &ber, "l{", &len ) == LBER_ERROR ) { + return LDAP_DECODING_ERROR; + } + + if ( ber_set_option( &ber, LBER_OPT_REMAINING_BYTES, &len ) != LBER_OPT_SUCCESS ) { + return LDAP_OTHER; + } + + if ( ber_scanf( &ber, "m{", &bdn ) == LBER_ERROR ) { return LDAP_DECODING_ERROR; } @@ -1814,7 +1854,12 @@ meta_send_entry( BER_BVZERO( &dn ); if ( rc != LDAP_SUCCESS ) { - return LDAP_INVALID_DN_SYNTAX; + Debug( LDAP_DEBUG_ANY, + "%s meta_send_entry(\"%s\"): " + "invalid DN syntax\n", + op->o_log_prefix, ent.e_name.bv_val, 0 ); + rc = LDAP_INVALID_DN_SYNTAX; + goto done; } /* @@ -1833,6 +1878,20 @@ meta_send_entry( slap_syntax_validate_func *validate; slap_syntax_transform_func *pretty; + if ( ber_pvt_ber_remaining( &ber ) < 0 ) { + Debug( LDAP_DEBUG_ANY, + "%s meta_send_entry(\"%s\"): " + "unable to parse attr \"%s\".\n", + op->o_log_prefix, ent.e_name.bv_val, a.bv_val ); + + rc = LDAP_OTHER; + goto done; + } + + if ( ber_pvt_ber_remaining( &ber ) == 0 ) { + break; + } + ldap_back_map( &mi->mi_targets[ target ]->mt_rwmap.rwm_at, &a, &mapped, BACKLDAP_REMAP ); if ( BER_BVISNULL( &mapped ) || mapped.bv_val[0] == '\0' ) { @@ -1845,7 +1904,8 @@ meta_send_entry( } attr = attr_alloc( NULL ); if ( attr == NULL ) { - return LDAP_OTHER; + rc = LDAP_OTHER; + goto done; } if ( slap_bv2ad( &mapped, &attr->a_desc, &text ) != LDAP_SUCCESS) { @@ -2097,6 +2157,8 @@ next_attr:; rc = LDAP_OTHER; break; } + +done:; rs->sr_entry = NULL; rs->sr_attrs = NULL; if ( rs->sr_ctrls != NULL ) { -- 2.39.5