also restore original o_bd

This commit is contained in:
Pierangelo Masarati 2006-01-14 17:47:54 +00:00
parent bad81cb0d1
commit 7f826af5fd
6 changed files with 23 additions and 30 deletions

View File

@ -216,7 +216,7 @@ fe_op_add( Operation *op, SlapReply *rs )
int manageDSAit; int manageDSAit;
Modifications **modtail = &op->ora_modlist; Modifications **modtail = &op->ora_modlist;
int rc = 0; int rc = 0;
BackendDB *op_be; BackendDB *op_be, *bd = op->o_bd;
char textbuf[ SLAP_TEXT_BUFLEN ]; char textbuf[ SLAP_TEXT_BUFLEN ];
size_t textlen = sizeof( textbuf ); size_t textlen = sizeof( textbuf );
@ -229,23 +229,20 @@ fe_op_add( Operation *op, SlapReply *rs )
*/ */
op->o_bd = select_backend( &op->ora_e->e_nname, manageDSAit, 1 ); op->o_bd = select_backend( &op->ora_e->e_nname, manageDSAit, 1 );
if ( op->o_bd == NULL ) { if ( op->o_bd == NULL ) {
op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral, rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT ); NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) rs->sr_ref = default_referral; if ( !rs->sr_ref ) rs->sr_ref = default_referral;
if ( rs->sr_ref ) { if ( rs->sr_ref ) {
rs->sr_err = LDAP_REFERRAL; rs->sr_err = LDAP_REFERRAL;
op->o_bd = frontendDB;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
if ( rs->sr_ref != default_referral ) { if ( rs->sr_ref != default_referral ) {
ber_bvarray_free( rs->sr_ref ); ber_bvarray_free( rs->sr_ref );
} }
} else { } else {
op->o_bd = frontendDB;
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" ); "no global superior knowledge" );
op->o_bd = NULL;
} }
goto done; goto done;
} }
@ -372,12 +369,13 @@ fe_op_add( Operation *op, SlapReply *rs )
#endif /* SLAPD_MULTIMASTER */ #endif /* SLAPD_MULTIMASTER */
} }
} else { } else {
Debug( LDAP_DEBUG_ARGS, " do_add: no backend support\n", 0, 0, 0 ); Debug( LDAP_DEBUG_ARGS, "do_add: no backend support\n", 0, 0, 0 );
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"operation not supported within namingContext" ); "operation not supported within namingContext" );
} }
done:; done:;
op->o_bd = bd;
return rc; return rc;
} }

View File

@ -223,6 +223,7 @@ int
fe_op_bind( Operation *op, SlapReply *rs ) fe_op_bind( Operation *op, SlapReply *rs )
{ {
struct berval mech = op->orb_tmp_mech; struct berval mech = op->orb_tmp_mech;
BackendDB *bd = op->o_bd;
/* check for inappropriate controls */ /* check for inappropriate controls */
if( get_manageDSAit( op ) == SLAP_CONTROL_CRITICAL ) { if( get_manageDSAit( op ) == SLAP_CONTROL_CRITICAL ) {
@ -387,9 +388,8 @@ fe_op_bind( Operation *op, SlapReply *rs )
/* don't return referral for bind requests */ /* don't return referral for bind requests */
/* noSuchObject is not allowed to be returned by bind */ /* noSuchObject is not allowed to be returned by bind */
rs->sr_err = LDAP_INVALID_CREDENTIALS; rs->sr_err = LDAP_INVALID_CREDENTIALS;
op->o_bd = frontendDB; op->o_bd = bd;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
goto cleanup; goto cleanup;
} }
@ -452,6 +452,7 @@ fe_op_bind( Operation *op, SlapReply *rs )
} }
cleanup:; cleanup:;
op->o_bd = bd;
return rs->sr_err; return rs->sr_err;
} }

View File

