Commit 062aabac authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

don't risk leaving around client library error codes; try to return additional information

parent bb61ccd9
......@@ -584,12 +584,13 @@ retry:;
rc = ldap_parse_extended_result( ld, res,
NULL, &data, 0 );
if ( rc == LDAP_SUCCESS ) {
int err;
rc = ldap_parse_result( ld, res, &err,
SlapReply rs;
rc = ldap_parse_result( ld, res, &rs.sr_err,
NULL, NULL, NULL, NULL, 1 );
if ( rc == LDAP_SUCCESS ) {
rc = err;
if ( rc != LDAP_SUCCESS ) {
rs.sr_err = rc;
}
rc = slap_map_api2result( &rs );
res = NULL;
/* FIXME: in case a referral
......@@ -1804,10 +1805,12 @@ retry:;
rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
&match, &text, &refs, &ctrls, 1 );
rs->sr_text = text;
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_SUCCESS ) {
rs->sr_text = text;
} else {
rs->sr_err = rc;
}
rs->sr_err = slap_map_api2result( rs );
/* RFC 4511: referrals can only appear
* if result code is LDAP_REFERRAL */
......@@ -1901,14 +1904,14 @@ retry:;
ber_memvfree( (void **)refs );
}
/* match should not be possible with a successful bind */
if ( match ) {
if ( rs->sr_matched != match ) {
free( (char *)rs->sr_matched );
}
rs->sr_matched = NULL;
ldap_memfree( match );
/* match should not be possible with a successful bind */
if ( match ) {
if ( rs->sr_matched != match ) {
free( (char *)rs->sr_matched );
}
rs->sr_matched = NULL;
ldap_memfree( match );
}
if ( ctrls != NULL ) {
if ( op->o_tag == LDAP_REQ_BIND && rs->sr_err == LDAP_SUCCESS ) {
......
......@@ -462,14 +462,15 @@ retry:
rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
&match.bv_val, &err,
&references, &rs->sr_ctrls, 1 );
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_SUCCESS ) {
if ( err ) {
rs->sr_text = err;
freetext = 1;
}
} else {
rs->sr_err = rc;
}
rs->sr_err = slap_map_api2result( rs );
if ( err ) {
rs->sr_text = err;
freetext = 1;
}
/* RFC 4511: referrals can only appear
* if result code is LDAP_REFERRAL */
......
......@@ -425,6 +425,7 @@ retry:;
if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc;
}
rs->sr_err = slap_map_api2result( rs );
break;
}
}
......@@ -1042,10 +1043,12 @@ retry:;
rc = ldap_parse_result( msc->msc_ld, res, &rs->sr_err,
&matched, &text, &refs, &ctrls, 1 );
res = NULL;
rs->sr_text = text;
if ( rc != LDAP_SUCCESS ) {
if ( rc == LDAP_SUCCESS ) {
rs->sr_text = text;
} else {
rs->sr_err = rc;
}
rs->sr_err = slap_map_api2result( rs );
/* RFC 4511: referrals can only appear
* if result code is LDAP_REFERRAL */
......
......@@ -485,6 +485,7 @@ retry:;
if ( rs->sr_err == LDAP_SUCCESS ) {
rs->sr_err = err;
}
rs->sr_err = slap_map_api2result( rs );
/* FIXME: in case a referral
* is returned, should we try
......
......@@ -393,10 +393,8 @@ meta_search_dobind_result(
NULL, NULL, NULL, NULL, 0 );
if ( rc != LDAP_SUCCESS ) {
candidates[ candidate ].sr_err = rc;
} else {
rc = slap_map_api2result( &candidates[ candidate ] );
}
rc = slap_map_api2result( &candidates[ candidate ] );
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
LDAP_BACK_CONN_BINDING_CLEAR( msc );
......@@ -701,6 +699,7 @@ meta_back_search( Operation *op, SlapReply *rs )
int is_ok = 0;
void *savepriv;
SlapReply *candidates = NULL;
int do_taint = 0;
/*
* controls are set in ldap_back_dobind()
......@@ -1305,11 +1304,12 @@ really_bad:;
msg,
&candidates[ i ].sr_err,
(char **)&candidates[ i ].sr_matched,
NULL /* (char **)&candidates[ i ].sr_text */ ,
(char **)&candidates[ i ].sr_text,
&references,
NULL /* &candidates[ i ].sr_ctrls (unused) */ ,
0 );
if ( rs->sr_err != LDAP_SUCCESS ) {
candidates[ i ].sr_err = rs->sr_err;
sres = slap_map_api2result( &candidates[ i ] );
candidates[ i ].sr_type = REP_RESULT;
ldap_msgfree( res );
......@@ -1451,9 +1451,12 @@ really_bad:;
if ( rs->sr_nentries == op->ors_slimit
|| META_BACK_ONERR_STOP( mi ) )
{
const char *save_text = rs->sr_text;
savepriv = op->o_private;
op->o_private = (void *)i;
rs->sr_text = candidates[ i ].sr_text;
send_ldap_result( op, rs );
rs->sr_text = save_text;
op->o_private = savepriv;
ldap_msgfree( res );
res = NULL;
......@@ -1464,9 +1467,12 @@ really_bad:;
default:
candidates[ i ].sr_err = rs->sr_err;
if ( META_BACK_ONERR_STOP( mi ) ) {
const char *save_text = rs->sr_text;
savepriv = op->o_private;
op->o_private = (void *)i;
rs->sr_text = candidates[ i ].sr_text;
send_ldap_result( op, rs );
rs->sr_text = save_text;
op->o_private = savepriv;
ldap_msgfree( res );
res = NULL;
......@@ -1814,12 +1820,17 @@ finish:;
&& op->o_time > mc->mc_conns[ i ].msc_time )
{
/* don't let anyone else use this expired connection */
LDAP_BACK_CONN_TAINTED_SET( mc );
do_taint++;
}
}
if ( mc ) {
meta_back_release_conn( mi, mc );
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
if ( do_taint ) {
LDAP_BACK_CONN_TAINTED_SET( mc );
}
meta_back_release_conn_lock( mi, mc, 0 );
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
}
return rs->sr_err;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment