struct berval *syncuuid_bv;
syncuuid_bv = ber_dupbv( NULL, &syncUUIDs[i] );
slap_sl_free( syncUUIDs[i].bv_val,op->o_tmpmemctx );
- avl_insert( &si->si_presentlist,
+ if ( avl_insert( &si->si_presentlist,
(caddr_t) syncuuid_bv,
- syncuuid_cmp, avl_dup_error );
+ syncuuid_cmp, avl_dup_error ))
+ ber_bvfree( syncuuid_bv );
}
slap_sl_free( syncUUIDs, op->o_tmpmemctx );
}
op->orr_modlist = NULL;
if ( slap_modrdn2mods( op, &rs ))
goto done;
- /* FIXME: append entryCSN, modifiersName, modifyTimestamp to
- * modlist here. Should accesslog give these to us in a reqMod?
- */
+ /* Append modlist for operational attrs */
+ {
+ Modifications *m;
+
+ for ( m = op->orr_modlist; m->sml_next; m = m->sml_next ) ;
+ m->sml_next = modlist;
+ modlist = NULL;
+ }
rc = op->o_bd->be_modrdn( op, &rs );
slap_mods_free( op->orr_modlist, 1 );
Debug( rc ? LDAP_DEBUG_ANY : LDAP_DEBUG_SYNC,
return rc;
}
- dnPrettyNormal( NULL, &bdn, &dn, &ndn, op->o_tmpmemctx );
- ber_dupbv( &op->o_req_dn, &dn );
- ber_dupbv( &op->o_req_ndn, &ndn );
- slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
- slap_sl_free( dn.bv_val, op->o_tmpmemctx );
-
if ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_DELETE ) {
/* NOTE: this could be done even before decoding the DN,
* although encoding errors wouldn't be detected */
goto done;
}
+ dnPrettyNormal( NULL, &bdn, &dn, &ndn, op->o_tmpmemctx );
+ ber_dupbv( &op->o_req_dn, &dn );
+ ber_dupbv( &op->o_req_ndn, &ndn );
+ slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
+ slap_sl_free( dn.bv_val, op->o_tmpmemctx );
+
e = entry_alloc();
e->e_name = op->o_req_dn;
e->e_nname = op->o_req_ndn;
modtail = &mod->sml_next;
}
}
-
+
rc = slap_mods2entry( *modlist, &e, 1, 1, &text, txtbuf, textlen);
if( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_entry: rid %03ld mods2entry (%s)\n",
if (( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) {
if ( !si->si_refreshPresent ) {
syncuuid_bv = ber_dupbv( NULL, syncUUID );
- avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
- syncuuid_cmp, avl_dup_error );
+ if ( avl_insert( &si->si_presentlist, (caddr_t) syncuuid_bv,
+ syncuuid_cmp, avl_dup_error )) {
+ ber_bvfree( syncuuid_bv );
+ syncuuid_bv = NULL;
+ }
}
}
}
}
+ (void)slap_uuidstr_from_normalized( &syncUUID_strrep, syncUUID, op->o_tmpmemctx );
+ if ( syncstate != LDAP_SYNC_DELETE ) {
+ Attribute *a = attr_find( entry->e_attrs, slap_schema.si_ad_entryUUID );
+
+ if ( a == NULL ) {
+ /* add if missing */
+ attr_merge_one( entry, slap_schema.si_ad_entryUUID,
+ &syncUUID_strrep, syncUUID );
+
+ } else if ( !bvmatch( &a->a_nvals[0], syncUUID ) ) {
+ /* replace only if necessary */
+ if ( a->a_nvals != a->a_vals ) {
+ ber_memfree( a->a_nvals[0].bv_val );
+ ber_dupbv( &a->a_nvals[0], syncUUID );
+ }
+ ber_memfree( a->a_vals[0].bv_val );
+ ber_dupbv( &a->a_vals[0], &syncUUID_strrep );
+ }
+ }
+
f.f_choice = LDAP_FILTER_EQUALITY;
f.f_ava = &ava;
ava.aa_desc = slap_schema.si_ad_entryUUID;
ava.aa_value = *syncUUID;
- (void)slap_uuidstr_from_normalized( &syncUUID_strrep, syncUUID, op->o_tmpmemctx );
if ( syncuuid_bv ) {
Debug( LDAP_DEBUG_SYNC, "syncrepl_entry: rid %03ld inserted UUID %s\n",
si->si_rid, syncUUID_strrep.bv_val, 0 );
si->si_rid, dni.dn.bv_val ? dni.dn.bv_val : "(null)", 0 );
}
- if ( syncstate != LDAP_SYNC_DELETE ) {
- Attribute *a = attr_find( entry->e_attrs, slap_schema.si_ad_entryUUID );
-
- if ( a == NULL ) {
- /* add if missing */
- attr_merge_one( entry, slap_schema.si_ad_entryUUID,
- &syncUUID_strrep, syncUUID );
-
- } else if ( !bvmatch( &a->a_nvals[0], syncUUID ) ) {
- /* replace only if necessary */
- if ( a->a_nvals != a->a_vals ) {
- ber_memfree( a->a_nvals[0].bv_val );
- ber_dupbv( &a->a_nvals[0], syncUUID );
- }
- ber_memfree( a->a_vals[0].bv_val );
- ber_dupbv( &a->a_vals[0], &syncUUID_strrep );
- }
- /* Don't save the contextCSN on the inooming context entry,
- * we'll write it when syncrepl_updateCookie eventually
- * gets called. (ITS#4622)
- */
- if ( syncstate == LDAP_SYNC_ADD && dn_match( &entry->e_nname,
- &be->be_nsuffix[0] )) {
- Attribute **ap;
- for ( ap = &entry->e_attrs; *ap; ap=&(*ap)->a_next ) {
- a = *ap;
- if ( a->a_desc == slap_schema.si_ad_contextCSN ) {
- *ap = a->a_next;
- attr_free( a );
- break;
- }
+ /* Don't save the contextCSN on the inooming context entry,
+ * we'll write it when syncrepl_updateCookie eventually
+ * gets called. (ITS#4622)
+ */
+ if ( syncstate == LDAP_SYNC_ADD && dn_match( &entry->e_nname,
+ &be->be_nsuffix[0] )) {
+ Attribute *a, **ap;
+ for ( ap = &entry->e_attrs; *ap; ap=&(*ap)->a_next ) {
+ a = *ap;
+ if ( a->a_desc == slap_schema.si_ad_contextCSN ) {
+ *ap = a->a_next;
+ attr_free( a );
+ break;
}
}
}
Modifications mod = { { 0 } };
struct berval vals[ 2 ];
- int rc;
+ int rc, flags;
slap_callback cb = { NULL };
SlapReply rs_modify = {REP_RESULT};
/* update contextCSN */
op->o_msgid = SLAP_SYNC_UPDATE_MSGID;
op->orm_modlist = &mod;
+ flags = SLAP_DBFLAGS( op->o_bd );
+ SLAP_DBFLAGS( op->o_bd ) |= SLAP_DBFLAG_NOLASTMOD;
rc = be->be_modify( op, &rs_modify );
+ SLAP_DBFLAGS( op->o_bd ) = flags;
op->o_msgid = 0;
if ( rs_modify.sr_err == LDAP_SUCCESS ) {
*modtail = mod;
modtail = &mod->sml_next;
} else {
- *mcur = &mod->sml_next;
+ if ( mod )
+ *mcur = &mod->sml_next;
}
*mret = modtail;
}
for ( old = rs->sr_entry->e_attrs, new = dni->new_entry->e_attrs;
old && new; )
{
+#if 1
+ if ( new->a_flags & SLAP_ATTR_IXADD ) {
+ new = new->a_next;
+ continue;
+ }
+#endif
if ( old->a_desc != new->a_desc ) {
- /* Delete old attr, force into new order */
Modifications *mod;
- mod = ch_malloc( sizeof( Modifications ) );
- mod->sml_op = LDAP_MOD_DELETE;
- mod->sml_flags = 0;
- mod->sml_desc = old->a_desc;
- mod->sml_type = mod->sml_desc->ad_cname;
- mod->sml_values = NULL;
- mod->sml_nvalues = NULL;
- *modtail = mod;
- modtail = &mod->sml_next;
-
+ Attribute *tmp;
+
+ /* If it's just been re-added later,
+ * remember that we've seen it.
+ */
+ tmp = attr_find( new, old->a_desc );
+ if ( tmp ) {
+ tmp->a_flags |= SLAP_ATTR_IXADD;
+ } else {
+ /* If it's a new attribute, pull it in.
+ */
+ tmp = attr_find( old, new->a_desc );
+ if ( !tmp ) {
+ attr_cmp( op, NULL, new, &modtail, &ml );
+ new = new->a_next;
+ continue;
+ }
+ /* Delete old attr */
+ mod = ch_malloc( sizeof( Modifications ) );
+ mod->sml_op = LDAP_MOD_DELETE;
+ mod->sml_flags = 0;
+ mod->sml_desc = old->a_desc;
+ mod->sml_type = mod->sml_desc->ad_cname;
+ mod->sml_values = NULL;
+ mod->sml_nvalues = NULL;
+ *modtail = mod;
+ modtail = &mod->sml_next;
+ }
old = old->a_next;
continue;
}
* in case they really want to do this, they can vary
* the case of the URL to allow it.
*/
- if ( l ) {
+ if ( l && !SLAP_DBHIDDEN( c->be )) {
int i;
for ( i=0; l[i]; i++ ) {
if ( bvmatch( &l[i]->sl_url, &si->si_bindconf.sb_uri )) {