@ -135,9 +135,10 @@ cleanup:;
int int
fe_op_compare( Operation *op, SlapReply *rs ) fe_op_compare( Operation *op, SlapReply *rs )
{ {
Entry *entry = NULL; Entry *entry = NULL;
int manageDSAit; int manageDSAit;
AttributeAssertion ava = *op->orc_ava; AttributeAssertion ava = *op->orc_ava;
BackendDB *bd = op->o_bd;
if( strcasecmp( op->o_req_ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) { if( strcasecmp( op->o_req_ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) {
Debug( LDAP_DEBUG_ARGS, Debug( LDAP_DEBUG_ARGS,
@ -214,9 +215,8 @@ fe_op_compare( Operation *op, SlapReply *rs )
rs->sr_err = LDAP_REFERRAL; rs->sr_err = LDAP_REFERRAL;
if (!rs->sr_ref) rs->sr_ref = default_referral; if (!rs->sr_ref) rs->sr_ref = default_referral;
op->o_bd = frontendDB; op->o_bd = bd;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
rs->sr_err = 0; rs->sr_err = 0;
@ -369,6 +369,7 @@ fe_op_compare( Operation *op, SlapReply *rs )
} }
cleanup:; cleanup:;
op->o_bd = bd;
return rs->sr_err; return rs->sr_err;
} }

View File

@ -101,7 +101,7 @@ fe_op_delete( Operation *op, SlapReply *rs )
{ {
struct berval pdn = BER_BVNULL; struct berval pdn = BER_BVNULL;
int manageDSAit; int manageDSAit;
BackendDB *op_be; BackendDB *op_be, *bd = op->o_bd;
manageDSAit = get_manageDSAit( op ); manageDSAit = get_manageDSAit( op );
@ -112,23 +112,19 @@ fe_op_delete( Operation *op, SlapReply *rs )
*/ */
op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 ); op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
if ( op->o_bd == NULL ) { if ( op->o_bd == NULL ) {
op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral, rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral; if (!rs->sr_ref) rs->sr_ref = default_referral;
if ( rs->sr_ref != NULL ) { if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL; rs->sr_err = LDAP_REFERRAL;
op->o_bd = frontendDB;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
} else { } else {
op->o_bd = frontendDB;
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" ); "no global superior knowledge" );
op->o_bd = NULL;
} }
goto cleanup; goto cleanup;
} }
@ -243,5 +239,6 @@ fe_op_delete( Operation *op, SlapReply *rs )
} }
cleanup:; cleanup:;
op->o_bd = bd;
return rs->sr_err; return rs->sr_err;
} }

View File

@ -214,7 +214,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
Modifications *tmp; Modifications *tmp;
#endif #endif
int manageDSAit; int manageDSAit;
BackendDB *op_be; BackendDB *op_be, *bd = op->o_bd;
char textbuf[ SLAP_TEXT_BUFLEN ]; char textbuf[ SLAP_TEXT_BUFLEN ];
size_t textlen = sizeof( textbuf ); size_t textlen = sizeof( textbuf );
@ -302,6 +302,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
*/ */
op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 ); op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
if ( op->o_bd == NULL ) { if ( op->o_bd == NULL ) {
op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral, rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if ( !rs->sr_ref ) { if ( !rs->sr_ref ) {
@ -310,19 +311,15 @@ fe_op_modify( Operation *op, SlapReply *rs )
if ( rs->sr_ref != NULL ) { if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL; rs->sr_err = LDAP_REFERRAL;
op->o_bd = frontendDB;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
if ( rs->sr_ref != default_referral ) { if ( rs->sr_ref != default_referral ) {
ber_bvarray_free( rs->sr_ref ); ber_bvarray_free( rs->sr_ref );
} }
} else { } else {
op->o_bd = frontendDB;
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" ); "no global superior knowledge" );
op->o_bd = NULL;
} }
goto cleanup; goto cleanup;
} }
@ -431,6 +428,7 @@ fe_op_modify( Operation *op, SlapReply *rs )
} }
cleanup:; cleanup:;
op->o_bd = bd;
return rs->sr_err; return rs->sr_err;
} }

View File

@ -208,7 +208,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
Backend *newSuperior_be = NULL; Backend *newSuperior_be = NULL;
int manageDSAit; int manageDSAit;
struct berval pdn = BER_BVNULL; struct berval pdn = BER_BVNULL;
BackendDB *op_be; BackendDB *op_be, *bd = op->o_bd;
if( op->o_req_ndn.bv_len == 0 ) { if( op->o_req_ndn.bv_len == 0 ) {
Debug( LDAP_DEBUG_ANY, "do_modrdn: root dse!\n", 0, 0, 0 ); Debug( LDAP_DEBUG_ANY, "do_modrdn: root dse!\n", 0, 0, 0 );
@ -238,22 +238,19 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
*/ */
op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 ); op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
if ( op->o_bd == NULL ) { if ( op->o_bd == NULL ) {
op->o_bd = bd;
rs->sr_ref = referral_rewrite( default_referral, rs->sr_ref = referral_rewrite( default_referral,
NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
if (!rs->sr_ref) rs->sr_ref = default_referral; if (!rs->sr_ref) rs->sr_ref = default_referral;
if ( rs->sr_ref != NULL ) { if ( rs->sr_ref != NULL ) {
rs->sr_err = LDAP_REFERRAL; rs->sr_err = LDAP_REFERRAL;
op->o_bd = frontendDB;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
op->o_bd = NULL;
if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
} else { } else {
op->o_bd = frontendDB;
send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
"no global superior knowledge" ); "no global superior knowledge" );
op->o_bd = NULL;
} }
goto cleanup; goto cleanup;
} }
@ -381,6 +378,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
} }
cleanup:; cleanup:;
op->o_bd = bd;
return rs->sr_err; return rs->sr_err;
} }