1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

schema: Reorder dsdb_set_schema() to unlink the old schema last

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2016-07-04 14:06:10 +12:00
parent 2a90606417
commit 51d2779a60

View File

@ -475,24 +475,17 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
old_schema = ldb_get_opaque(ldb, "dsdb_schema");
ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
if (ret != LDB_SUCCESS) {
return ret;
}
ret = ldb_set_opaque(ldb, "dsdb_schema", schema);
if (ret != LDB_SUCCESS) {
return ret;
}
/* Remove the reference to the schema we just overwrote - if there was
* none, NULL is harmless here */
if (old_schema != schema) {
talloc_unlink(ldb, old_schema);
talloc_steal(ldb, schema);
}
talloc_steal(ldb, schema);
ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
if (ret != LDB_SUCCESS) {
return ret;
}
/* Set the new attributes based on the new schema */
ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true);
@ -500,7 +493,15 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
return ret;
}
return LDB_SUCCESS;
/*
* Remove the reference to the schema we just overwrote - if there was
* none, NULL is harmless here.
*/
if (old_schema != schema) {
talloc_unlink(ldb, old_schema);
}
return ret;
}
/**