diff options
author | Andrew Bartlett <abartlet@samba.org> | 2016-08-04 15:25:52 +1200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2016-08-11 00:49:14 +0200 |
commit | 29caafaf2888b25408fcafdb9767a003a910c1d7 (patch) | |
tree | 0fcc453a17fa313bfebceac4e64b5a645b4d4887 /source4/dsdb/schema/schema_set.c | |
parent | c533b60ceb761b609e78dfe270930cb99fdac848 (diff) | |
download | samba-29caafaf2888b25408fcafdb9767a003a910c1d7.tar.gz |
s4:dsdb/schema: Remove unused old schema from memory
This avoids confusion when reading the talloc dump from a ldb context that has
been the target of replication, as the dsdb_schema_copy_shallow() memory was
still around, if unused.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12115
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb/schema/schema_set.c')
-rw-r--r-- | source4/dsdb/schema/schema_set.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 1b29c4dce4b..a404e0acdfc 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -566,6 +566,8 @@ int dsdb_set_global_schema(struct ldb_context *ldb) { int ret; void *use_global_schema = (void *)1; + struct dsdb_schema *old_schema = ldb_get_opaque(ldb, "dsdb_schema"); + ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", use_global_schema); if (ret != LDB_SUCCESS) { return ret; @@ -575,6 +577,16 @@ int dsdb_set_global_schema(struct ldb_context *ldb) return LDB_SUCCESS; } + /* Remove any pointer to a previous schema */ + ret = ldb_set_opaque(ldb, "dsdb_schema", NULL); + if (ret != LDB_SUCCESS) { + return ret; + } + + /* Remove the reference to the schema we just overwrote - if there was + * none, NULL is harmless here */ + talloc_unlink(ldb, old_schema); + /* Set the new attributes based on the new schema */ ret = dsdb_schema_set_indices_and_attributes(ldb, global_schema, false /* Don't write indices and attributes, it's expensive */); if (ret == LDB_SUCCESS) { |