ldb_tdb: Disallow reads without a transaction or read lock
authorAndrew Bartlett <abartlet@samba.org>
Wed, 4 Apr 2018 05:21:30 +0000 (17:21 +1200)
committerStefan Metzmacher <metze@samba.org>
Thu, 12 Apr 2018 13:05:52 +0000 (15:05 +0200)
This will ensure we match LMDB behaviour and avoid a repeat of the per-record locking
issues (compared with full DB locking) we had before Samba 4.7.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_tdb/ldb_tdb.c

index fc14e170c89915c03e331dd5bcad19848265620a..0833a4fd0cac1effeca5aeb43e0266fd33a37164 100644 (file)
@@ -1900,6 +1900,11 @@ static int ltdb_tdb_parse_record(struct ltdb_private *ltdb,
        };
        int ret;
 
+       if (tdb_transaction_active(ltdb->tdb) == false &&
+           ltdb->read_lock_count == 0) {
+               return LDB_ERR_PROTOCOL_ERROR;
+       }
+
        ret = tdb_parse_record(ltdb->tdb, key, ltdb_tdb_parse_record_wrapper,
                               &kv_ctx);
        if (ret == 0) {