ldb_tdb: Write GUID index values as version 3
authorAndrew Bartlett <abartlet@samba.org>
Thu, 10 Aug 2017 05:04:23 +0000 (17:04 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:21 +0000 (21:20 +0200)
Nothing reads these currently, but we should refuse to load a mixed up index
in the future

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_index.c

index dc33217aea9f0f15643103dd7596b3ff3c095316..179fe671393d346f5768699efcd70133659279a0 100644 (file)
@@ -49,6 +49,8 @@ struct ltdb_idxptr {
 */
 #define LTDB_INDEXING_VERSION 2
 
+#define LTDB_GUID_INDEXING_VERSION 3
+
 /* enable the idxptr mode when transactions start */
 int ltdb_index_transaction_start(struct ldb_module *module)
 {
@@ -274,10 +276,20 @@ static int ltdb_dn_list_store_full(struct ldb_module *module,
                return ldb_module_oom(module);
        }
 
-       ret = ldb_msg_add_fmt(msg, LTDB_IDXVERSION, "%u", LTDB_INDEXING_VERSION);
-       if (ret != LDB_SUCCESS) {
-               talloc_free(msg);
-               return ldb_module_oom(module);
+       if (ltdb->cache->GUID_index_attribute == NULL) {
+               ret = ldb_msg_add_fmt(msg, LTDB_IDXVERSION, "%u",
+                                     LTDB_INDEXING_VERSION);
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(msg);
+                       return ldb_module_oom(module);
+               }
+       } else {
+               ret = ldb_msg_add_fmt(msg, LTDB_IDXVERSION, "%u",
+                                     LTDB_GUID_INDEXING_VERSION);
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(msg);
+                       return ldb_module_oom(module);
+               }
        }
 
        msg->dn = dn;