summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2018-11-12 11:13:28 +1300
committerTim Beale <timbeale@samba.org>2018-11-21 01:51:11 +0100
commitf53954d0fd4d67c73336e9fda81429df9c55d77a (patch)
tree7cbc5bd74a38edcfd66abe980911d9e4f828980c /source4
parentc371fef58638a7570becf29dd0df651004219d0a (diff)
downloadsamba-f53954d0fd4d67c73336e9fda81429df9c55d77a.tar.gz
replmd: Move where we update the usnChanged/whenChanged
Move this closer to where the source object actually gets modified. The main reason to do this is that adding fields can cause the msg->elements to be reallocated, which will invalidate all the old_el and pdn_list pointers which are derived from the msg. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index b97c9db355f..88c5b6c9c4f 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -7947,7 +7947,6 @@ static int replmd_process_linked_attribute(struct ldb_module *module,
struct dsdb_dn *dsdb_dn = NULL;
uint64_t seq_num = 0;
struct ldb_message_element *old_el;
- time_t t = time(NULL);
struct parsed_dn *pdn_list, *pdn, *next;
struct GUID guid = GUID_zero();
bool active = (la->flags & DRSUAPI_DS_LINKED_ATTRIBUTE_FLAG_ACTIVE)?true:false;
@@ -8142,22 +8141,6 @@ static int replmd_process_linked_attribute(struct ldb_module *module,
}
}
- /* we only change whenChanged and uSNChanged if the seq_num
- has changed */
- ldb_msg_remove_attr(msg, "whenChanged");
- ldb_msg_remove_attr(msg, "uSNChanged");
- ret = add_time_element(msg, "whenChanged", t);
- if (ret != LDB_SUCCESS) {
- ldb_operr(ldb);
- return ret;
- }
-
- ret = add_uint64_element(ldb, msg, "uSNChanged", seq_num);
- if (ret != LDB_SUCCESS) {
- ldb_operr(ldb);
- return ret;
- }
-
old_el = ldb_msg_find_element(msg, attr->lDAPDisplayName);
if (old_el == NULL) {
return ldb_operr(ldb);
@@ -8229,6 +8212,8 @@ static int replmd_process_la_group(struct ldb_module *module,
const struct dsdb_attribute *attr = NULL;
replmd_link_changed change_type;
uint32_t num_changes = 0;
+ time_t t;
+ uint64_t seq_num = 0;
/*
* get the attribute being modified and the search result for the
@@ -8308,6 +8293,26 @@ static int replmd_process_la_group(struct ldb_module *module,
return LDB_SUCCESS;
}
+ /* update whenChanged/uSNChanged as the object has changed */
+ t = time(NULL);
+ ret = ldb_sequence_number(ldb, LDB_SEQ_HIGHEST_SEQ,
+ &seq_num);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ ret = add_time_element(msg, "whenChanged", t);
+ if (ret != LDB_SUCCESS) {
+ ldb_operr(ldb);
+ return ret;
+ }
+
+ ret = add_uint64_element(ldb, msg, "uSNChanged", seq_num);
+ if (ret != LDB_SUCCESS) {
+ ldb_operr(ldb);
+ return ret;
+ }
+
/* apply the link changes to the source object */
ret = linked_attr_modify(module, msg, NULL);
if (ret != LDB_SUCCESS) {