From: Howard Chu Date: Fri, 31 Jul 2015 23:35:44 +0000 (+0100) Subject: Fix interaction with rwm X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=706bbd42d991aa0114c29a7ccfdc64a609e48665;p=openldap Fix interaction with rwm --- diff --git a/contrib/slapd-modules/adremap/adremap.c b/contrib/slapd-modules/adremap/adremap.c index 8e2beee7c0..de337e7fbd 100644 --- a/contrib/slapd-modules/adremap/adremap.c +++ b/contrib/slapd-modules/adremap/adremap.c @@ -250,8 +250,8 @@ adremap_cf_dnv(ConfigArgs *c) typedef struct adremap_ctx { slap_overinst *on; AttributeName an; + AttributeDescription *ad; int an_swap; - int an_idx; } adremap_ctx; static int @@ -271,9 +271,28 @@ adremap_search_resp( if (rs->sr_type != REP_SEARCH) return SLAP_CB_CONTINUE; + /* we munged the attr list, restore it to original */ if (ctx->an_swap) { + int i; ctx->an_swap = 0; - rs->sr_attrs[ctx->an_idx] = ctx->an; + for (i=0; rs->sr_attrs[i].an_name.bv_val; i++) { + if (rs->sr_attrs[i].an_desc == ctx->ad) { + rs->sr_attrs[i] = ctx->an; + break; + } + } + /* Usually rs->sr_attrs is just op->ors_attrs, but + * overlays like rwm may make a new copy. Fix both + * if needed. + */ + if (op->ors_attrs != rs->sr_attrs) { + for (i=0; op->ors_attrs[i].an_name.bv_val; i++) { + if (op->ors_attrs[i].an_desc == ctx->ad) { + op->ors_attrs[i] = ctx->an; + break; + } + } + } } e = rs->sr_entry; for (ac = ai->ai_case; ac; ac = ac->ac_next) { @@ -482,7 +501,7 @@ adremap_search( for (i=0; op->ors_attrs[i].an_name.bv_val; i++) { if (op->ors_attrs[i].an_desc == ad->ad_newattr) { ctx->an_swap = 1; - ctx->an_idx = i; + ctx->ad = ad->ad_dnattr; ctx->an = op->ors_attrs[i]; op->ors_attrs[i].an_desc = ad->ad_dnattr; op->ors_attrs[i].an_name = ad->ad_dnattr->ad_cname;