ldb_tdb: Delete a successful tdb_store on index add fail in ltdb_add_internal()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 25 Aug 2017 10:33:15 +0000 (22:33 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:21 +0000 (21:20 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_tdb.c

index e2f08cdfc821c99333bb0f6fef98e239deceb4d8..24bdb0d0852fd9657d41469e420482f163d7922d 100644 (file)
@@ -451,6 +451,17 @@ static int ltdb_add_internal(struct ldb_module *module,
 
        ret = ltdb_index_add_new(module, ltdb, msg);
        if (ret != LDB_SUCCESS) {
+               /*
+                * If we failed to index, delete the message again.
+                *
+                * This is particularly important for the GUID index
+                * case, which will only fail for a duplicate DN
+                * in the index add.
+                *
+                * Note that the caller may not cancel the transation
+                * and this means the above add might really show up!
+                */
+               ltdb_delete_noindex(module, msg);
                return ret;
        }