From: Stefan Metzmacher Date: Mon, 8 Aug 2016 09:07:18 +0000 (+0200) Subject: s4:dsdb/repl: make sure the working_schema prefix map is populated with the remote... X-Git-Tag: tevent-0.9.30~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edeb577a59ea88d2a22559ffb8cbe994ea28f3f1;p=thirdparty%2Fsamba.git s4:dsdb/repl: make sure the working_schema prefix map is populated with the remote prefix map We should create the working_schema prefix map before we try to resolve the schema. This allows getting the same mapping (if there's not already a conflict) and allows us to remove the implicit prefix mapping creation in the prefix mapping lookup functions. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12128 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/source4/dsdb/repl/replicated_objects.c b/source4/dsdb/repl/replicated_objects.c index 17b68a42d2a..288bcc111c2 100644 --- a/source4/dsdb/repl/replicated_objects.c +++ b/source4/dsdb/repl/replicated_objects.c @@ -291,6 +291,7 @@ WERROR dsdb_repl_make_working_schema(struct ldb_context *ldb, { WERROR werr; struct dsdb_schema_prefixmap *pfm_remote; + uint32_t r; struct dsdb_schema *working_schema; /* make a copy of the iniatial_scheam so we don't mess with it */ @@ -310,6 +311,40 @@ WERROR dsdb_repl_make_working_schema(struct ldb_context *ldb, return werr; } + for (r=0; r < pfm_remote->length; r++) { + const struct dsdb_schema_prefixmap_oid *rm = &pfm_remote->prefixes[r]; + bool found_oid = false; + uint32_t l; + + for (l=0; l < working_schema->prefixmap->length; l++) { + const struct dsdb_schema_prefixmap_oid *lm = &working_schema->prefixmap->prefixes[l]; + int cmp; + + cmp = data_blob_cmp(&rm->bin_oid, &lm->bin_oid); + if (cmp == 0) { + found_oid = true; + break; + } + } + + if (found_oid) { + continue; + } + + /* + * We prefer the same is as we got from the remote peer + * if there's no conflict. + */ + werr = dsdb_schema_pfm_add_entry(working_schema->prefixmap, + rm->bin_oid, &rm->id, NULL); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(0,(__location__ ": Failed to merge remote prefixMap: %s", + win_errstr(werr))); + talloc_free(working_schema); + return werr; + } + } + werr = dsdb_repl_resolve_working_schema(ldb, pfm_remote, 0, /* cycle_before_switching */