From 5364f8d3d5a9a9fde6ca0ed88c9943dbfb02f699 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 17 Oct 2017 11:27:49 +1300 Subject: [PATCH] repl_meta_data: Split replmd_make_deleted_child_dn() into a helper function This will allow it to be used in common with replmd_conflict_dn() Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- .../dsdb/samdb/ldb_modules/repl_meta_data.c | 69 +++++++++++++++++-- 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 8664267a512..8bb47b330ab 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -4543,16 +4543,16 @@ static struct ldb_dn *replmd_conflict_dn(TALLOC_CTX *mem_ctx, struct ldb_dn *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; - const char *four_char_prefix = "DEL:"; 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 -- 2.34.1