summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAaron Haslett <aaronhaslett@catalyst.net.nz>2019-05-22 14:07:19 +1200
committerAndrew Bartlett <abartlet@samba.org>2019-05-29 04:41:24 +0000
commit08b9d204b6eeda0aedea754f7e4b6f809d358cfe (patch)
treedd069c8dd81039fbfb2cc5c10afb73b703fbb95f /source4
parent6005c8cbad77259fa3cb89ab21cb5f26b72413cd (diff)
downloadsamba-08b9d204b6eeda0aedea754f7e4b6f809d358cfe.tar.gz
ldb: binding ordered indexes to GUID indexing
To reduce the number of potential combinations of database features in ldb, we want to link all new database features since 4.7. GUID indexing, ordered integers, and pack format changes will all upgrade together. This patch makes ordered integers only function if GUID indexing is enabled. If GUID indexing is disabled, ORDERED_INTEGER will not be written to @ATTRIBUTES and a syntax's index_format_fn will never be used. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/schema/schema_set.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index b7043bd22ca..19beec561a4 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -73,11 +73,22 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
struct loadparm_context *lp_ctx =
talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
struct loadparm_context);
+ bool guid_indexing = true;
+ if (lp_ctx != NULL) {
+ /*
+ * GUID indexing is wanted by Samba by default. This allows
+ * an override in a specific case for downgrades.
+ */
+ guid_indexing = lpcfg_parm_bool(lp_ctx,
+ NULL,
+ "dsdb",
+ "guid index",
+ true);
+ }
/* setup our own attribute name to schema handler */
ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema);
ldb_schema_set_override_indexlist(ldb, true);
- if (lp_ctx == NULL ||
- lpcfg_parm_bool(lp_ctx, NULL, "dsdb", "guid index", true)) {
+ if (guid_indexing) {
ldb_schema_set_override_GUID_index(ldb, "objectGUID", "GUID");
}
@@ -116,8 +127,7 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
goto op_error;
}
- if (lp_ctx == NULL ||
- lpcfg_parm_bool(lp_ctx, NULL, "dsdb", "guid index", true)) {
+ if (guid_indexing) {
ret = ldb_msg_add_string(msg_idx, "@IDXGUID", "objectGUID");
if (ret != LDB_SUCCESS) {
goto op_error;
@@ -148,12 +158,25 @@ int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb,
/*
* Write out a rough approximation of the schema
- * as an @ATTRIBUTES value, for bootstrapping
+ * as an @ATTRIBUTES value, for bootstrapping.
+ * Only write ORDERED_INTEGER if we're using GUID indexes,
*/
if (strcmp(syntax, LDB_SYNTAX_INTEGER) == 0) {
ret = ldb_msg_add_string(msg, attr->lDAPDisplayName, "INTEGER");
} else if (strcmp(syntax, LDB_SYNTAX_ORDERED_INTEGER) == 0) {
- ret = ldb_msg_add_string(msg, attr->lDAPDisplayName, "ORDERED_INTEGER");
+ /*
+ * When preparing to downgrade Samba, we need to write
+ * out an LDB without the new key word ORDERED_INTEGER.
+ */
+ if (guid_indexing) {
+ ret = ldb_msg_add_string(msg,
+ attr->lDAPDisplayName,
+ "ORDERED_INTEGER");
+ } else {
+ ret = ldb_msg_add_string(msg,
+ attr->lDAPDisplayName,
+ "INTEGER");
+ }
} else if (strcmp(syntax, LDB_SYNTAX_DIRECTORY_STRING) == 0) {
ret = ldb_msg_add_string(msg, attr->lDAPDisplayName, "CASE_INSENSITIVE");
}