From 7f826af5fd925b04e993bbe23479b136d4517ef0 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 14 Jan 2006 17:47:54 +0000 Subject: [PATCH] also restore original o_bd --- servers/slapd/add.c | 12 +++++------- servers/slapd/bind.c | 5 +++-- servers/slapd/compare.c | 11 ++++++----- servers/slapd/delete.c | 9 +++------ servers/slapd/modify.c | 8 +++----- servers/slapd/modrdn.c | 8 +++----- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 9056e412ae..0f3f09a7ed 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -216,7 +216,7 @@ fe_op_add( Operation *op, SlapReply *rs ) int manageDSAit; Modifications **modtail = &op->ora_modlist; int rc = 0; - BackendDB *op_be; + BackendDB *op_be, *bd = op->o_bd; char textbuf[ SLAP_TEXT_BUFLEN ]; 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 ); if ( op->o_bd == NULL ) { + op->o_bd = bd; rs->sr_ref = referral_rewrite( default_referral, NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT ); if ( !rs->sr_ref ) rs->sr_ref = default_referral; if ( rs->sr_ref ) { rs->sr_err = LDAP_REFERRAL; - op->o_bd = frontendDB; send_ldap_result( op, rs ); - op->o_bd = NULL; if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } } else { - op->o_bd = frontendDB; send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); - op->o_bd = NULL; } goto done; } @@ -372,12 +369,13 @@ fe_op_add( Operation *op, SlapReply *rs ) #endif /* SLAPD_MULTIMASTER */ } } else { - Debug( LDAP_DEBUG_ARGS, " do_add: no backend support\n", 0, 0, 0 ); - send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, + Debug( LDAP_DEBUG_ARGS, "do_add: no backend support\n", 0, 0, 0 ); + send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "operation not supported within namingContext" ); } done:; + op->o_bd = bd; return rc; } diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index e9eee9cace..8c261489e8 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -223,6 +223,7 @@ int fe_op_bind( Operation *op, SlapReply *rs ) { struct berval mech = op->orb_tmp_mech; + BackendDB *bd = op->o_bd; /* check for inappropriate controls */ 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 */ /* noSuchObject is not allowed to be returned by bind */ rs->sr_err = LDAP_INVALID_CREDENTIALS; - op->o_bd = frontendDB; + op->o_bd = bd; send_ldap_result( op, rs ); - op->o_bd = NULL; goto cleanup; } @@ -452,6 +452,7 @@ fe_op_bind( Operation *op, SlapReply *rs ) } cleanup:; + op->o_bd = bd; return rs->sr_err; } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 2dd0b169eb..bbe9774e1d 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -135,9 +135,10 @@ cleanup:; int fe_op_compare( Operation *op, SlapReply *rs ) { - Entry *entry = NULL; - int manageDSAit; - AttributeAssertion ava = *op->orc_ava; + Entry *entry = NULL; + int manageDSAit; + AttributeAssertion ava = *op->orc_ava; + BackendDB *bd = op->o_bd; if( strcasecmp( op->o_req_ndn.bv_val, LDAP_ROOT_DSE ) == 0 ) { Debug( LDAP_DEBUG_ARGS, @@ -214,9 +215,8 @@ fe_op_compare( Operation *op, SlapReply *rs ) rs->sr_err = LDAP_REFERRAL; if (!rs->sr_ref) rs->sr_ref = default_referral; - op->o_bd = frontendDB; + op->o_bd = bd; send_ldap_result( op, rs ); - op->o_bd = NULL; if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); rs->sr_err = 0; @@ -369,6 +369,7 @@ fe_op_compare( Operation *op, SlapReply *rs ) } cleanup:; + op->o_bd = bd; return rs->sr_err; } diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index b060d9e352..8c696fa22a 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -101,7 +101,7 @@ fe_op_delete( Operation *op, SlapReply *rs ) { struct berval pdn = BER_BVNULL; int manageDSAit; - BackendDB *op_be; + BackendDB *op_be, *bd = op->o_bd; 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 ); if ( op->o_bd == NULL ) { + op->o_bd = bd; rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); if (!rs->sr_ref) rs->sr_ref = default_referral; if ( rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; - - op->o_bd = frontendDB; send_ldap_result( op, rs ); - op->o_bd = NULL; if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); } else { - op->o_bd = frontendDB; send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); - op->o_bd = NULL; } goto cleanup; } @@ -243,5 +239,6 @@ fe_op_delete( Operation *op, SlapReply *rs ) } cleanup:; + op->o_bd = bd; return rs->sr_err; } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 05891b3dbe..44f67247c7 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -214,7 +214,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) Modifications *tmp; #endif int manageDSAit; - BackendDB *op_be; + BackendDB *op_be, *bd = op->o_bd; char textbuf[ SLAP_TEXT_BUFLEN ]; 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 ); if ( op->o_bd == NULL ) { + op->o_bd = bd; rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); if ( !rs->sr_ref ) { @@ -310,19 +311,15 @@ fe_op_modify( Operation *op, SlapReply *rs ) if ( rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; - op->o_bd = frontendDB; send_ldap_result( op, rs ); - op->o_bd = NULL; if ( rs->sr_ref != default_referral ) { ber_bvarray_free( rs->sr_ref ); } } else { - op->o_bd = frontendDB; send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); - op->o_bd = NULL; } goto cleanup; } @@ -431,6 +428,7 @@ fe_op_modify( Operation *op, SlapReply *rs ) } cleanup:; + op->o_bd = bd; return rs->sr_err; } diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 43eef3eb3f..328f49ec60 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -208,7 +208,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) Backend *newSuperior_be = NULL; int manageDSAit; struct berval pdn = BER_BVNULL; - BackendDB *op_be; + BackendDB *op_be, *bd = op->o_bd; if( op->o_req_ndn.bv_len == 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 ); if ( op->o_bd == NULL ) { + op->o_bd = bd; rs->sr_ref = referral_rewrite( default_referral, NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); if (!rs->sr_ref) rs->sr_ref = default_referral; if ( rs->sr_ref != NULL ) { rs->sr_err = LDAP_REFERRAL; - op->o_bd = frontendDB; send_ldap_result( op, rs ); - op->o_bd = NULL; if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref ); } else { - op->o_bd = frontendDB; send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM, "no global superior knowledge" ); - op->o_bd = NULL; } goto cleanup; } @@ -381,6 +378,7 @@ fe_op_modrdn( Operation *op, SlapReply *rs ) } cleanup:; + op->o_bd = bd; return rs->sr_err; } -- 2.39.5