]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/translucent.c
fix wrong response tags (ITS4182; consequence of fixing ITS#4173)
[openldap] / servers / slapd / overlays / translucent.c
index 85724d5f507f27f1c1b64a58da4ef55e2df0996a..13e37ff9be714ff3a53e75b3f07bb5181f5640ad 100644 (file)
@@ -63,18 +63,12 @@ void glue_parent(Operation *op) {
        Operation nop = *op;
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        struct berval dn = { 0, NULL };
-       char *odn = op->o_req_ndn.bv_val;
        Attribute *a;
        Entry *e;
-       int idn, ldn;
+       struct berval   pdn;
 
-       /* tis more work to use strchr() for a berval... */
-       for(idn = 0; odn[idn] && odn[idn] != ','; idn++);
-       if(!idn || !odn[idn]) return;   /* because you never know */
-       idn++;
-       ldn = dn.bv_len = op->o_req_ndn.bv_len - idn;
-       dn.bv_val = ch_malloc(ldn + 1);
-       strcpy(dn.bv_val, odn + idn);
+       dnParent( &op->o_req_ndn, &pdn );
+       ber_dupbv( &dn, &pdn );
 
        Debug(LDAP_DEBUG_TRACE, "=> glue_parent: fabricating glue for <%s>\n", dn.bv_val, 0, 0);
 
@@ -207,6 +201,15 @@ static int translucent_delete(Operation *op, SlapReply *rs) {
        return(SLAP_CB_CONTINUE);
 }
 
+static int
+translucent_tag_cb( Operation *op, SlapReply *rs )
+{
+       op->o_tag = (ber_tag_t)op->o_callback->sc_private;
+       rs->sr_tag = slap_req2res( op->o_tag );
+
+       return SLAP_CB_CONTINUE;
+}
+
 /*
 ** translucent_modify()
 **     modify in local backend if exists in both;
@@ -226,6 +229,7 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
        Attribute *a, *ax;
        Modifications *m, *mm;
        int del, rc, erc = 0;
+       slap_callback cb = { 0 }, *save_cb;
 
        Debug(LDAP_DEBUG_TRACE, "==> translucent_modify: %s\n",
                op->o_req_dn.bv_val, 0, 0);
@@ -382,7 +386,13 @@ release:
        op->o_bd->bd_info = (BackendInfo *) on;
        glue_parent(&nop);
 
+       save_cb = op->o_callback;
+       cb.sc_response = translucent_tag_cb;
+       cb.sc_private = (void *)LDAP_REQ_MODIFY;
+       cb.sc_next = nop.o_callback;
+       nop.o_callback = &cb;
        rc = on->on_info->oi_orig->bi_op_add(&nop, &nrs);
+       nop.o_callback = save_cb;
        free_attr_chain(a);
 
        return(rc);