From 4c5de987cd2acd7ae1cd845018760180058ef847 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 11 Jun 2003 06:32:24 +0000 Subject: [PATCH] Fix config, chaining --- servers/slapd/back-ldap/chain.c | 56 ++++++++++++++++++++++++--------- servers/slapd/backover.c | 8 ++--- servers/slapd/config.c | 4 +-- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index 214a250649..596c003d2d 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -40,32 +40,57 @@ ldap_chain_response( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; void *private = op->o_bd->be_private; + slap_callback *sc = op->o_callback; LDAPControl **prev = op->o_ctrls; - LDAPControl **ctrls, authz; + LDAPControl **ctrls = NULL, authz; int i, nctrls, rc; int cache = op->o_do_not_cache; + char *authzid = NULL; + BerVarray ref; if ( rs->sr_err != LDAP_REFERRAL ) return SLAP_CB_CONTINUE; + /* currently we assume only one referral destination. + * we'll have to parse this in the future. + */ + ref = rs->sr_ref; + rs->sr_ref = NULL; + op->o_bd->be_private = on->on_bi.bi_private; - for (i=0; prev && prev[i]; i++); - nctrls = i; - - ctrls = op->o_tmpalloc((i+1)*sizeof(LDAPControl *), op->o_tmpmemctx); - for (i=0; i o_dn; + op->o_callback = NULL; + + if ( op->o_tag != LDAP_REQ_BIND ) { + for (i=0; prev && prev[i]; i++); + nctrls = i; + + /* Add an extra NULL slot */ + if (!prev) i++; + + ctrls = op->o_tmpalloc((i+1)*sizeof(LDAPControl *), + op->o_tmpmemctx); + for (i=0; i o_dn; + if ( op->o_dn.bv_len ) { + authzid = op->o_tmpalloc( op->o_dn.bv_len+4, + op->o_tmpmemctx ); + strcpy(authzid, "dn: "); + strcpy(authzid+4, op->o_dn.bv_val); + authz.ldctl_value.bv_len = op->o_dn.bv_len + 4; + authz.ldctl_value.bv_val = authzid; + } + op->o_ctrls = ctrls; + } /* Chaining is performed by a privileged user on behalf * of a normal user */ op->o_do_not_cache = 1; - op->o_ctrls = ctrls; switch( op->o_tag ) { case LDAP_REQ_BIND: @@ -99,7 +124,10 @@ ldap_chain_response( Operation *op, SlapReply *rs ) op->o_do_not_cache = cache; op->o_ctrls = prev; op->o_bd->be_private = private; - op->o_tmpfree( ctrls, op->o_tmpmemctx ); + op->o_callback = sc; + if ( ctrls ) op->o_tmpfree( ctrls, op->o_tmpmemctx ); + if ( authzid ) op->o_tmpfree( authzid, op->o_tmpmemctx ); + rs->sr_ref = ref; return rc; } diff --git a/servers/slapd/backover.c b/servers/slapd/backover.c index 6b29007eb1..87025c1305 100644 --- a/servers/slapd/backover.c +++ b/servers/slapd/backover.c @@ -37,7 +37,7 @@ over_db_func( BI_db_open **func; int rc = 0; - func = &oi->oi_bi.bi_db_open; + func = &oi->oi_bd.bd_info->bi_db_open; if ( func[which] ) { rc = func[which]( &oi->oi_bd ); if ( rc ) return rc; @@ -69,8 +69,8 @@ over_db_config( BackendDB bd; int rc = 0; - if ( oi->oi_bi.bi_db_config ) { - rc = oi->oi_bi.bi_db_config( &oi->oi_bd, fname, lineno, + if ( oi->oi_bd.bd_info->bi_db_config ) { + rc = oi->oi_bd.bd_info->bi_db_config( &oi->oi_bd, fname, lineno, argc, argv ); if ( rc ) return rc; } @@ -179,7 +179,7 @@ over_op_func( } } - func = &oi->oi_bi.bi_op_bind; + func = &oi->oi_bd.bd_info->bi_op_bind; if ( func[which] ) { rc = func[which]( op, rs ); } diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 9cf80a8575..5b5a366f8a 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -935,8 +935,8 @@ read_config( const char *fname, int depth ) #endif return 1; - } else { - return overlay_config( be, cargv[1] ); + } else if ( overlay_config( be, cargv[1] )) { + return 1; } /* set database suffix */ -- 2.39.5