From 82b56e63b5cb7e19a580a7cdeaf1caa8608852bc Mon Sep 17 00:00:00 2001 From: Tim Beale Date: Thu, 28 Sep 2017 09:42:14 +1300 Subject: [PATCH] replmd: Handle single-valued conflicts for an existing link Currently the code only handles the case where the received link attribute is a new link (i.e. pdn == NULL). As well as this, we need to handle the case where the conflicting link already exists, i.e. it's a deleted link that has been re-added on another DC. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13055 Signed-off-by: Tim Beale Reviewed-by: Garming Sam Reviewed-by: Andrew Bartlett --- selftest/knownfail.d/link_conflicts | 4 ---- .../dsdb/samdb/ldb_modules/repl_meta_data.c | 18 +++++++++++------- source4/torture/drs/python/link_conflicts.py | 7 ++----- 3 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 selftest/knownfail.d/link_conflicts diff --git a/selftest/knownfail.d/link_conflicts b/selftest/knownfail.d/link_conflicts deleted file mode 100644 index a927997a527..00000000000 --- a/selftest/knownfail.d/link_conflicts +++ /dev/null @@ -1,4 +0,0 @@ -# Currently Samba can't resolve a conflict for a single-valued link attribute -samba4.drs.link_conflicts.python\(vampire_dc\).link_conflicts.DrsReplicaLinkConflictTestCase.test_conflict_existing_single_valued_link\(vampire_dc\) -samba4.drs.link_conflicts.python\(promoted_dc\).link_conflicts.DrsReplicaLinkConflictTestCase.test_conflict_existing_single_valued_link\(promoted_dc\) - diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 4f347938e17..7d7ecc89123 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -7381,20 +7381,24 @@ static int replmd_process_linked_attribute(struct ldb_module *module, return ret; } - if (pdn == NULL && active) { + /* + * check if there's a conflict for single-valued links, i.e. an active + * linked attribute already exists, but it has a different target value + */ + if (active) { + struct parsed_dn *active_pdn = NULL; - /* - * check if there's a conflict for single-valued links, i.e. - * an active linked attribute already exists, but it has a - * different target value - */ ret = replmd_get_active_singleval_link(module, tmp_ctx, pdn_list, old_el->num_values, attr, - &conflict_pdn); + &active_pdn); if (ret != LDB_SUCCESS) { talloc_free(tmp_ctx); return ret; } + + if (active_pdn != pdn) { + conflict_pdn = active_pdn; + } } if (!replmd_link_update_is_newer(pdn, la)) { diff --git a/source4/torture/drs/python/link_conflicts.py b/source4/torture/drs/python/link_conflicts.py index 036472bb9ea..c8b65563ad6 100644 --- a/source4/torture/drs/python/link_conflicts.py +++ b/source4/torture/drs/python/link_conflicts.py @@ -668,11 +668,8 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase): self.ensure_unique_timestamp() self.add_link_attr(self.ldb_dc2, src_ou, "managedBy", target2_ou) - # try to sync the 2 DCs (this currently fails) - try: - self.sync_DCs(sync_order=sync_order) - except Exception, e: - self.fail("Replication could not resolve link conflict: %s" % e) + # try to sync the 2 DCs + self.sync_DCs(sync_order=sync_order) res1 = self.ldb_dc1.search(base="" % src_guid, scope=SCOPE_BASE, attrs=["managedBy"]) -- 2.34.1