repl_meta_data: Split replmd_make_deleted_child_dn() into a helper function
authorAndrew Bartlett <abartlet@samba.org>
Mon, 16 Oct 2017 22:27:49 +0000 (11:27 +1300)
committerGarming Sam <garming@samba.org>
Sun, 29 Oct 2017 23:16:39 +0000 (00:16 +0100)
This will allow it to be used in common with replmd_conflict_dn()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/repl_meta_data.c

index 8664267a512ea1a54b30ab6a59257cb95596ba7a..8bb47b330ab7c7559e43e79a05e5d35f1bd714cf 100644 (file)
@@ -4543,16 +4543,16 @@ static struct ldb_dn *replmd_conflict_dn(TALLOC_CTX *mem_ctx, struct ldb_dn *dn,
 /*
   form a deleted DN
  */
 /*
   form a deleted DN
  */
-static int replmd_make_deleted_child_dn(TALLOC_CTX *tmp_ctx,
-                                       struct ldb_context *ldb,
-                                       struct ldb_dn *dn,
-                                       const char *rdn_name,
-                                       const struct ldb_val *rdn_value,
-                                       struct GUID guid)
+static int replmd_make_prefix_child_dn(TALLOC_CTX *tmp_ctx,
+                                      struct ldb_context *ldb,
+                                      struct ldb_dn *dn,
+                                      const char *four_char_prefix,
+                                      const char *rdn_name,
+                                      const struct ldb_val *rdn_value,
+                                      struct GUID guid)
 {
        struct ldb_val deleted_child_rdn_val;
        struct GUID_txt_buf guid_str;
 {
        struct ldb_val deleted_child_rdn_val;
        struct GUID_txt_buf guid_str;
-       const char *four_char_prefix = "DEL:";
        bool retb;
 
        GUID_buf_string(&guid, &guid_str);
        bool retb;
 
        GUID_buf_string(&guid, &guid_str);
@@ -4617,6 +4617,61 @@ static int replmd_make_deleted_child_dn(TALLOC_CTX *tmp_ctx,
 }
 
 
 }
 
 
+/*
+  form a conflict DN
+ */
+static struct ldb_dn *replmd_conflict_dn(TALLOC_CTX *mem_ctx,
+                                        struct ldb_context *ldb,
+                                        struct ldb_dn *dn,
+                                        struct GUID *guid)
+{
+       const struct ldb_val *rdn_val;
+       const char *rdn_name;
+       struct ldb_dn *new_dn;
+       int ret;
+
+       rdn_val = ldb_dn_get_rdn_val(dn);
+       rdn_name = ldb_dn_get_rdn_name(dn);
+       if (!rdn_val || !rdn_name) {
+               return NULL;
+       }
+
+       new_dn = ldb_dn_get_parent(mem_ctx, dn);
+       if (!new_dn) {
+               return NULL;
+       }
+
+       ret = replmd_make_prefix_child_dn(mem_ctx,
+                                         ldb, new_dn,
+                                         "CNF:",
+                                         rdn_name,
+                                         rdn_val,
+                                         *guid);
+       if (ret != LDB_SUCCESS) {
+               return NULL;
+       }
+       return new_dn;
+}
+
+/*
+  form a deleted DN
+ */
+static int replmd_make_deleted_child_dn(TALLOC_CTX *tmp_ctx,
+                                       struct ldb_context *ldb,
+                                       struct ldb_dn *dn,
+                                       const char *rdn_name,
+                                       const struct ldb_val *rdn_value,
+                                       struct GUID guid)
+{
+       return replmd_make_prefix_child_dn(tmp_ctx,
+                                          ldb, dn,
+                                          "DEL:",
+                                          rdn_name,
+                                          rdn_value,
+                                          guid);
+}
+
+
 /*
   perform a modify operation which sets the rDN and name attributes to
   their current values. This has the effect of changing these
 /*
   perform a modify operation which sets the rDN and name attributes to
   their current values. This has the effect of changing these