]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/translucent.c
More for prev commit - set entryCSN as well.
[openldap] / servers / slapd / overlays / translucent.c
index ba948e6193c5fc467462671e41be443e6a0f3cc3..8b1e8f369390af540295fe6c056f6e272d438c1d 100644 (file)
@@ -29,6 +29,7 @@
 #include <ac/socket.h>
 
 #include "slap.h"
+#include "lutil.h"
 
 /* config block */
 
@@ -63,18 +64,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 +202,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;
@@ -221,12 +225,12 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
 
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        overlay_stack *ov = on->on_bi.bi_private;
-       translucent_configuration *cf = ov->config;
        void *private = op->o_bd->be_private;
        Entry ne, *e, *re = NULL;
        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);
@@ -291,7 +295,7 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
                                mm = m;
                                m = m->sml_next;
                                mm->sml_next = NULL;            /* hack */
-                               slap_mods_free(mm);
+                               slap_mods_free(mm, 1);
                                if(m) continue;
                        }
                        m->sml_op = LDAP_MOD_ADD;
@@ -383,7 +387,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);
@@ -393,11 +403,9 @@ static int translucent_compare(Operation *op, SlapReply *rs) {
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        overlay_stack *ov = on->on_bi.bi_private;
        void *private = op->o_bd->be_private;
-       translucent_configuration *cf = ov->config;
 
        AttributeAssertion *ava = op->orc_ava;
-       Attribute *a, *an, *ra, *as = NULL;
-       Entry *e, *ee, *re;
+       Entry *e;
        int rc;
 
        Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n",
@@ -440,9 +448,8 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
        slap_overinst *on;
        Entry *e, *re = NULL;
        Attribute *a, *ax, *an, *as = NULL;
-       BerVarray b, bx;
        void *private;
-       int i, rc, size;
+       int rc;
 
        if(!op || !rs || rs->sr_type != REP_SEARCH || !rs->sr_entry)
                return(SLAP_CB_CONTINUE);
@@ -525,7 +532,6 @@ static int translucent_search(Operation *op, SlapReply *rs) {
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        slap_callback cb = { NULL, NULL, NULL, NULL };
        overlay_stack *ov = on->on_bi.bi_private;
-       translucent_configuration *cf = ov->config;
        void *private = op->o_bd->be_private;
        int rc;
 
@@ -615,7 +621,11 @@ static int translucent_config(
                        ov->config->debug = 0xFFFF;
                        rc = 0;
                } else if(argc == 2) {
-                       ov->config->debug = atoi(argv[1]);
+                       if ( lutil_atoi( &ov->config->debug, argv[1]) != 0 ) {
+                               fprintf(stderr, "%s: line %d: unable to parse debug \"%s\"\n",
+                                       fname, lineno, argv[1]);
+                               return 1;
+                       }
                        rc = 0;
                } else {
                        fprintf(stderr, "%s: line %d: too many arguments (%d) to debug\n",
@@ -708,7 +718,6 @@ static int translucent_open(BackendDB *be) {
 static int translucent_close(BackendDB *be) {
        slap_overinst *on = (slap_overinst *) be->bd_info;
        overlay_stack *ov = on->on_bi.bi_private;
-       translucent_configuration *cf = ov->config;
        void *private = be->be_private;
        int rc;
 
@@ -726,7 +735,7 @@ static int translucent_close(BackendDB *be) {
 **
 */
 
-int translucent_init() {
+int translucent_initialize() {
 
        translucent.on_bi.bi_type       = "translucent";
        translucent.on_bi.bi_db_init    = translucent_db_init;
@@ -746,7 +755,7 @@ int translucent_init() {
 
 #if SLAPD_OVER_TRANSLUCENT == SLAPD_MOD_DYNAMIC && defined(PIC)
 int init_module(int argc, char *argv[]) {
-       return translucent_init();
+       return translucent_initialize();
 }
 #endif