ldb_tdb: modify ltdb_delete_noindex() to take a struct ldb_message
authorAndrew Bartlett <abartlet@samba.org>
Wed, 16 Aug 2017 21:08:34 +0000 (09:08 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:21 +0000 (21:20 +0200)
This will make it easier to delete records with the GUID TDB key

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

index 179fe671393d346f5768699efcd70133659279a0..1276701b6f50b0d7fc3c4c2ad1483f49b2a96b7c 100644 (file)
@@ -263,19 +263,22 @@ static int ltdb_dn_list_store_full(struct ldb_module *module,
        struct ldb_message *msg;
        int ret;
 
+       msg = ldb_msg_new(module);
+       if (!msg) {
+               return ldb_module_oom(module);
+       }
+
+       msg->dn = dn;
+
        if (list->count == 0) {
-               ret = ltdb_delete_noindex(module, dn);
+               ret = ltdb_delete_noindex(module, msg);
                if (ret == LDB_ERR_NO_SUCH_OBJECT) {
+                       talloc_free(msg);
                        return LDB_SUCCESS;
                }
                return ret;
        }
 
-       msg = ldb_msg_new(module);
-       if (!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);
@@ -292,7 +295,6 @@ static int ltdb_dn_list_store_full(struct ldb_module *module,
                }
        }
 
-       msg->dn = dn;
        if (list->count > 0) {
                struct ldb_message_element *el;
 
index 32d9e344d626fd3ee1da998789b9d84389913fd5..e2f08cdfc821c99333bb0f6fef98e239deceb4d8 100644 (file)
@@ -491,7 +491,8 @@ static int ltdb_add(struct ltdb_context *ctx)
   delete a record from the database, not updating indexes (used for deleting
   index records)
 */
-int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn)
+int ltdb_delete_noindex(struct ldb_module *module,
+                       const struct ldb_message *msg)
 {
        void *data = ldb_module_get_private(module);
        struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
@@ -502,7 +503,7 @@ int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn)
                return LDB_ERR_UNWILLING_TO_PERFORM;
        }
 
-       tdb_key = ltdb_key_dn(module, dn);
+       tdb_key = ltdb_key_dn(module, msg->dn);
        if (!tdb_key.dptr) {
                return LDB_ERR_OTHER;
        }
@@ -535,7 +536,7 @@ static int ltdb_delete_internal(struct ldb_module *module, struct ldb_dn *dn)
                goto done;
        }
 
-       ret = ltdb_delete_noindex(module, dn);
+       ret = ltdb_delete_noindex(module, msg);
        if (ret != LDB_SUCCESS) {
                goto done;
        }
index 8d6c9f500c20b36b2f8b07d4bdddd4ae1611d67e..d35b090956aea02edffb08a0138d63bbc4c308d5 100644 (file)
@@ -138,7 +138,8 @@ TDB_DATA ltdb_key_dn(struct ldb_module *module, struct ldb_dn *dn);
 TDB_DATA ltdb_key_msg(struct ldb_module *module, const struct ldb_message *msg);
 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
-int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);
+int ltdb_delete_noindex(struct ldb_module *module,
+                       const struct ldb_message *msg);
 int ltdb_err_map(enum TDB_ERROR tdb_code);
 
 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,