replmd: Handle single-valued conflicts for an existing link
authorTim Beale <timbeale@catalyst.net.nz>
Wed, 27 Sep 2017 20:42:14 +0000 (09:42 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 20 Oct 2017 02:05:21 +0000 (04:05 +0200)
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 <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/link_conflicts [deleted file]
source4/dsdb/samdb/ldb_modules/repl_meta_data.c
source4/torture/drs/python/link_conflicts.py

diff --git a/selftest/knownfail.d/link_conflicts b/selftest/knownfail.d/link_conflicts
deleted file mode 100644 (file)
index a927997..0000000
+++ /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\)
-
index 4f347938e17fdc9f7b8c733b74019aeae4f63804..7d7ecc891233d80f214f65aa5f0c343eebfcc25f 100644 (file)
@@ -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)) {
index 036472bb9ea02cc43ed8ba2b4dfb09ca0604f568..c8b65563ad6900d6d93018b5e5c4352d1ae211c0 100644 (file)
@@ -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="<GUID=%s>" % src_guid,
                                   scope=SCOPE_BASE, attrs=["managedBy"])