]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/cache-merge.c
Fix prev commit, return generated passwd
[openldap] / servers / slapd / back-meta / cache-merge.c
index 83e0c8ba2cdf4459aea1962e21bd6aa479b8d2af..e6cce64bc883a44d7be79b48aa9eff9f76f585b7 100644 (file)
@@ -1,19 +1,21 @@
-/* Copyright (c) 2003 by International Business Machines, Inc.
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
+ * Copyright 1999-2003 The OpenLDAP Foundation.
+ * Portions Copyright 2003 IBM Corporation.
+ * All rights reserved.
  *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by the Apurva Kumar for inclusion
+ * in OpenLDAP Software.
  */
 
 #include "portable.h"
@@ -34,8 +36,6 @@
 #include "../../../libraries/libldap/ldap-int.h"
 #include <sys/time.h>
 
-#ifdef LDAP_CACHING
-
 static struct berval bv_queryid_any = BER_BVC( "(queryid=*)" );
 
 static Attribute* 
@@ -112,6 +112,8 @@ merge_entry(
        BerVarray               value_array; 
        Attribute               *uuid_attr, *attr;
        Entry                   *e;
+       char                    textbuf[SLAP_TEXT_BUFLEN];
+       size_t                  textlen = sizeof(textbuf);
 
        SlapReply sreply = {REP_RESULT};
 
@@ -122,7 +124,14 @@ merge_entry(
        sreply.sr_nentries = 0; 
 
        e = ( Entry * ) ch_calloc( 1, sizeof( Entry )); 
-       dnPrettyNormal(0, &rs->sr_entry->e_name, &e->e_name, &e->e_nname, op->o_tmpmemctx);
+
+       dnPrettyNormal(0, &rs->sr_entry->e_name, &op_tmp.o_req_dn, &op_tmp.o_req_ndn, op->o_tmpmemctx);
+       ber_dupbv( &e->e_name, &op_tmp.o_req_dn );
+       ber_dupbv( &e->e_nname, &op_tmp.o_req_ndn );
+       sl_free( op_tmp.o_req_ndn.bv_val, op->o_tmpmemctx );
+       sl_free( op_tmp.o_req_dn.bv_val, op->o_tmpmemctx );
+       op_tmp.o_req_dn = e->e_name;
+       op_tmp.o_req_ndn = e->e_nname;
 
        e->e_private = NULL;
        e->e_attrs = NULL; 
@@ -165,13 +174,11 @@ merge_entry(
        op_tmp.o_do_not_cache = 1;
 
        op_tmp.ora_e = e;
-       op_tmp.o_req_dn = e->e_name;
-       op_tmp.o_req_ndn = e->e_nname;
        rc = op->o_bd->be_add( &op_tmp, &sreply );
 
        if ( rc != LDAP_SUCCESS ) {
                if ( rc == LDAP_ALREADY_EXISTS ) {
-                       slap_entry2mods( e, &modlist, &text );
+                       slap_entry2mods( e, &modlist, &text, textbuf, textlen );
                        op_tmp.o_tag = LDAP_REQ_MODIFY;
                        op_tmp.orm_modlist = modlist;
                        op_tmp.o_req_dn = e->e_name;
@@ -180,8 +187,7 @@ merge_entry(
                        result->rc = info.added;
                } else if ( rc == LDAP_REFERRAL ||
                                        rc == LDAP_NO_SUCH_OBJECT ) {
-                       slap_entry2mods( e, &modlist, &text );
-                       syncrepl_add_glue( NULL, NULL, &op_tmp, e, modlist, 0, NULL, NULL );
+                       syncrepl_add_glue( &op_tmp, e );
                        result->rc = info.added;
                } else {
                        result->rc = 0;
@@ -258,7 +264,7 @@ normalize_values( Attribute* attr )
        {
                for ( i = 0; i < nvals; i++ ) {
                        rc = attr->a_desc->ad_type->sat_equality->smr_normalize(
-                               0,
+                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
                                attr->a_desc->ad_type->sat_syntax,
                                attr->a_desc->ad_type->sat_equality,
                                &attr->a_vals[i], &attr->a_nvals[i], NULL );
@@ -286,5 +292,3 @@ normalize_values( Attribute* attr )
 
        return LDAP_SUCCESS;
 }
-
-#endif /* LDAP_CACHING */