]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/accesslog.c
Improved bignum detection/use
[openldap] / servers / slapd / overlays / accesslog.c
index 26bb076946ce6db9597487161db1b2fe4c649643..bd61096dbbb9f8e01c5e267438b588eca0bc0c43 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2005 The OpenLDAP Foundation.
+ * Copyright 2005-2006 The OpenLDAP Foundation.
  * Portions copyright 2004-2005 Symas Corporation.
  * All rights reserved.
  *
@@ -1112,7 +1112,7 @@ accesslog_unbind( Operation *op, SlapReply *rs )
        slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
        if ( op->o_conn->c_authz_backend == on->on_info->oi_origdb ) {
                log_info *li = on->on_bi.bi_private;
-               Operation op2;
+               Operation op2 = {0};
                void *cids[SLAP_MAX_CIDS];
                SlapReply rs2 = {REP_RESULT};
                Entry *e;
@@ -1132,7 +1132,6 @@ accesslog_unbind( Operation *op, SlapReply *rs )
                op2.o_callback = &nullsc;
                op2.o_controls = cids;
                memset(cids, 0, sizeof( cids ));
-               memset(op2.o_ctrlflag, 0, sizeof( op2.o_ctrlflag ));
 
                op2.o_bd->be_add( &op2, &rs2 );
                entry_free( e );
@@ -1145,7 +1144,7 @@ accesslog_abandon( Operation *op, SlapReply *rs )
 {
        slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
        log_info *li = on->on_bi.bi_private;
-       Operation op2;
+       Operation op2 = {0};
        void *cids[SLAP_MAX_CIDS];
        SlapReply rs2 = {REP_RESULT};
        Entry *e;
@@ -1171,7 +1170,6 @@ accesslog_abandon( Operation *op, SlapReply *rs )
        op2.o_callback = &nullsc;
        op2.o_controls = cids;
        memset(cids, 0, sizeof( cids ));
-       memset(op2.o_ctrlflag, 0, sizeof( op2.o_ctrlflag ));
 
        op2.o_bd->be_add( &op2, &rs2 );
        entry_free( e );
@@ -1235,12 +1233,16 @@ accesslog_db_open(
 
        rc = be_entry_get_rw( op, li->li_db->be_nsuffix, NULL, NULL, 0, &e );
 
-       if ( !e ) {
+       if ( e ) {
+               be_entry_release_rw( op, e, 0 );
+       } else {
                SlapReply rs = {REP_RESULT};
                struct berval rdn, nrdn, attr;
                char *ptr;
                AttributeDescription *ad = NULL;
                const char *text = NULL;
+               Entry *e_ctx;
+
                e = ch_calloc( 1, sizeof( Entry ));
                e->e_name = *li->li_db->be_suffix;
                e->e_nname = *li->li_db->be_nsuffix;
@@ -1266,6 +1268,25 @@ accesslog_db_open(
                nrdn.bv_val = ptr+1;
                attr_merge_one( e, ad, &rdn, &nrdn );
 
+               /* Get contextCSN from main DB */
+               op->o_bd = be;
+               op->o_bd->bd_info = on->on_info->oi_orig;
+               rc = be_entry_get_rw( op, be->be_nsuffix, NULL,
+                       slap_schema.si_ad_contextCSN, 0, &e_ctx );
+
+               if ( e_ctx ) {
+                       Attribute *a;
+
+                       a = attr_find( e_ctx->e_attrs, slap_schema.si_ad_contextCSN );
+                       if ( a ) {
+                               attr_merge( e, slap_schema.si_ad_entryCSN, a->a_vals, NULL );
+                               attr_merge( e, a->a_desc, a->a_vals, NULL );
+                       }
+                       be_entry_release_rw( op, e_ctx, 0 );
+               }
+               op->o_bd->bd_info = (BackendInfo *)on;
+               op->o_bd = li->li_db;
+
                op->ora_e = e;
                op->o_req_dn = e->e_name;
                op->o_req_ndn = e->e_nname;