diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-08-10 08:44:04 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2012-08-10 10:18:28 +1000 |
commit | fdd07e87c6fc7a4a0ea7c6f99080d78e526042e6 (patch) | |
tree | 1d5daf395827c0b602669bd0ee7bfdff3a7b6a34 /source4/dsdb | |
parent | 1d1bdc315b4619f0ca5b2a0db602cbe283f8dca8 (diff) | |
download | samba-fdd07e87c6fc7a4a0ea7c6f99080d78e526042e6.tar.gz samba-fdd07e87c6fc7a4a0ea7c6f99080d78e526042e6.tar.bz2 samba-fdd07e87c6fc7a4a0ea7c6f99080d78e526042e6.zip |
s4-dsdb: Explain better what records are written during schema set
This is controlled by setting write_indices_and_attributes.
Andrew Bartlett
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/pydsdb.c | 6 | ||||
-rw-r--r-- | source4/dsdb/schema/schema_set.c | 23 |
2 files changed, 19 insertions, 10 deletions
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 9023d69054..39229f487f 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -873,9 +873,9 @@ static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args) struct ldb_context *from_ldb; struct dsdb_schema *schema; int ret; - char write_attributes = true; + char write_indices_and_attributes = true; if (!PyArg_ParseTuple(args, "OO|b", - &py_ldb, &py_from_ldb, &write_attributes)) + &py_ldb, &py_from_ldb, &write_indices_and_attributes)) return NULL; PyErr_LDB_OR_RAISE(py_ldb, ldb); @@ -888,7 +888,7 @@ static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args) return NULL; } - ret = dsdb_reference_schema(ldb, schema, write_attributes); + ret = dsdb_reference_schema(ldb, schema, write_indices_and_attributes); PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_get_exception(), ret, ldb); Py_RETURN_NONE; diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 286a8a3f23..e226118b4c 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -50,8 +50,13 @@ const struct ldb_schema_attribute *dsdb_attribute_handler_override(struct ldb_co } return a->ldb_schema_attribute; } - -static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_attributes) +/* + * Set the attribute handlers onto the LDB, and potentially write the + * @INDEXLIST, @IDXONE and @ATTRIBUTES records. The @ATTRIBUTES records + * are required so we can operate on a schema-less database (say the + * backend during emergency fixes) and during the schema load. + */ +static int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_indices_and_attributes) { int ret = LDB_SUCCESS; struct ldb_result *res; @@ -65,7 +70,7 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem /* setup our own attribute name to schema handler */ ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema); - if (!write_attributes) { + if (!write_indices_and_attributes) { return ret; } @@ -454,7 +459,7 @@ int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema) } /* Set the new attributes based on the new schema */ - ret = dsdb_schema_set_attributes(ldb, schema, true); + ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true); if (ret != LDB_SUCCESS) { return ret; } @@ -469,9 +474,13 @@ static struct dsdb_schema *global_schema; /** * Make this ldb use a specified schema, already fully calculated and belonging to another ldb + * + * The write_indices_and_attributes controls writing of the @ records + * because we cannot write to a database that does not yet exist on + * disk. */ int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema, - bool write_attributes) + bool write_indices_and_attributes) { int ret; struct dsdb_schema *old_schema; @@ -495,7 +504,7 @@ int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema, return ret; } - ret = dsdb_schema_set_attributes(ldb, schema, write_attributes); + ret = dsdb_schema_set_indices_and_attributes(ldb, schema, write_indices_and_attributes); if (ret != LDB_SUCCESS) { return ret; } @@ -519,7 +528,7 @@ int dsdb_set_global_schema(struct ldb_context *ldb) } /* Set the new attributes based on the new schema */ - ret = dsdb_schema_set_attributes(ldb, global_schema, false /* Don't write attributes, it's expensive */); + ret = dsdb_schema_set_indices_and_attributes(ldb, global_schema, false /* Don't write indices and attributes, it's expensive */); if (ret == LDB_SUCCESS) { /* Keep a reference to this schema, just in case the original copy is replaced */ if (talloc_reference(ldb, global_schema) == NULL) { |