From 75e88e40a2c66668a95f00e151efe18c365580fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 14 Sep 2017 14:04:51 +1200 Subject: [PATCH] ldb_tdb: Map TDB error codes into LDB error codes in ltdb_lock_read() The ltdb_lock_read() routine did not return an LDB error code, but -1. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13033 Signed-off-by: Gary Lockyer Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- lib/ldb/ldb_tdb/ldb_tdb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index ccad8168a6e..055d8354b73 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -98,15 +98,26 @@ int ltdb_lock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); - int ret = 0; + int tdb_ret = 0; + int ret; if (ltdb->in_transaction == 0 && ltdb->read_lock_count == 0) { - ret = tdb_lockall_read(ltdb->tdb); + tdb_ret = tdb_lockall_read(ltdb->tdb); } - if (ret == 0) { + if (tdb_ret == 0) { ltdb->read_lock_count++; + return LDB_SUCCESS; } + ret = ltdb_err_map(tdb_error(ltdb->tdb)); + if (ret == LDB_SUCCESS) { + ret = LDB_ERR_OPERATIONS_ERROR; + } + ldb_debug_set(ldb_module_get_ctx(module), + LDB_DEBUG_FATAL, + "Failure during ltdb_lock_read(): %s -> %s", + tdb_errorstr(ltdb->tdb), + ldb_strerror(ret)); return ret; }