schema: Set flag into @INDEXLIST to indicate we support feature flags
authorAndrew Bartlett <abartlet@samba.org>
Fri, 3 Feb 2017 03:13:43 +0000 (16:13 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 Feb 2017 02:17:16 +0000 (03:17 +0100)
Because @INDEXLIST is rewritten by all Samba versions, we can detect
that we have opened the database with an older version that does not
support the feature flags by the absense of this in @INDEXLIST

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/samba_dsdb.c
source4/dsdb/samdb/samdb.h
source4/dsdb/schema/schema_set.c

index 9de62f386c9ae6bc182d55c6a5a608cf8bbcd4f9..fd432e202407b1fb565a5c3ec61766124361d934 100644 (file)
@@ -235,7 +235,7 @@ static int samba_dsdb_init(struct ldb_module *module)
        TALLOC_CTX *tmp_ctx = talloc_new(module);
        struct ldb_result *res;
        struct ldb_message *rootdse_msg = NULL, *partition_msg;
-       struct ldb_dn *samba_dsdb_dn, *partition_dn;
+       struct ldb_dn *samba_dsdb_dn, *partition_dn, *indexlist_dn;
        struct ldb_module *backend_module, *module_chain;
        const char **final_module_list, **reverse_module_list;
        /*
@@ -320,6 +320,7 @@ static int samba_dsdb_init(struct ldb_module *module)
        static const char *samba_dsdb_attrs[] = { "backendType",
                                                  SAMBA_COMPATIBLE_FEATURES_ATTR,
                                                  SAMBA_REQUIRED_FEATURES_ATTR, NULL };
+       static const char *indexlist_attrs[] = { SAMBA_FEATURES_SUPPORTED_FLAG, NULL };
        static const char *partition_attrs[] = { "ldapBackend", NULL };
        const char *backendType, *backendUrl;
        bool use_sasl_external = false;
@@ -342,6 +343,12 @@ static int samba_dsdb_init(struct ldb_module *module)
                return ldb_oom(ldb);
        }
 
+       indexlist_dn = ldb_dn_new(tmp_ctx, ldb, "@INDEXLIST");
+       if (!samba_dsdb_dn) {
+               talloc_free(tmp_ctx);
+               return ldb_oom(ldb);
+       }
+
        partition_dn = ldb_dn_new(tmp_ctx, ldb, DSDB_PARTITION_DN);
        if (!partition_dn) {
                talloc_free(tmp_ctx);
index 586a3bfaf0ec0f347c21835d895740b4cf4f350b..3eb4a67bdfc5156700cbeae18a9d5ff7f5eb3f5c 100644 (file)
@@ -316,4 +316,5 @@ struct dsdb_extended_sec_desc_propagation_op {
 
 #define SAMBA_COMPATIBLE_FEATURES_ATTR "compatibleFeatures"
 #define SAMBA_REQUIRED_FEATURES_ATTR "requiredFeatures"
+#define SAMBA_FEATURES_SUPPORTED_FLAG "@SAMBA_FEATURES_SUPPORTED"
 #endif /* __SAMDB_H__ */
index 6f03046ff21c0f62e5b07484159b7b0aa17f2bc5..2e688d07546a10be2afa3669aa816378d1a18398 100644 (file)
@@ -111,6 +111,11 @@ static int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, struc
                goto op_error;
        }
 
+       ret = ldb_msg_add_string(msg_idx, SAMBA_FEATURES_SUPPORTED_FLAG, "1");
+       if (ret != LDB_SUCCESS) {
+               goto op_error;
+       }
+
        for (attr = schema->attributes; attr; attr = attr->next) {
                const char *syntax = attr->syntax->ldb_syntax;