From: Stefan Metzmacher Date: Wed, 1 Jun 2016 21:13:21 +0000 (+0200) Subject: s4:dsdb/samdb: add DSDB_FLAG_INTERNAL_FORCE_META_DATA X-Git-Tag: tdb-1.3.10~463 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ca71aa1523e9653964d63b496e3cf50f18ee0a1;p=thirdparty%2Fsamba.git s4:dsdb/samdb: add DSDB_FLAG_INTERNAL_FORCE_META_DATA With this it's possible to add a replPropertyMetaData entry for an empty attribute. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9654 Signed-off-by: Stefan Metzmacher 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 1db23927be0..80808347e4f 100644 --- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c +++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c @@ -986,12 +986,15 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) is_schema_nc = ldb_dn_compare_base(replmd_private->schema_dn, msg->dn) == 0; - for (i=0; i < msg->num_elements; i++) { + for (i=0; i < msg->num_elements;) { struct ldb_message_element *e = &msg->elements[i]; struct replPropertyMetaData1 *m = &nmd.ctr.ctr1.array[ni]; const struct dsdb_attribute *sa; - if (e->name[0] == '@') continue; + if (e->name[0] == '@') { + i++; + continue; + } sa = dsdb_attribute_by_lDAPDisplayName(ac->schema, e->name); if (!sa) { @@ -1006,6 +1009,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) /* if the attribute is not replicated (0x00000001) * or constructed (0x00000004) it has no metadata */ + i++; continue; } @@ -1019,6 +1023,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) } /* linked attributes are not stored in replPropertyMetaData in FL above w2k */ + i++; continue; } @@ -1051,6 +1056,20 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req) m->originating_usn = ac->seq_num; m->local_usn = ac->seq_num; ni++; + + if (!(e->flags & DSDB_FLAG_INTERNAL_FORCE_META_DATA)) { + i++; + continue; + } + + e->flags &= ~DSDB_FLAG_INTERNAL_FORCE_META_DATA; + + if (e->num_values != 0) { + i++; + continue; + } + + ldb_msg_remove_element(msg, e); } /* fix meta data count */ @@ -1237,6 +1256,11 @@ static int replmd_update_rpmd_element(struct ldb_context *ldb, } } + if (el->flags & DSDB_FLAG_INTERNAL_FORCE_META_DATA) { + may_skip = false; + el->flags &= ~DSDB_FLAG_INTERNAL_FORCE_META_DATA; + } + if (may_skip) { if (strcmp(el->name, "interSiteTopologyGenerator") != 0 && !ldb_request_get_control(req, LDB_CONTROL_PROVISION_OID)) { @@ -1565,10 +1589,13 @@ static int replmd_update_rpmd(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - for (i=0; inum_elements; i++) { + for (i=0; inum_elements;) { + struct ldb_message_element *el = &msg->elements[i]; struct ldb_message_element *old_el; - old_el = ldb_msg_find_element(res->msgs[0], msg->elements[i].name); - ret = replmd_update_rpmd_element(ldb, msg, &msg->elements[i], old_el, &omd, schema, seq_num, + + old_el = ldb_msg_find_element(res->msgs[0], el->name); + ret = replmd_update_rpmd_element(ldb, msg, el, old_el, + &omd, schema, seq_num, our_invocation_id, now, is_schema_nc, req); @@ -1577,9 +1604,22 @@ static int replmd_update_rpmd(struct ldb_module *module, } if (!*is_urgent && (situation == REPL_URGENT_ON_UPDATE)) { - *is_urgent = replmd_check_urgent_attribute(&msg->elements[i]); + *is_urgent = replmd_check_urgent_attribute(el); + } + + if (!(el->flags & DSDB_FLAG_INTERNAL_FORCE_META_DATA)) { + i++; + continue; + } + + el->flags &= ~DSDB_FLAG_INTERNAL_FORCE_META_DATA; + + if (el->num_values != 0) { + i++; + continue; } + ldb_msg_remove_element(msg, el); } } diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 12971dd6d93..8c5e1779b53 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -296,4 +296,11 @@ struct dsdb_extended_sec_desc_propagation_op { #define DSDB_SAMDB_MINIMUM_ALLOWED_RID 1000 #define DSDB_METADATA_SCHEMA_SEQ_NUM "SCHEMA_SEQ_NUM" + +/* + * must be in LDB_FLAG_INTERNAL_MASK + * see also the values in lib/ldb/include/ldb_module.h + */ +#define DSDB_FLAG_INTERNAL_FORCE_META_DATA 0x10000 + #endif /* __SAMDB_H__ */