]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/chain.c
Fix corrupted CSN issue
[openldap] / servers / slapd / back-ldap / chain.c
index 102374a40cfc2bdd99eee9bdeeb59c23bee17173..4b6a24ab57fa96b211f65204f585348de73681c4 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2007 The OpenLDAP Foundation.
+ * Copyright 2003-2009 The OpenLDAP Foundation.
  * Portions Copyright 2003 Howard Chu.
  * All rights reserved.
  *
@@ -63,6 +63,7 @@ typedef enum {
        LDAP_CH_RES,
        LDAP_CH_ERR
 } ldap_chain_status_t;
+
 static BackendInfo     *lback;
 
 typedef struct ldap_chain_t {
@@ -596,6 +597,8 @@ ldap_chain_search(
        struct berval   odn = op->o_req_dn,
                        ondn = op->o_req_ndn;
        slap_response   *save_response = op->o_callback->sc_response;
+       Entry           *save_entry = rs->sr_entry;
+       slap_mask_t     save_flags = rs->sr_flags;
 
        int             rc = LDAP_OTHER,
                        first_rc = -1;
@@ -726,9 +729,6 @@ cleanup:;
                ldap_memfree( li.li_uri );
                li.li_uri = NULL;
 
-               op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
-               op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-
                if ( temporary ) {
                        lip->li_uri = NULL;
                        lip->li_bvuri = NULL;
@@ -763,7 +763,8 @@ further_cleanup:;
        op->o_req_ndn = ondn;
        op->o_callback->sc_response = save_response;
        rs->sr_type = REP_SEARCHREF;
-       rs->sr_entry = NULL;
+       rs->sr_entry = save_entry;
+       rs->sr_flags = save_flags;
 
        if ( rc != LDAP_SUCCESS ) {
                /* couldn't chase any of the referrals */
@@ -1099,7 +1100,7 @@ static ConfigOCs chainocs[] = {
                "NAME 'olcChainDatabase' "
                "DESC 'Chain remote server configuration' "
                "AUXILIARY )",
-               Cft_Misc, chaincfg, chain_ldadd },
+               Cft_Misc, olcDatabaseDummy, chain_ldadd },
        { NULL, 0, NULL }
 };
 
@@ -1190,6 +1191,8 @@ chain_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
                }
        }
 
+       ca->ca_private = on;
+
 done:;
        if ( rc != LDAP_SUCCESS ) {
                (void)ldap_chain_db_destroy_one( ca->be, NULL );
@@ -1217,9 +1220,9 @@ ldap_chain_cfadd_apply( void *datum, void *arg )
        struct berval                   bv;
 
        /* FIXME: should not hardcode "olcDatabase" here */
-       bv.bv_len = snprintf( lca->ca->msg, sizeof( lca->ca->msg ),
+       bv.bv_len = snprintf( lca->ca->cr_msg, sizeof( lca->ca->cr_msg ),
                "olcDatabase={%d}%s", lca->count, lback->bi_type );
-       bv.bv_val = lca->ca->msg;
+       bv.bv_val = lca->ca->cr_msg;
 
        lca->ca->be->be_private = (void *)li;
        config_build_entry( lca->op, lca->rs, lca->p->e_private, lca->ca,
@@ -1479,11 +1482,11 @@ chain_cf_gen( ConfigArgs *c )
 
        case CH_MAX_DEPTH:
                if ( c->value_int < 0 ) {
-                       snprintf( c->msg, sizeof( c->msg ),
+                       snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                "<%s> invalid max referral depth %d",
                                c->argv[0], c->value_int );
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
-                               c->log, c->msg, 0 );
+                               c->log, c->cr_msg, 0 );
                        rc = 1;
                        break;
                }
@@ -1507,23 +1510,17 @@ chain_cf_gen( ConfigArgs *c )
 static int
 ldap_chain_db_init(
        BackendDB *be,
-       ConfigArgs *ca )
+       ConfigReply *cr )
 {
        slap_overinst   *on = (slap_overinst *)be->bd_info;
        ldap_chain_t    *lc = NULL;
 
        if ( lback == NULL ) {
-               static BackendInfo      lback2;
-
                lback = backend_info( "ldap" );
 
                if ( lback == NULL ) {
                        return 1;
                }
-
-               lback2 = *lback;
-               lback2.bi_type = ldapchain.on_bi.bi_type;
-               lback = &lback2;
        }
 
        lc = ch_malloc( sizeof( ldap_chain_t ) );
@@ -1739,7 +1736,7 @@ ldap_chain_db_func(
 static int
 ldap_chain_db_open(
        BackendDB       *be,
-       ConfigArgs      *ca )
+       ConfigReply     *cr )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
@@ -1772,7 +1769,7 @@ ldap_chain_db_open(
 static int
 ldap_chain_db_close(
        BackendDB       *be,
-       ConfigArgs      *ca )
+       ConfigReply     *cr )
 {
        return ldap_chain_db_func( be, db_close );
 }
@@ -1780,7 +1777,7 @@ ldap_chain_db_close(
 static int
 ldap_chain_db_destroy(
        BackendDB       *be,
-       ConfigArgs      *ca )
+       ConfigReply     *cr )
 {
        slap_overinst   *on = (slap_overinst *) be->bd_info;
        ldap_chain_t    *lc = (ldap_chain_t *)on->on_bi.bi_private;
@@ -2065,7 +2062,8 @@ ldap_chain_parse_ctrl(
 int
 chain_initialize( void )
 {
-       int     rc;
+       int rc;
+       const char *text;
 
        /* Make sure we don't exceed the bits reserved for userland */
        config_check_userland( CH_LAST );