Skip to content
Snippets Groups Projects
Commit a3f4f0b2 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

map result codes as required (ITS#4419)

parent 88d7428f
Branches
Tags
No related merge requests found
......@@ -45,6 +45,7 @@ meta_back_add( Operation *op, SlapReply *rs )
dncookie dc;
int msgid;
int do_retry = 1;
int maperr = 1;
Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n",
op->o_req_dn.bv_val, 0, 0 );
......@@ -185,20 +186,19 @@ retry:;
}
rs->sr_err = LDAP_OTHER;
maperr = 0;
rc = ldap_result( mc->mc_conns[ candidate ].msc_ld,
msgid, LDAP_MSG_ALL, tvp, &res );
switch ( rc ) {
case -1:
send_ldap_result( op, rs );
goto cleanup;
break;
case 0:
ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld,
msgid, NULL, NULL );
rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR;
send_ldap_result( op, rs );
goto cleanup;
break;
case LDAP_RES_ADD:
rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld,
......@@ -206,6 +206,7 @@ retry:;
if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc;
}
maperr = 1;
break;
default:
......@@ -214,7 +215,12 @@ retry:;
}
}
(void)meta_back_op_result( mc, op, rs, candidate );
if ( maperr ) {
rs->sr_err = meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
}
cleanup:;
for ( --i; i >= 0; --i ) {
......
......@@ -41,6 +41,7 @@ meta_back_delete( Operation *op, SlapReply *rs )
dncookie dc;
int msgid;
int do_retry = 1;
int maperr = 1;
mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR );
if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) {
......@@ -83,21 +84,20 @@ retry:;
}
rs->sr_err = LDAP_OTHER;
maperr = 0;
rc = ldap_result( mc->mc_conns[ candidate ].msc_ld,
msgid, LDAP_MSG_ALL, tvp, &res );
switch ( rc ) {
case -1:
rs->sr_err = LDAP_OTHER;
send_ldap_result( op, rs );
goto cleanup;
break;
case 0:
ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld,
msgid, NULL, NULL );
rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR;
send_ldap_result( op, rs );
goto cleanup;
break;
case LDAP_RES_DELETE:
rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld,
......@@ -105,6 +105,7 @@ retry:;
if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc;
}
maperr = 1;
break;
default:
......@@ -113,7 +114,12 @@ retry:;
}
}
rs->sr_err = meta_back_op_result( mc, op, rs, candidate );
if ( maperr ) {
rs->sr_err = meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
}
cleanup:;
if ( mdn.bv_val != op->o_req_dn.bv_val ) {
......
......@@ -196,6 +196,9 @@ target_free(
if ( mt->mt_uri ) {
free( mt->mt_uri );
}
if ( mt->mt_subtree_exclude ) {
ber_bvarray_free( mt->mt_subtree_exclude );
}
if ( !BER_BVISNULL( &mt->mt_psuffix ) ) {
free( mt->mt_psuffix.bv_val );
}
......
......@@ -37,6 +37,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metaconn_t *mc;
int rc = 0;
int maperr = 1;
LDAPMod **modv = NULL;
LDAPMod *mods = NULL;
Modifications *ml;
......@@ -64,7 +65,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
dc.ctx = "modifyDN";
if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rc = -1;
maperr = 0;
goto cleanup;
}
......@@ -74,13 +75,13 @@ meta_back_modify( Operation *op, SlapReply *rs )
mods = ch_malloc( sizeof( LDAPMod )*i );
if ( mods == NULL ) {
rs->sr_err = LDAP_NO_MEMORY;
rc = -1;
maperr = 0;
goto cleanup;
}
modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) );
if ( modv == NULL ) {
rs->sr_err = LDAP_NO_MEMORY;
rc = -1;
maperr = 0;
goto cleanup;
}
......@@ -197,7 +198,7 @@ retry:;
msgid, LDAP_MSG_ALL, tvp, &res );
switch ( rc ) {
case -1:
rc = -1;
maperr = 0;
break;
case 0:
......@@ -205,7 +206,7 @@ retry:;
msgid, NULL, NULL );
rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR;
rc = -1;
maperr = 0;
break;
case LDAP_RES_MODIFY:
......@@ -214,11 +215,11 @@ retry:;
if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc;
}
rc = 0;
maperr = 1;
break;
default:
rc = -1;
maperr = 0;
ldap_msgfree( res );
break;
}
......@@ -237,16 +238,15 @@ cleanup:;
free( mods );
free( modv );
if ( rc != -1 ) {
if ( maperr ) {
rc = meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
rc = 0;
}
meta_back_release_conn( op, mc );
return rc;
return rs->sr_err;
}
......@@ -42,6 +42,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dncookie dc;
int msgid;
int do_retry = 1;
int maperr = 1;
mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR );
if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) {
......@@ -87,6 +88,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dc.ctx = "newSuperiorDN";
if ( ldap_back_dn_massage( &dc, op->orr_newSup, &mnewSuperior ) ) {
rs->sr_err = LDAP_OTHER;
maperr = 0;
goto cleanup;
}
}
......@@ -98,6 +100,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dc.ctx = "modrDN";
if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rs->sr_err = LDAP_OTHER;
maperr = 0;
goto cleanup;
}
......@@ -126,6 +129,7 @@ retry:;
rs->sr_err = LDAP_OTHER;
rc = ldap_result( mc->mc_conns[ candidate ].msc_ld,
msgid, LDAP_MSG_ALL, tvp, &res );
maperr = 0;
switch ( rc ) {
case -1:
break;
......@@ -143,6 +147,7 @@ retry:;
if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc;
}
maperr = 1;
break;
default:
......@@ -164,8 +169,9 @@ cleanup:;
BER_BVZERO( &mnewSuperior );
}
if ( rs->sr_err == LDAP_SUCCESS ) {
if ( maperr ) {
meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment