From: Tim Beale Date: Thu, 28 Sep 2017 02:58:16 +0000 (+1300) Subject: replmd: Make replmd_set_la_val() closer to replmd_build_la_val() X-Git-Tag: tevent-0.9.34~153 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a607a3e83e1f355b73057af235f385c6db98f5c4;p=thirdparty%2Fsamba.git replmd: Make replmd_set_la_val() closer to replmd_build_la_val() These two functions are almost identical. The main difference between them is the RMD_ADDTIME. replmd_set_la_val() tries to use the RMD_ADDTIME of the old_dsdb_dn. Whereas replmd_build_la_val() always uses the time passed in. Change replmd_set_la_val() so it can accept a NULL old_dsdb_dn (i.e. if it's a new linked attribute that's being set). If so, it'll end up using the nttime parameter passed in, same as replmd_build_la_val() does. Also update replmd_process_linked_attribute (which used to use replmd_build_la_val()) to now pass in a NULL old_dsdb_dn. There shouldn't be a difference in behaviour either way, but this exercises the code change. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13055 Signed-off-by: Tim Beale Reviewed-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c index 80a5cad2b14..a7ee2d70fbb 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -2305,7 +2305,7 @@ static int replmd_set_la_val(TALLOC_CTX *mem_ctx, struct ldb_val *v, struct dsdb struct ldb_val iid; struct ldb_val usnv, local_usnv; struct ldb_val vers, flagsv; - const struct ldb_val *old_addtime; + const struct ldb_val *old_addtime = NULL; NTSTATUS status; int ret; const char *dnstring; @@ -2345,7 +2345,10 @@ static int replmd_set_la_val(TALLOC_CTX *mem_ctx, struct ldb_val *v, struct dsdb if (ret != LDB_SUCCESS) return ret; /* get the ADDTIME from the original */ - old_addtime = ldb_dn_get_extended_component(old_dsdb_dn->dn, "RMD_ADDTIME"); + if (old_dsdb_dn != NULL) { + old_addtime = ldb_dn_get_extended_component(old_dsdb_dn->dn, + "RMD_ADDTIME"); + } if (old_addtime == NULL) { old_addtime = &tval; }