summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/tdb/tdb.c6
-rw-r--r--source4/lib/tdb/tdb.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/source4/lib/tdb/tdb.c b/source4/lib/tdb/tdb.c
index 8fbf128914..5f57f05778 100644
--- a/source4/lib/tdb/tdb.c
+++ b/source4/lib/tdb/tdb.c
@@ -1479,6 +1479,12 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
/* first try in-place update, on modify or replace. */
if (tdb_update_hash(tdb, key, hash, dbuf) == 0)
goto out;
+ if (tdb->ecode == TDB_ERR_NOEXIST &&
+ flag == TDB_MODIFY) {
+ /* if the record doesn't exist and we are in TDB_MODIFY mode then
+ we should fail the store */
+ goto fail;
+ }
}
/* reset the error code potentially set by the tdb_update() */
tdb->ecode = TDB_SUCCESS;
diff --git a/source4/lib/tdb/tdb.h b/source4/lib/tdb/tdb.h
index b3a28b7440..b7c51b5519 100644
--- a/source4/lib/tdb/tdb.h
+++ b/source4/lib/tdb/tdb.h
@@ -29,6 +29,7 @@ extern "C" {
/* flags to tdb_store() */
#define TDB_REPLACE 1
#define TDB_INSERT 2
+#define TDB_MODIFY 3
/* flags for tdb_open() */
#define TDB_DEFAULT 0 /* just a readability place holder */