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:
parent
2a90606417
commit
51d2779a60
@ -475,32 +475,33 @@ 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);
|
||||
if (ret != LDB_SUCCESS) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user