From e0186d1f2da7d946ee140e6bb54b1d62766b43aa Mon Sep 17 00:00:00 2001 From: Gary Lockyer Date: Fri, 20 Jul 2018 11:53:21 +1200 Subject: [PATCH] lib ldb: rename ltdb_private to ldb_kv_private Rename ltdb_private to ldb_kv_private as it contains key value operation context. Note there is still some tdb specific context that can be refactored into a separate structure along the lines of the lmdb context. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- lib/ldb/ldb_mdb/ldb_mdb.c | 106 ++++----- lib/ldb/ldb_tdb/ldb_cache.c | 118 +++++----- lib/ldb/ldb_tdb/ldb_index.c | 374 ++++++++++++++++---------------- lib/ldb/ldb_tdb/ldb_search.c | 50 ++--- lib/ldb/ldb_tdb/ldb_tdb.c | 358 +++++++++++++++--------------- lib/ldb/ldb_tdb/ldb_tdb.h | 54 ++--- lib/ldb/tests/ldb_kv_ops_test.c | 242 ++++++++++----------- lib/ldb/tests/ldb_lmdb_test.c | 8 +- lib/ldb/tests/ldb_tdb_test.c | 8 +- 9 files changed, 659 insertions(+), 659 deletions(-) diff --git a/lib/ldb/ldb_mdb/ldb_mdb.c b/lib/ldb/ldb_mdb/ldb_mdb.c index befcb2a7fa0..34e9e1e4aaa 100644 --- a/lib/ldb/ldb_mdb/ldb_mdb.c +++ b/lib/ldb/ldb_mdb/ldb_mdb.c @@ -93,9 +93,9 @@ static int lmdb_error_at(struct ldb_context *ldb, } -static bool lmdb_transaction_active(struct ltdb_private *ltdb) +static bool lmdb_transaction_active(struct ldb_kv_private *ldb_kv) { - return ltdb->lmdb_private->txlist != NULL; + return ldb_kv->lmdb_private->txlist != NULL; } static MDB_txn *lmdb_trans_get_tx(struct lmdb_trans *ltx) @@ -148,18 +148,18 @@ static MDB_txn *get_current_txn(struct lmdb_private *lmdb) return NULL; } -static int lmdb_store(struct ltdb_private *ltdb, +static int lmdb_store(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, int flags) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; MDB_val mdb_key; MDB_val mdb_data; int mdb_flags; MDB_txn *txn = NULL; MDB_dbi dbi = 0; - if (ltdb->read_only) { + if (ldb_kv->read_only) { return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -206,14 +206,14 @@ static int lmdb_store(struct ltdb_private *ltdb, return ldb_mdb_err_map(lmdb->error); } -static int lmdb_delete(struct ltdb_private *ltdb, struct ldb_val key) +static int lmdb_delete(struct ldb_kv_private *ldb_kv, struct ldb_val key) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; MDB_val mdb_key; MDB_txn *txn = NULL; MDB_dbi dbi = 0; - if (ltdb->read_only) { + if (ldb_kv->read_only) { return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -239,11 +239,11 @@ static int lmdb_delete(struct ltdb_private *ltdb, struct ldb_val key) return ldb_mdb_err_map(lmdb->error); } -static int lmdb_traverse_fn(struct ltdb_private *ltdb, +static int lmdb_traverse_fn(struct ldb_kv_private *ldb_kv, ldb_kv_traverse_fn fn, void *ctx) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; MDB_val mdb_key; MDB_val mdb_data; MDB_txn *txn = NULL; @@ -281,7 +281,7 @@ static int lmdb_traverse_fn(struct ltdb_private *ltdb, .data = mdb_data.mv_data, }; - ret = fn(ltdb, key, data, ctx); + ret = fn(ldb_kv, key, data, ctx); if (ret != 0) { goto done; } @@ -300,13 +300,13 @@ done: return ldb_mdb_err_map(lmdb->error); } -static int lmdb_update_in_iterate(struct ltdb_private *ltdb, +static int lmdb_update_in_iterate(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val key2, struct ldb_val data, void *state) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; struct ldb_val copy; int ret = LDB_SUCCESS; @@ -315,13 +315,13 @@ static int lmdb_update_in_iterate(struct ltdb_private *ltdb, * data, as it is in private lmdb memory. */ copy.length = data.length; - copy.data = talloc_memdup(ltdb, data.data, data.length); + copy.data = talloc_memdup(ldb_kv, data.data, data.length); if (copy.data == NULL) { lmdb->error = MDB_PANIC; return ldb_oom(lmdb->ldb); } - lmdb->error = lmdb_delete(ltdb, key); + lmdb->error = lmdb_delete(ldb_kv, key); if (lmdb->error != MDB_SUCCESS) { ldb_debug( lmdb->ldb, @@ -337,7 +337,7 @@ static int lmdb_update_in_iterate(struct ltdb_private *ltdb, goto done; } - lmdb->error = lmdb_store(ltdb, key2, copy, 0); + lmdb->error = lmdb_store(ldb_kv, key2, copy, 0); if (lmdb->error != MDB_SUCCESS) { ldb_debug( lmdb->ldb, @@ -368,12 +368,12 @@ done: } /* Handles only a single record */ -static int lmdb_parse_record(struct ltdb_private *ltdb, struct ldb_val key, +static int lmdb_parse_record(struct ldb_kv_private *ldb_kv, struct ldb_val key, int (*parser)(struct ldb_val key, struct ldb_val data, void *private_data), void *ctx) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; MDB_val mdb_key; MDB_val mdb_data; MDB_txn *txn = NULL; @@ -417,8 +417,8 @@ static int lmdb_parse_record(struct ltdb_private *ltdb, struct ldb_val key, static int lmdb_lock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); + struct lmdb_private *lmdb = ldb_kv->lmdb_private; pid_t pid = getpid(); if (pid != lmdb->pid) { @@ -433,8 +433,8 @@ static int lmdb_lock_read(struct ldb_module *module) } lmdb->error = MDB_SUCCESS; - if (lmdb_transaction_active(ltdb) == false && - ltdb->read_lock_count == 0) { + if (lmdb_transaction_active(ldb_kv) == false && + ldb_kv->read_lock_count == 0) { lmdb->error = mdb_txn_begin(lmdb->env, NULL, MDB_RDONLY, @@ -444,36 +444,36 @@ static int lmdb_lock_read(struct ldb_module *module) return ldb_mdb_error(lmdb->ldb, lmdb->error); } - ltdb->read_lock_count++; + ldb_kv->read_lock_count++; return ldb_mdb_err_map(lmdb->error); } static int lmdb_unlock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); - if (lmdb_transaction_active(ltdb) == false && ltdb->read_lock_count == 1) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + if (lmdb_transaction_active(ldb_kv) == false && ldb_kv->read_lock_count == 1) { + struct lmdb_private *lmdb = ldb_kv->lmdb_private; mdb_txn_commit(lmdb->read_txn); lmdb->read_txn = NULL; - ltdb->read_lock_count--; + ldb_kv->read_lock_count--; return LDB_SUCCESS; } - ltdb->read_lock_count--; + ldb_kv->read_lock_count--; return LDB_SUCCESS; } -static int lmdb_transaction_start(struct ltdb_private *ltdb) +static int lmdb_transaction_start(struct ldb_kv_private *ldb_kv) { - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; struct lmdb_trans *ltx; struct lmdb_trans *ltx_head; MDB_txn *tx_parent; pid_t pid = getpid(); /* Do not take out the transaction lock on a read-only DB */ - if (ltdb->read_only) { + if (ldb_kv->read_only) { return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -507,10 +507,10 @@ static int lmdb_transaction_start(struct ltdb_private *ltdb) return ldb_mdb_err_map(lmdb->error); } -static int lmdb_transaction_cancel(struct ltdb_private *ltdb) +static int lmdb_transaction_cancel(struct ldb_kv_private *ldb_kv) { struct lmdb_trans *ltx; - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; ltx = lmdb_private_trans_head(lmdb); if (ltx == NULL) { @@ -522,16 +522,16 @@ static int lmdb_transaction_cancel(struct ltdb_private *ltdb) return LDB_SUCCESS; } -static int lmdb_transaction_prepare_commit(struct ltdb_private *ltdb) +static int lmdb_transaction_prepare_commit(struct ldb_kv_private *ldb_kv) { /* No need to prepare a commit */ return LDB_SUCCESS; } -static int lmdb_transaction_commit(struct ltdb_private *ltdb) +static int lmdb_transaction_commit(struct ldb_kv_private *ldb_kv) { struct lmdb_trans *ltx; - struct lmdb_private *lmdb = ltdb->lmdb_private; + struct lmdb_private *lmdb = ldb_kv->lmdb_private; ltx = lmdb_private_trans_head(lmdb); if (ltx == NULL) { @@ -544,22 +544,22 @@ static int lmdb_transaction_commit(struct ltdb_private *ltdb) return lmdb->error; } -static int lmdb_error(struct ltdb_private *ltdb) +static int lmdb_error(struct ldb_kv_private *ldb_kv) { - return ldb_mdb_err_map(ltdb->lmdb_private->error); + return ldb_mdb_err_map(ldb_kv->lmdb_private->error); } -static const char *lmdb_errorstr(struct ltdb_private *ltdb) +static const char *lmdb_errorstr(struct ldb_kv_private *ldb_kv) { - return mdb_strerror(ltdb->lmdb_private->error); + return mdb_strerror(ldb_kv->lmdb_private->error); } -static const char * lmdb_name(struct ltdb_private *ltdb) +static const char * lmdb_name(struct ldb_kv_private *ldb_kv) { return "lmdb"; } -static bool lmdb_changed(struct ltdb_private *ltdb) +static bool lmdb_changed(struct ldb_kv_private *ldb_kv) { /* * lmdb does no provide a quick way to determine if the database @@ -837,7 +837,7 @@ int lmdb_connect(struct ldb_context *ldb, { const char *path = NULL; struct lmdb_private *lmdb = NULL; - struct ltdb_private *ltdb = NULL; + struct ldb_kv_private *ldb_kv = NULL; int ret; /* @@ -852,29 +852,29 @@ int lmdb_connect(struct ldb_context *ldb, return LDB_ERR_OPERATIONS_ERROR; } - ltdb = talloc_zero(ldb, struct ltdb_private); - if (!ltdb) { + ldb_kv = talloc_zero(ldb, struct ldb_kv_private); + if (!ldb_kv) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - lmdb = talloc_zero(ltdb, struct lmdb_private); + lmdb = talloc_zero(ldb_kv, struct lmdb_private); if (lmdb == NULL) { - TALLOC_FREE(ltdb); + TALLOC_FREE(ldb_kv); return ldb_oom(ldb); } lmdb->ldb = ldb; - ltdb->kv_ops = &lmdb_key_value_ops; + ldb_kv->kv_ops = &lmdb_key_value_ops; ret = lmdb_pvt_open(lmdb, ldb, path, flags); if (ret != LDB_SUCCESS) { - TALLOC_FREE(ltdb); + TALLOC_FREE(ldb_kv); return ret; } - ltdb->lmdb_private = lmdb; + ldb_kv->lmdb_private = lmdb; if (flags & LDB_FLG_RDONLY) { - ltdb->read_only = true; + ldb_kv->read_only = true; } /* @@ -883,8 +883,8 @@ int lmdb_connect(struct ldb_context *ldb, * The override option is max_key_len_for_self_test, and is * used for testing only. */ - ltdb->max_key_length = LDB_MDB_MAX_KEY_LENGTH; + ldb_kv->max_key_length = LDB_MDB_MAX_KEY_LENGTH; return ldb_kv_init_store( - ltdb, "ldb_mdb backend", ldb, options, _module); + ldb_kv, "ldb_mdb backend", ldb, options, _module); } diff --git a/lib/ldb/ldb_tdb/ldb_cache.c b/lib/ldb/ldb_tdb/ldb_cache.c index e9da45db2d5..1a07f99e843 100644 --- a/lib/ldb/ldb_tdb/ldb_cache.c +++ b/lib/ldb/ldb_tdb/ldb_cache.c @@ -236,7 +236,7 @@ failed: register any index records we find for the DB */ static int ldb_kv_index_load(struct ldb_module *module, - struct ltdb_private *ltdb) + struct ldb_kv_private *ldb_kv) { struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_dn *indexlist_dn; @@ -247,32 +247,32 @@ static int ldb_kv_index_load(struct ldb_module *module, * we skip loading the @INDEXLIST record when a module is * supplying its own attribute handling */ - ltdb->cache->attribute_indexes = true; - ltdb->cache->one_level_indexes = ldb->schema.one_level_indexes; - ltdb->cache->GUID_index_attribute + ldb_kv->cache->attribute_indexes = true; + ldb_kv->cache->one_level_indexes = ldb->schema.one_level_indexes; + ldb_kv->cache->GUID_index_attribute = ldb->schema.GUID_index_attribute; - ltdb->cache->GUID_index_dn_component + ldb_kv->cache->GUID_index_dn_component = ldb->schema.GUID_index_dn_component; return 0; } - talloc_free(ltdb->cache->indexlist); + talloc_free(ldb_kv->cache->indexlist); - ltdb->cache->indexlist = ldb_msg_new(ltdb->cache); - if (ltdb->cache->indexlist == NULL) { + ldb_kv->cache->indexlist = ldb_msg_new(ldb_kv->cache); + if (ldb_kv->cache->indexlist == NULL) { return -1; } - ltdb->cache->one_level_indexes = false; - ltdb->cache->attribute_indexes = false; + ldb_kv->cache->one_level_indexes = false; + ldb_kv->cache->attribute_indexes = false; - indexlist_dn = ldb_dn_new(ltdb, ldb, LTDB_INDEXLIST); + indexlist_dn = ldb_dn_new(ldb_kv, ldb, LTDB_INDEXLIST); if (indexlist_dn == NULL) { return -1; } r = ldb_kv_search_dn1(module, indexlist_dn, - ltdb->cache->indexlist, + ldb_kv->cache->indexlist, LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC | LDB_UNPACK_DATA_FLAG_NO_VALUES_ALLOC | LDB_UNPACK_DATA_FLAG_NO_DN); @@ -282,21 +282,21 @@ static int ldb_kv_index_load(struct ldb_module *module, return -1; } - if (ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXONE) != NULL) { - ltdb->cache->one_level_indexes = true; + if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXONE) != NULL) { + ldb_kv->cache->one_level_indexes = true; } - if (ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR) != NULL) { - ltdb->cache->attribute_indexes = true; + if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXATTR) != NULL) { + ldb_kv->cache->attribute_indexes = true; } - ltdb->cache->GUID_index_attribute - = ldb_msg_find_attr_as_string(ltdb->cache->indexlist, + ldb_kv->cache->GUID_index_attribute + = ldb_msg_find_attr_as_string(ldb_kv->cache->indexlist, LTDB_IDXGUID, NULL); - ltdb->cache->GUID_index_dn_component - = ldb_msg_find_attr_as_string(ltdb->cache->indexlist, + ldb_kv->cache->GUID_index_dn_component + = ldb_msg_find_attr_as_string(ldb_kv->cache->indexlist, LTDB_IDX_DN_GUID, NULL); lmdb_subdb_version - = ldb_msg_find_attr_as_int(ltdb->cache->indexlist, + = ldb_msg_find_attr_as_int(ldb_kv->cache->indexlist, LTDB_IDX_LMDB_SUBDB, 0); if (lmdb_subdb_version != 0) { @@ -319,7 +319,7 @@ static int ldb_kv_baseinfo_init(struct ldb_module *module) { struct ldb_context *ldb; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_message *msg; struct ldb_message_element el; struct ldb_val val; @@ -331,9 +331,9 @@ static int ldb_kv_baseinfo_init(struct ldb_module *module) ldb = ldb_module_get_ctx(module); - ltdb->sequence_number = atof(initial_sequence_number); + ldb_kv->sequence_number = atof(initial_sequence_number); - msg = ldb_msg_new(ltdb); + msg = ldb_msg_new(ldb_kv); if (msg == NULL) { goto failed; } @@ -375,11 +375,11 @@ failed: static void ldb_kv_cache_free(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); - ltdb->sequence_number = 0; - talloc_free(ltdb->cache); - ltdb->cache = NULL; + ldb_kv->sequence_number = 0; + talloc_free(ldb_kv->cache); + ldb_kv->cache = NULL; } /* @@ -399,7 +399,7 @@ int ldb_kv_cache_load(struct ldb_module *module) { struct ldb_context *ldb; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL; uint64_t seq; struct ldb_message *baseinfo = NULL, *options = NULL; @@ -410,22 +410,22 @@ int ldb_kv_cache_load(struct ldb_module *module) ldb = ldb_module_get_ctx(module); /* a very fast check to avoid extra database reads */ - if (ltdb->cache != NULL && !ltdb->kv_ops->has_changed(ltdb)) { + if (ldb_kv->cache != NULL && !ldb_kv->kv_ops->has_changed(ldb_kv)) { return 0; } - if (ltdb->cache == NULL) { - ltdb->cache = talloc_zero(ltdb, struct ltdb_cache); - if (ltdb->cache == NULL) goto failed; + if (ldb_kv->cache == NULL) { + ldb_kv->cache = talloc_zero(ldb_kv, struct ltdb_cache); + if (ldb_kv->cache == NULL) goto failed; } - baseinfo = ldb_msg_new(ltdb->cache); + baseinfo = ldb_msg_new(ldb_kv->cache); if (baseinfo == NULL) goto failed; baseinfo_dn = ldb_dn_new(baseinfo, ldb, LTDB_BASEINFO); if (baseinfo_dn == NULL) goto failed; - r = ltdb->kv_ops->lock_read(module); + r = ldb_kv->kv_ops->lock_read(module); if (r != LDB_SUCCESS) { goto failed; } @@ -438,12 +438,12 @@ int ldb_kv_cache_load(struct ldb_module *module) if (r == LDB_ERR_NO_SUCH_OBJECT) { /* Give up the read lock, try again with a write lock */ - r = ltdb->kv_ops->unlock_read(module); + r = ldb_kv->kv_ops->unlock_read(module); if (r != LDB_SUCCESS) { goto failed; } - if (ltdb->kv_ops->begin_write(ltdb) != 0) { + if (ldb_kv->kv_ops->begin_write(ldb_kv) != 0) { goto failed; } @@ -461,19 +461,19 @@ int ldb_kv_cache_load(struct ldb_module *module) } /* Ignore the result, and update the sequence number */ - ltdb->kv_ops->has_changed(ltdb); + ldb_kv->kv_ops->has_changed(ldb_kv); /* if the current internal sequence number is the same as the one in the database then assume the rest of the cache is OK */ seq = ldb_msg_find_attr_as_uint64(baseinfo, LTDB_SEQUENCE_NUMBER, 0); - if (seq == ltdb->sequence_number) { + if (seq == ldb_kv->sequence_number) { goto done; } - ltdb->sequence_number = seq; + ldb_kv->sequence_number = seq; /* Read an interpret database options */ - options = ldb_msg_new(ltdb->cache); + options = ldb_msg_new(ldb_kv->cache); if (options == NULL) goto failed_and_unlock; options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS); @@ -487,15 +487,15 @@ int ldb_kv_cache_load(struct ldb_module *module) /* set flags if they do exist */ if (r == LDB_SUCCESS) { - ltdb->check_base = ldb_msg_find_attr_as_bool(options, + ldb_kv->check_base = ldb_msg_find_attr_as_bool(options, LTDB_CHECK_BASE, false); - ltdb->disallow_dn_filter = ldb_msg_find_attr_as_bool(options, + ldb_kv->disallow_dn_filter = ldb_msg_find_attr_as_bool(options, LTDB_DISALLOW_DN_FILTER, false); } else { - ltdb->check_base = false; - ltdb->disallow_dn_filter = false; + ldb_kv->check_base = false; + ldb_kv->disallow_dn_filter = false; } /* @@ -508,7 +508,7 @@ int ldb_kv_cache_load(struct ldb_module *module) */ ldb_kv_attributes_unload(module); - if (ldb_kv_index_load(module, ltdb) == -1) { + if (ldb_kv_index_load(module, ldb_kv) == -1) { goto failed_and_unlock; } @@ -521,24 +521,24 @@ int ldb_kv_cache_load(struct ldb_module *module) goto failed_and_unlock; } - ltdb->GUID_index_syntax = NULL; - if (ltdb->cache->GUID_index_attribute != NULL) { + ldb_kv->GUID_index_syntax = NULL; + if (ldb_kv->cache->GUID_index_attribute != NULL) { /* * Now the attributes are loaded, set the guid_index_syntax. * This can't fail, it will return a default at worst */ a = ldb_schema_attribute_by_name(ldb, - ltdb->cache->GUID_index_attribute); - ltdb->GUID_index_syntax = a->syntax; + ldb_kv->cache->GUID_index_attribute); + ldb_kv->GUID_index_syntax = a->syntax; } done: if (have_write_txn) { - if (ltdb->kv_ops->finish_write(ltdb) != 0) { + if (ldb_kv->kv_ops->finish_write(ldb_kv) != 0) { goto failed; } } else { - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); } talloc_free(options); @@ -547,9 +547,9 @@ done: failed_and_unlock: if (have_write_txn) { - ltdb->kv_ops->abort_write(ltdb); + ldb_kv->kv_ops->abort_write(ldb_kv); } else { - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); } failed: @@ -566,7 +566,7 @@ int ldb_kv_increase_sequence_number(struct ldb_module *module) { struct ldb_context *ldb; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_message *msg; struct ldb_message_element el[2]; struct ldb_val val; @@ -577,13 +577,13 @@ int ldb_kv_increase_sequence_number(struct ldb_module *module) ldb = ldb_module_get_ctx(module); - msg = ldb_msg_new(ltdb); + msg = ldb_msg_new(ldb_kv); if (msg == NULL) { errno = ENOMEM; return LDB_ERR_OPERATIONS_ERROR; } - s = talloc_asprintf(msg, "%llu", ltdb->sequence_number+1); + s = talloc_asprintf(msg, "%llu", ldb_kv->sequence_number+1); if (!s) { talloc_free(msg); errno = ENOMEM; @@ -634,12 +634,12 @@ int ldb_kv_increase_sequence_number(struct ldb_module *module) talloc_free(msg); if (ret == LDB_SUCCESS) { - ltdb->sequence_number += 1; + ldb_kv->sequence_number += 1; } /* updating the tdb_seqnum here avoids us reloading the cache records due to our own modification */ - ltdb->kv_ops->has_changed(ltdb); + ldb_kv->kv_ops->has_changed(ldb_kv); return ret; } diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index a04431ef7b9..e0a5b62827c 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -174,12 +174,12 @@ static int ldb_kv_write_index_dn_guid(struct ldb_module *module, const struct ldb_message *msg, int add); static int ldb_kv_index_dn_base_dn(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_dn *base_dn, struct dn_list *dn_list, enum key_truncation *truncation); -static void ldb_kv_dn_list_sort(struct ltdb_private *ltdb, +static void ldb_kv_dn_list_sort(struct ldb_kv_private *ldb_kv, struct dn_list *list); /* we put a @IDXVERSION attribute on index entries. This @@ -189,20 +189,20 @@ static void ldb_kv_dn_list_sort(struct ltdb_private *ltdb, #define LTDB_GUID_INDEXING_VERSION 3 -static unsigned ldb_kv_max_key_length(struct ltdb_private *ltdb) +static unsigned ldb_kv_max_key_length(struct ldb_kv_private *ldb_kv) { - if (ltdb->max_key_length == 0){ + if (ldb_kv->max_key_length == 0){ return UINT_MAX; } - return ltdb->max_key_length; + return ldb_kv->max_key_length; } /* enable the idxptr mode when transactions start */ int ldb_kv_index_transaction_start(struct ldb_module *module) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); - ltdb->idxptr = talloc_zero(ltdb, struct ltdb_idxptr); - if (ltdb->idxptr == NULL) { + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); + ldb_kv->idxptr = talloc_zero(ldb_kv, struct ltdb_idxptr); + if (ldb_kv->idxptr == NULL) { return ldb_oom(ldb_module_get_ctx(module)); } @@ -248,14 +248,14 @@ static int ldb_val_equal_exact_ordered(const struct ldb_val v1, This is therefore safe when the value is a GUID in the future */ -static int ldb_kv_dn_list_find_val(struct ltdb_private *ltdb, +static int ldb_kv_dn_list_find_val(struct ldb_kv_private *ldb_kv, const struct dn_list *list, const struct ldb_val *v) { unsigned int i; struct ldb_val *exact = NULL, *next = NULL; - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { for (i=0; icount; i++) { if (ldb_val_equal_exact(&list->dn[i], v) == 1) { return i; @@ -283,25 +283,25 @@ static int ldb_kv_dn_list_find_val(struct ltdb_private *ltdb, find a entry in a dn_list. Uses a case sensitive comparison with the dn returns -1 if not found */ -static int ldb_kv_dn_list_find_msg(struct ltdb_private *ltdb, +static int ldb_kv_dn_list_find_msg(struct ldb_kv_private *ldb_kv, struct dn_list *list, const struct ldb_message *msg) { struct ldb_val v; const struct ldb_val *key_val; - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { const char *dn_str = ldb_dn_get_linearized(msg->dn); v.data = discard_const_p(unsigned char, dn_str); v.length = strlen(dn_str); } else { key_val = ldb_msg_find_ldb_val(msg, - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); if (key_val == NULL) { return -1; } v = *key_val; } - return ldb_kv_dn_list_find_val(ltdb, list, &v); + return ldb_kv_dn_list_find_val(ldb_kv, list, &v); } /* @@ -344,7 +344,7 @@ static struct dn_list *ldb_kv_index_idxptr(struct ldb_module *module, struct dn_list */ static int ldb_kv_dn_list_load(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_dn *dn, struct dn_list *list) { @@ -359,15 +359,15 @@ static int ldb_kv_dn_list_load(struct ldb_module *module, list->count = 0; /* see if we have any in-memory index entries */ - if (ltdb->idxptr == NULL || - ltdb->idxptr->itdb == NULL) { + if (ldb_kv->idxptr == NULL || + ldb_kv->idxptr->itdb == NULL) { goto normal_index; } key.dptr = discard_const_p(unsigned char, ldb_dn_get_linearized(dn)); key.dsize = strlen((char *)key.dptr); - rec = tdb_fetch(ltdb->idxptr->itdb, key); + rec = tdb_fetch(ldb_kv->idxptr->itdb, key); if (rec.dptr == NULL) { goto normal_index; } @@ -413,7 +413,7 @@ normal_index: * asked for the memory to be allocated on msg, not on each * value with LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC above */ - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { /* check indexing version number */ if (version != LTDB_INDEXING_VERSION) { ldb_debug_set(ldb_module_get_ctx(module), @@ -479,7 +479,7 @@ normal_index: } int ldb_kv_key_dn_from_idx(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, TDB_DATA *tdb_key) @@ -494,7 +494,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_kv_index_dn_base_dn(module, ltdb, dn, list, &truncation); + ret = ldb_kv_index_dn_base_dn(module, ldb_kv, dn, list, &truncation); if (ret != LDB_SUCCESS) { TALLOC_FREE(list); return ret; @@ -512,7 +512,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, ": Failed to read DN index " "against %s for %s: too many " "values (%u > 1)", - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, dn_str, list->count); TALLOC_FREE(list); return LDB_ERR_CONSTRAINT_VIOLATION; @@ -539,14 +539,14 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, } ret = ldb_kv_idx_to_key( - module, ltdb, ldb, &list->dn[i], &key); + module, ldb_kv, ldb, &list->dn[i], &key); if (ret != LDB_SUCCESS) { TALLOC_FREE(list); TALLOC_FREE(rec); return ret; } - ret = ldb_kv_search_key(module, ltdb, key, rec, flags); + ret = ldb_kv_search_key(module, ldb_kv, key, rec, flags); if (key.dptr != guid_key) { TALLOC_FREE(key.dptr); } @@ -590,7 +590,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, } /* The tdb_key memory is allocated by the caller */ - ret = ldb_kv_guid_to_key(module, ltdb, &list->dn[index], tdb_key); + ret = ldb_kv_guid_to_key(module, ldb_kv, &list->dn[index], tdb_key); TALLOC_FREE(list); if (ret != LDB_SUCCESS) { @@ -606,7 +606,7 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module, save a dn_list into a full @IDX style record */ static int ldb_kv_dn_list_store_full(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_dn *dn, struct dn_list *list) { @@ -629,7 +629,7 @@ static int ldb_kv_dn_list_store_full(struct ldb_module *module, return ret; } - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { ret = ldb_msg_add_fmt(msg, LTDB_IDXVERSION, "%u", LTDB_INDEXING_VERSION); if (ret != LDB_SUCCESS) { @@ -654,7 +654,7 @@ static int ldb_kv_dn_list_store_full(struct ldb_module *module, return ldb_module_oom(module); } - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { el->values = list->dn; el->num_values = list->count; } else { @@ -704,18 +704,18 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, struct ldb_dn *dn, struct dn_list *list) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); TDB_DATA rec, key; int ret; struct dn_list *list2; - if (ltdb->idxptr == NULL) { - return ldb_kv_dn_list_store_full(module, ltdb, dn, list); + if (ldb_kv->idxptr == NULL) { + return ldb_kv_dn_list_store_full(module, ldb_kv, dn, list); } - if (ltdb->idxptr->itdb == NULL) { - ltdb->idxptr->itdb = tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0); - if (ltdb->idxptr->itdb == NULL) { + if (ldb_kv->idxptr->itdb == NULL) { + ldb_kv->idxptr->itdb = tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0); + if (ldb_kv->idxptr->itdb == NULL) { return LDB_ERR_OPERATIONS_ERROR; } } @@ -726,7 +726,7 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, } key.dsize = strlen((char *)key.dptr); - rec = tdb_fetch(ltdb->idxptr->itdb, key); + rec = tdb_fetch(ldb_kv->idxptr->itdb, key); if (rec.dptr != NULL) { list2 = ldb_kv_index_idxptr(module, rec, false); if (list2 == NULL) { @@ -739,7 +739,7 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, return LDB_SUCCESS; } - list2 = talloc(ltdb->idxptr, struct dn_list); + list2 = talloc(ldb_kv->idxptr, struct dn_list); if (list2 == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -754,9 +754,9 @@ static int ldb_kv_dn_list_store(struct ldb_module *module, * This is not a store into the main DB, but into an in-memory * TDB, so we don't need a guard on ltdb->read_only */ - ret = tdb_store(ltdb->idxptr->itdb, key, rec, TDB_INSERT); + ret = tdb_store(ldb_kv->idxptr->itdb, key, rec, TDB_INSERT); if (ret != 0) { - return ltdb_err_map(tdb_error(ltdb->idxptr->itdb)); + return ltdb_err_map(tdb_error(ldb_kv->idxptr->itdb)); } return LDB_SUCCESS; } @@ -770,7 +770,7 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb, void *state) { struct ldb_module *module = state; - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); struct ldb_dn *dn; struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_val v; @@ -778,7 +778,7 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb, list = ldb_kv_index_idxptr(module, data, true); if (list == NULL) { - ltdb->idxptr->error = LDB_ERR_OPERATIONS_ERROR; + ldb_kv->idxptr->error = LDB_ERR_OPERATIONS_ERROR; return -1; } @@ -788,13 +788,13 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb, dn = ldb_dn_from_ldb_val(module, ldb, &v); if (dn == NULL) { ldb_asprintf_errstring(ldb, "Failed to parse index key %*.*s as an LDB DN", (int)v.length, (int)v.length, (const char *)v.data); - ltdb->idxptr->error = LDB_ERR_OPERATIONS_ERROR; + ldb_kv->idxptr->error = LDB_ERR_OPERATIONS_ERROR; return -1; } - ltdb->idxptr->error = ldb_kv_dn_list_store_full(module, ltdb, dn, list); + ldb_kv->idxptr->error = ldb_kv_dn_list_store_full(module, ldb_kv, dn, list); talloc_free(dn); - if (ltdb->idxptr->error != 0) { + if (ldb_kv->idxptr->error != 0) { return -1; } return 0; @@ -803,20 +803,20 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb, /* cleanup the idxptr mode when transaction commits */ int ldb_kv_index_transaction_commit(struct ldb_module *module) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_reset_err_string(ldb); - if (ltdb->idxptr->itdb) { + if (ldb_kv->idxptr->itdb) { tdb_traverse( - ltdb->idxptr->itdb, ldb_kv_index_traverse_store, module); - tdb_close(ltdb->idxptr->itdb); + ldb_kv->idxptr->itdb, ldb_kv_index_traverse_store, module); + tdb_close(ldb_kv->idxptr->itdb); } - ret = ltdb->idxptr->error; + ret = ldb_kv->idxptr->error; if (ret != LDB_SUCCESS) { if (!ldb_errstring(ldb)) { ldb_set_errstring(ldb, ldb_strerror(ret)); @@ -824,20 +824,20 @@ int ldb_kv_index_transaction_commit(struct ldb_module *module) ldb_asprintf_errstring(ldb, "Failed to store index records in transaction commit: %s", ldb_errstring(ldb)); } - talloc_free(ltdb->idxptr); - ltdb->idxptr = NULL; + talloc_free(ldb_kv->idxptr); + ldb_kv->idxptr = NULL; return ret; } /* cleanup the idxptr mode when transaction cancels */ int ldb_kv_index_transaction_cancel(struct ldb_module *module) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); - if (ltdb->idxptr && ltdb->idxptr->itdb) { - tdb_close(ltdb->idxptr->itdb); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); + if (ldb_kv->idxptr && ldb_kv->idxptr->itdb) { + tdb_close(ldb_kv->idxptr->itdb); } - talloc_free(ltdb->idxptr); - ltdb->idxptr = NULL; + talloc_free(ldb_kv->idxptr); + ldb_kv->idxptr = NULL; return LDB_SUCCESS; } @@ -847,7 +847,7 @@ int ldb_kv_index_transaction_cancel(struct ldb_module *module) the caller is responsible for freeing */ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const char *attr, const struct ldb_val *value, const struct ldb_schema_attribute **ap, @@ -861,7 +861,7 @@ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb, int r; bool should_b64_encode; - unsigned int max_key_length = ldb_kv_max_key_length(ltdb); + unsigned int max_key_length = ldb_kv_max_key_length(ldb_kv); size_t key_len = 0; size_t attr_len = 0; const size_t indx_len = sizeof(LTDB_INDEX) - 1; @@ -937,7 +937,7 @@ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb, * casefold and lineraized, that is good enough. That already * avoids embedded NUL etc. */ - if (ltdb->cache->GUID_index_attribute != NULL) { + if (ldb_kv->cache->GUID_index_attribute != NULL) { if (strcmp(attr, LTDB_IDXDN) == 0) { should_b64_encode = false; } else if (strcmp(attr, LTDB_IDXONE) == 0) { @@ -1033,16 +1033,16 @@ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb, see if a attribute value is in the list of indexed attributes */ static bool ldb_kv_is_indexed(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const char *attr) { struct ldb_context *ldb = ldb_module_get_ctx(module); unsigned int i; struct ldb_message_element *el; - if ((ltdb->cache->GUID_index_attribute != NULL) && + if ((ldb_kv->cache->GUID_index_attribute != NULL) && (ldb_attr_cmp(attr, - ltdb->cache->GUID_index_attribute) == 0)) { + ldb_kv->cache->GUID_index_attribute) == 0)) { /* Implicity covered, this is the index key */ return false; } @@ -1061,11 +1061,11 @@ static bool ldb_kv_is_indexed(struct ldb_module *module, } } - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { return false; } - el = ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR); + el = ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXATTR); if (el == NULL) { return false; } @@ -1096,7 +1096,7 @@ static bool ldb_kv_is_indexed(struct ldb_module *module, equality search only) */ static int ldb_kv_index_dn_simple(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { @@ -1112,14 +1112,14 @@ static int ldb_kv_index_dn_simple(struct ldb_module *module, /* if the attribute isn't in the list of indexed attributes then this node needs a full search */ - if (!ldb_kv_is_indexed(module, ltdb, tree->u.equality.attr)) { + if (!ldb_kv_is_indexed(module, ldb_kv, tree->u.equality.attr)) { return LDB_ERR_OPERATIONS_ERROR; } /* the attribute is indexed. Pull the list of DNs that match the search criterion */ dn = ldb_kv_index_key(ldb, - ltdb, + ldb_kv, tree->u.equality.attr, &tree->u.equality.value, NULL, @@ -1131,25 +1131,25 @@ static int ldb_kv_index_dn_simple(struct ldb_module *module, */ if (!dn) return LDB_ERR_OPERATIONS_ERROR; - ret = ldb_kv_dn_list_load(module, ltdb, dn, list); + ret = ldb_kv_dn_list_load(module, ldb_kv, dn, list); talloc_free(dn); return ret; } static bool list_union(struct ldb_context *ldb, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct dn_list *list, struct dn_list *list2); /* return a list of dn's that might match a leaf indexed search */ static int ldb_kv_index_dn_leaf(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { - if (ltdb->disallow_dn_filter && + if (ldb_kv->disallow_dn_filter && (ldb_attr_cmp(tree->u.equality.attr, "dn") == 0)) { /* in AD mode we do not support "(dn=...)" search filters */ list->dn = NULL; @@ -1183,16 +1183,16 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module, * to list for the memory to remain valid. */ return ldb_kv_index_dn_base_dn( - module, ltdb, dn, list, &truncation); + module, ldb_kv, dn, list, &truncation); /* * We ignore truncation here and allow multi-valued matches * as ltdb_search_indexed will filter out the wrong one in * ltdb_index_filter() which calls ldb_match_message(). */ - } else if ((ltdb->cache->GUID_index_attribute != NULL) && + } else if ((ldb_kv->cache->GUID_index_attribute != NULL) && (ldb_attr_cmp(tree->u.equality.attr, - ltdb->cache->GUID_index_attribute) == 0)) { + ldb_kv->cache->GUID_index_attribute) == 0)) { int ret; struct ldb_context *ldb = ldb_module_get_ctx(module); list->dn = talloc_array(list, struct ldb_val, 1); @@ -1205,7 +1205,7 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module, * ensure we get the index in binary, rather * than a string */ - ret = ltdb->GUID_index_syntax->canonicalise_fn(ldb, + ret = ldb_kv->GUID_index_syntax->canonicalise_fn(ldb, list->dn, &tree->u.equality.value, &list->dn[0]); @@ -1216,7 +1216,7 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module, return LDB_SUCCESS; } - return ldb_kv_index_dn_simple(module, ltdb, tree, list); + return ldb_kv_index_dn_simple(module, ldb_kv, tree, list); } @@ -1225,7 +1225,7 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module, list = list & list2 */ static bool list_intersect(struct ldb_context *ldb, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct dn_list *list, const struct dn_list *list2) { const struct dn_list *short_list, *long_list; @@ -1285,7 +1285,7 @@ static bool list_intersect(struct ldb_context *ldb, for (i=0;icount;i++) { /* For the GUID index case, this is a binary search */ if (ldb_kv_dn_list_find_val( - ltdb, long_list, &short_list->dn[i]) != -1) { + ldb_kv, long_list, &short_list->dn[i]) != -1) { list3->dn[list3->count] = short_list->dn[i]; list3->count++; } @@ -1305,7 +1305,7 @@ static bool list_intersect(struct ldb_context *ldb, list = list | list2 */ static bool list_union(struct ldb_context *ldb, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct dn_list *list, struct dn_list *list2) { struct ldb_val *dn3; @@ -1335,8 +1335,8 @@ static bool list_union(struct ldb_context *ldb, * NOTE: This can sort the in-memory index values, as list or * list2 might not be a copy! */ - ldb_kv_dn_list_sort(ltdb, list); - ldb_kv_dn_list_sort(ltdb, list2); + ldb_kv_dn_list_sort(ldb_kv, list); + ldb_kv_dn_list_sort(ldb_kv, list2); dn3 = talloc_array(list, struct ldb_val, list->count + list2->count); if (!dn3) { @@ -1381,7 +1381,7 @@ static bool list_union(struct ldb_context *ldb, } static int ldb_kv_index_dn(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list); @@ -1389,7 +1389,7 @@ static int ldb_kv_index_dn(struct ldb_module *module, process an OR list (a union) */ static int ldb_kv_index_dn_or(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { @@ -1411,7 +1411,7 @@ static int ldb_kv_index_dn_or(struct ldb_module *module, } ret = ldb_kv_index_dn( - module, ltdb, tree->u.list.elements[i], list2); + module, ldb_kv, tree->u.list.elements[i], list2); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* X || 0 == X */ @@ -1425,7 +1425,7 @@ static int ldb_kv_index_dn_or(struct ldb_module *module, return ret; } - if (!list_union(ldb, ltdb, list, list2)) { + if (!list_union(ldb, ldb_kv, list, list2)) { talloc_free(list2); return LDB_ERR_OPERATIONS_ERROR; } @@ -1443,7 +1443,7 @@ static int ldb_kv_index_dn_or(struct ldb_module *module, NOT an index results */ static int ldb_kv_index_dn_not(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { @@ -1463,12 +1463,12 @@ static int ldb_kv_index_dn_not(struct ldb_module *module, * by GUID, DN or a unique attribute */ static bool ldb_kv_index_unique(struct ldb_context *ldb, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const char *attr) { const struct ldb_schema_attribute *a; - if (ltdb->cache->GUID_index_attribute != NULL) { - if (ldb_attr_cmp(attr, ltdb->cache->GUID_index_attribute) == 0) { + if (ldb_kv->cache->GUID_index_attribute != NULL) { + if (ldb_attr_cmp(attr, ldb_kv->cache->GUID_index_attribute) == 0) { return true; } } @@ -1487,7 +1487,7 @@ static bool ldb_kv_index_unique(struct ldb_context *ldb, process an AND expression (intersection) */ static int ldb_kv_index_dn_and(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { @@ -1508,11 +1508,11 @@ static int ldb_kv_index_dn_and(struct ldb_module *module, int ret; if (subtree->operation != LDB_OP_EQUALITY || - !ldb_kv_index_unique(ldb, ltdb, subtree->u.equality.attr)) { + !ldb_kv_index_unique(ldb, ldb_kv, subtree->u.equality.attr)) { continue; } - ret = ldb_kv_index_dn(module, ltdb, subtree, list); + ret = ldb_kv_index_dn(module, ldb_kv, subtree, list); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* 0 && X == 0 */ return LDB_ERR_NO_SUCH_OBJECT; @@ -1539,7 +1539,7 @@ static int ldb_kv_index_dn_and(struct ldb_module *module, return ldb_module_oom(module); } - ret = ldb_kv_index_dn(module, ltdb, subtree, list2); + ret = ldb_kv_index_dn(module, ldb_kv, subtree, list2); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* X && 0 == 0 */ @@ -1560,7 +1560,7 @@ static int ldb_kv_index_dn_and(struct ldb_module *module, list->dn = list2->dn; list->count = list2->count; found = true; - } else if (!list_intersect(ldb, ltdb, + } else if (!list_intersect(ldb, ldb_kv, list, list2)) { talloc_free(list2); return LDB_ERR_OPERATIONS_ERROR; @@ -1589,7 +1589,7 @@ static int ldb_kv_index_dn_and(struct ldb_module *module, return a list of matching objects using a one-level index */ static int ldb_kv_index_dn_attr(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const char *attr, struct ldb_dn *dn, struct dn_list *list, @@ -1605,13 +1605,13 @@ static int ldb_kv_index_dn_attr(struct ldb_module *module, /* work out the index key from the parent DN */ val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(dn)); val.length = strlen((char *)val.data); - key = ldb_kv_index_key(ldb, ltdb, attr, &val, NULL, truncation); + key = ldb_kv_index_key(ldb, ldb_kv, attr, &val, NULL, truncation); if (!key) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_kv_dn_list_load(module, ltdb, key, list); + ret = ldb_kv_dn_list_load(module, ldb_kv, key, list); talloc_free(key); if (ret != LDB_SUCCESS) { return ret; @@ -1628,7 +1628,7 @@ static int ldb_kv_index_dn_attr(struct ldb_module *module, return a list of matching objects using a one-level index */ static int ldb_kv_index_dn_one(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_dn *parent_dn, struct dn_list *list, enum key_truncation *truncation) @@ -1636,20 +1636,20 @@ static int ldb_kv_index_dn_one(struct ldb_module *module, /* Ensure we do not shortcut on intersection for this list */ list->strict = true; return ldb_kv_index_dn_attr( - module, ltdb, LTDB_IDXONE, parent_dn, list, truncation); + module, ldb_kv, LTDB_IDXONE, parent_dn, list, truncation); } /* return a list of matching objects using the DN index */ static int ldb_kv_index_dn_base_dn(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_dn *base_dn, struct dn_list *dn_list, enum key_truncation *truncation) { const struct ldb_val *guid_val = NULL; - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { dn_list->dn = talloc_array(dn_list, struct ldb_val, 1); if (dn_list->dn == NULL) { return ldb_module_oom(module); @@ -1665,9 +1665,9 @@ static int ldb_kv_index_dn_base_dn(struct ldb_module *module, return LDB_SUCCESS; } - if (ltdb->cache->GUID_index_dn_component != NULL) { + if (ldb_kv->cache->GUID_index_dn_component != NULL) { guid_val = ldb_dn_get_extended_component(base_dn, - ltdb->cache->GUID_index_dn_component); + ldb_kv->cache->GUID_index_dn_component); } if (guid_val != NULL) { @@ -1683,7 +1683,7 @@ static int ldb_kv_index_dn_base_dn(struct ldb_module *module, } return ldb_kv_index_dn_attr( - module, ltdb, LTDB_IDXDN, base_dn, dn_list, truncation); + module, ldb_kv, LTDB_IDXDN, base_dn, dn_list, truncation); } /* @@ -1691,7 +1691,7 @@ static int ldb_kv_index_dn_base_dn(struct ldb_module *module, an error. return LDB_ERR_NO_SUCH_OBJECT for no matches, or LDB_SUCCESS for matches */ static int ldb_kv_index_dn(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_parse_tree *tree, struct dn_list *list) { @@ -1699,19 +1699,19 @@ static int ldb_kv_index_dn(struct ldb_module *module, switch (tree->operation) { case LDB_OP_AND: - ret = ldb_kv_index_dn_and(module, ltdb, tree, list); + ret = ldb_kv_index_dn_and(module, ldb_kv, tree, list); break; case LDB_OP_OR: - ret = ldb_kv_index_dn_or(module, ltdb, tree, list); + ret = ldb_kv_index_dn_or(module, ldb_kv, tree, list); break; case LDB_OP_NOT: - ret = ldb_kv_index_dn_not(module, ltdb, tree, list); + ret = ldb_kv_index_dn_not(module, ldb_kv, tree, list); break; case LDB_OP_EQUALITY: - ret = ldb_kv_index_dn_leaf(module, ltdb, tree, list); + ret = ldb_kv_index_dn_leaf(module, ldb_kv, tree, list); break; case LDB_OP_SUBSTRING: @@ -1732,7 +1732,7 @@ static int ldb_kv_index_dn(struct ldb_module *module, filter a candidate dn_list from an indexed search into a set of results extracting just the given attributes */ -static int ldb_kv_index_filter(struct ltdb_private *ltdb, +static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv, const struct dn_list *dn_list, struct ldb_kv_context *ac, uint32_t *match_count, @@ -1757,7 +1757,7 @@ static int ldb_kv_index_filter(struct ltdb_private *ltdb, return ldb_module_oom(ac->module); } - if (ltdb->cache->GUID_index_attribute != NULL) { + if (ldb_kv->cache->GUID_index_attribute != NULL) { /* * We speculate that the keys will be GUID based and so * pre-fill in enough space for a GUID (avoiding a pile of @@ -1790,13 +1790,13 @@ static int ldb_kv_index_filter(struct ltdb_private *ltdb, int ret; ret = ldb_kv_idx_to_key( - ac->module, ltdb, keys, &dn_list->dn[i], &keys[num_keys]); + ac->module, ldb_kv, keys, &dn_list->dn[i], &keys[num_keys]); if (ret != LDB_SUCCESS) { talloc_free(keys); return ret; } - if (ltdb->cache->GUID_index_attribute != NULL) { + if (ldb_kv->cache->GUID_index_attribute != NULL) { /* * If we are in GUID index mode, then the dn_list is * sorted. If we got a duplicate, forget about it, as @@ -1836,7 +1836,7 @@ static int ldb_kv_index_filter(struct ltdb_private *ltdb, ret = ldb_kv_search_key(ac->module, - ltdb, + ldb_kv, keys[i], msg, LDB_UNPACK_DATA_FLAG_NO_DATA_ALLOC | @@ -1866,7 +1866,7 @@ static int ldb_kv_index_filter(struct ltdb_private *ltdb, * LDB_SCOPE_BASE is not passed in by our only caller. */ if (ac->scope == LDB_SCOPE_ONELEVEL - && ltdb->cache->one_level_indexes + && ldb_kv->cache->one_level_indexes && scope_one_truncation == KEY_NOT_TRUNCATED) { ret = ldb_match_message(ldb, msg, ac->tree, ac->scope, &matched); @@ -1916,7 +1916,7 @@ static int ldb_kv_index_filter(struct ltdb_private *ltdb, /* sort a DN list */ -static void ldb_kv_dn_list_sort(struct ltdb_private *ltdb, struct dn_list *list) +static void ldb_kv_dn_list_sort(struct ldb_kv_private *ltdb, struct dn_list *list) { if (list->count < 2) { return; @@ -1939,15 +1939,15 @@ static void ldb_kv_dn_list_sort(struct ltdb_private *ltdb, struct dn_list *list) int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) { struct ldb_context *ldb = ldb_module_get_ctx(ac->module); - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(ac->module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(ac->module), struct ldb_kv_private); struct dn_list *dn_list; int ret; enum ldb_scope index_scope; enum key_truncation scope_one_truncation = KEY_NOT_TRUNCATED; /* see if indexing is enabled */ - if (!ltdb->cache->attribute_indexes && - !ltdb->cache->one_level_indexes && + if (!ldb_kv->cache->attribute_indexes && + !ldb_kv->cache->one_level_indexes && ac->scope != LDB_SCOPE_BASE) { /* fallback to a full search */ return LDB_ERR_OPERATIONS_ERROR; @@ -1964,7 +1964,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * search */ if (ac->scope == LDB_SCOPE_ONELEVEL && - !ltdb->cache->one_level_indexes) { + !ldb_kv->cache->one_level_indexes) { index_scope = LDB_SCOPE_SUBTREE; } else { index_scope = ac->scope; @@ -1985,7 +1985,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * this list, as we trust the ONELEVEL index */ ret = ldb_kv_index_dn_one( - ac->module, ltdb, ac->base, dn_list, &scope_one_truncation); + ac->module, ldb_kv, ac->base, dn_list, &scope_one_truncation); if (ret != LDB_SUCCESS) { talloc_free(dn_list); return ret; @@ -2004,14 +2004,14 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * do it always and rely on the index lookup being * fast enough in the small case. */ - if (ltdb->cache->GUID_index_attribute != NULL) { + if (ldb_kv->cache->GUID_index_attribute != NULL) { struct dn_list *idx_one_tree_list = talloc_zero(ac, struct dn_list); if (idx_one_tree_list == NULL) { return ldb_module_oom(ac->module); } - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { talloc_free(idx_one_tree_list); talloc_free(dn_list); return LDB_ERR_OPERATIONS_ERROR; @@ -2024,9 +2024,9 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * the ONELEVEL index is still good enough. */ ret = ldb_kv_index_dn( - ac->module, ltdb, ac->tree, idx_one_tree_list); + ac->module, ldb_kv, ac->tree, idx_one_tree_list); if (ret == LDB_SUCCESS) { - if (!list_intersect(ldb, ltdb, + if (!list_intersect(ldb, ldb_kv, dn_list, idx_one_tree_list)) { talloc_free(idx_one_tree_list); @@ -2039,7 +2039,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) case LDB_SCOPE_SUBTREE: case LDB_SCOPE_DEFAULT: - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { talloc_free(dn_list); return LDB_ERR_OPERATIONS_ERROR; } @@ -2047,7 +2047,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * Here we load the index for the tree. We have no * index for the subtree. */ - ret = ldb_kv_index_dn(ac->module, ltdb, ac->tree, dn_list); + ret = ldb_kv_index_dn(ac->module, ldb_kv, ac->tree, dn_list); if (ret != LDB_SUCCESS) { talloc_free(dn_list); return ret; @@ -2067,7 +2067,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * SCOPE_ONELEVEL index. */ ret = ldb_kv_index_filter( - ltdb, dn_list, ac, match_count, scope_one_truncation); + ldb_kv, dn_list, ac, match_count, scope_one_truncation); talloc_free(dn_list); return ret; } @@ -2093,7 +2093,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count) * @return An ldb error code */ static int ldb_kv_index_add1(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el, int v_idx) @@ -2115,7 +2115,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, } dn_key = ldb_kv_index_key( - ldb, ltdb, el->name, &el->values[v_idx], &a, &truncation); + ldb, ldb_kv, el->name, &el->values[v_idx], &a, &truncation); if (!dn_key) { talloc_free(list); return LDB_ERR_OPERATIONS_ERROR; @@ -2135,13 +2135,13 @@ static int ldb_kv_index_add1(struct ldb_module *module, "exceeds maximum key length of %u (encoded).", el->name, ldb_dn_get_linearized(msg->dn), - ltdb->max_key_length); + ldb_kv->max_key_length); talloc_free(list); return LDB_ERR_CONSTRAINT_VIOLATION; } talloc_steal(list, dn_key); - ret = ldb_kv_dn_list_load(module, ltdb, dn_key, list); + ret = ldb_kv_dn_list_load(module, ldb_kv, dn_key, list); if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) { talloc_free(list); return ret; @@ -2184,14 +2184,14 @@ static int ldb_kv_index_add1(struct ldb_module *module, } ret = ldb_kv_idx_to_key( - module, ltdb, ldb, &list->dn[i], &key); + module, ldb_kv, ldb, &list->dn[i], &key); if (ret != LDB_SUCCESS) { TALLOC_FREE(list); TALLOC_FREE(rec); return ret; } - ret = ldb_kv_search_key(module, ltdb, key, rec, flags); + ret = ldb_kv_search_key(module, ldb_kv, key, rec, flags); if (key.dptr != guid_key) { TALLOC_FREE(key.dptr); } @@ -2239,7 +2239,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, * user-visible error string */ - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { ldb_debug(ldb, LDB_DEBUG_WARNING, __location__ ": unique index violation on %s in %s, " @@ -2254,7 +2254,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, const struct ldb_schema_attribute *attr = ldb_schema_attribute_by_name( ldb, - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); struct ldb_val v; ret = attr->syntax->ldif_write_fn(ldb, list, &list->dn[0], &v); @@ -2265,7 +2265,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, "%s, conficts with %s %*.*s in %s", el->name, ldb_dn_get_linearized(msg->dn), - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, (int)v.length, (int)v.length, v.data, @@ -2290,7 +2290,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { const char *dn_str = ldb_dn_get_linearized(msg->dn); list->dn[list->count].data = (uint8_t *)talloc_strdup(list->dn, dn_str); @@ -2303,7 +2303,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, const struct ldb_val *key_val; struct ldb_val *exact = NULL, *next = NULL; key_val = ldb_msg_find_ldb_val(msg, - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); if (key_val == NULL) { talloc_free(list); return ldb_module_operr(module); @@ -2329,7 +2329,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, const struct ldb_schema_attribute *attr = ldb_schema_attribute_by_name( ldb, - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); struct ldb_val v; ret = attr->syntax->ldif_write_fn(ldb, list, exact, &v); @@ -2341,7 +2341,7 @@ static int ldb_kv_index_add1(struct ldb_module *module, "duplicate of %s %*.*s in %s", ldb_dn_get_linearized(msg->dn), el->name, - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, (int)v.length, (int)v.length, v.data, @@ -2374,13 +2374,13 @@ static int ldb_kv_index_add1(struct ldb_module *module, add index entries for one elements in a message */ static int ldb_kv_index_add_el(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el) { unsigned int i; for (i = 0; i < el->num_values; i++) { - int ret = ldb_kv_index_add1(module, ltdb, msg, el, i); + int ret = ldb_kv_index_add1(module, ldb_kv, msg, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -2393,7 +2393,7 @@ static int ldb_kv_index_add_el(struct ldb_module *module, add index entries for all elements in a message */ static int ldb_kv_index_add_all(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg) { struct ldb_message_element *elements = msg->elements; @@ -2415,16 +2415,16 @@ static int ldb_kv_index_add_all(struct ldb_module *module, return ret; } - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { /* no indexed fields */ return LDB_SUCCESS; } for (i = 0; i < msg->num_elements; i++) { - if (!ldb_kv_is_indexed(module, ltdb, elements[i].name)) { + if (!ldb_kv_is_indexed(module, ldb_kv, elements[i].name)) { continue; } - ret = ldb_kv_index_add_el(module, ltdb, msg, &elements[i]); + ret = ldb_kv_index_add_el(module, ldb_kv, msg, &elements[i]); if (ret != LDB_SUCCESS) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, @@ -2443,7 +2443,7 @@ static int ldb_kv_index_add_all(struct ldb_module *module, insert a DN index for a message */ static int ldb_kv_modify_index_dn(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_dn *dn, const char *index, @@ -2462,7 +2462,7 @@ static int ldb_kv_modify_index_dn(struct ldb_module *module, "against %s in %s: failed " "to get casefold DN", index, - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, dn_str); return LDB_ERR_OPERATIONS_ERROR; } @@ -2473,9 +2473,9 @@ static int ldb_kv_modify_index_dn(struct ldb_module *module, el.num_values = 1; if (add) { - ret = ldb_kv_index_add1(module, ltdb, msg, &el, 0); + ret = ldb_kv_index_add1(module, ldb_kv, msg, &el, 0); } else { /* delete */ - ret = ldb_kv_index_del_value(module, ltdb, msg, &el, 0); + ret = ldb_kv_index_del_value(module, ldb_kv, msg, &el, 0); } if (ret != LDB_SUCCESS) { @@ -2486,7 +2486,7 @@ static int ldb_kv_modify_index_dn(struct ldb_module *module, ": Failed to modify %s " "against %s in %s - %s", index, - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, dn_str, ldb_errstring(ldb)); return ret; } @@ -2500,13 +2500,13 @@ static int ldb_kv_index_onelevel(struct ldb_module *module, const struct ldb_message *msg, int add) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), - struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), + struct ldb_kv_private); struct ldb_dn *pdn; int ret; /* We index for ONE Level only if requested */ - if (!ltdb->cache->one_level_indexes) { + if (!ldb_kv->cache->one_level_indexes) { return LDB_SUCCESS; } @@ -2514,7 +2514,7 @@ static int ldb_kv_index_onelevel(struct ldb_module *module, if (pdn == NULL) { return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_kv_modify_index_dn(module, ltdb, msg, pdn, LTDB_IDXONE, add); + ret = ldb_kv_modify_index_dn(module, ldb_kv, msg, pdn, LTDB_IDXONE, add); talloc_free(pdn); @@ -2529,16 +2529,16 @@ static int ldb_kv_write_index_dn_guid(struct ldb_module *module, int add) { int ret; - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), - struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), + struct ldb_kv_private); /* We index for DN only if using a GUID index */ - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { return LDB_SUCCESS; } ret = - ldb_kv_modify_index_dn(module, ltdb, msg, msg->dn, LTDB_IDXDN, add); + ldb_kv_modify_index_dn(module, ldb_kv, msg, msg->dn, LTDB_IDXDN, add); if (ret == LDB_ERR_CONSTRAINT_VIOLATION) { ldb_asprintf_errstring(ldb_module_get_ctx(module), @@ -2554,24 +2554,24 @@ static int ldb_kv_write_index_dn_guid(struct ldb_module *module, The caller guarantees that these element values are not yet indexed */ int ldb_kv_index_add_element(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el) { if (ldb_dn_is_special(msg->dn)) { return LDB_SUCCESS; } - if (!ldb_kv_is_indexed(module, ltdb, el->name)) { + if (!ldb_kv_is_indexed(module, ldb_kv, el->name)) { return LDB_SUCCESS; } - return ldb_kv_index_add_el(module, ltdb, msg, el); + return ldb_kv_index_add_el(module, ldb_kv, msg, el); } /* add the index entries for a new record */ int ldb_kv_index_add_new(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg) { int ret; @@ -2580,7 +2580,7 @@ int ldb_kv_index_add_new(struct ldb_module *module, return LDB_SUCCESS; } - ret = ldb_kv_index_add_all(module, ltdb, msg); + ret = ldb_kv_index_add_all(module, ldb_kv, msg); if (ret != LDB_SUCCESS) { /* * Because we can't trust the caller to be doing @@ -2612,7 +2612,7 @@ int ldb_kv_index_add_new(struct ldb_module *module, delete an index entry for one message element */ int ldb_kv_index_del_value(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el, unsigned int v_idx) @@ -2638,7 +2638,7 @@ int ldb_kv_index_del_value(struct ldb_module *module, } dn_key = ldb_kv_index_key( - ldb, ltdb, el->name, &el->values[v_idx], NULL, &truncation); + ldb, ldb_kv, el->name, &el->values[v_idx], NULL, &truncation); /* * We ignore key truncation in ltdb_index_add1() so * match that by ignoring it here as well @@ -2655,7 +2655,7 @@ int ldb_kv_index_del_value(struct ldb_module *module, return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_kv_dn_list_load(module, ltdb, dn_key, list); + ret = ldb_kv_dn_list_load(module, ldb_kv, dn_key, list); if (ret == LDB_ERR_NO_SUCH_OBJECT) { /* it wasn't indexed. Did we have an earlier error? If we did then its gone now */ @@ -2671,7 +2671,7 @@ int ldb_kv_index_del_value(struct ldb_module *module, /* * Find one of the values matching this message to remove */ - i = ldb_kv_dn_list_find_msg(ltdb, list, msg); + i = ldb_kv_dn_list_find_msg(ldb_kv, list, msg); if (i == -1) { /* nothing to delete */ talloc_free(dn_key); @@ -2702,7 +2702,7 @@ int ldb_kv_index_del_value(struct ldb_module *module, return -1 on failure */ int ldb_kv_index_del_element(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el) { @@ -2710,7 +2710,7 @@ int ldb_kv_index_del_element(struct ldb_module *module, int ret; unsigned int i; - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { /* no indexed fields */ return LDB_SUCCESS; } @@ -2724,11 +2724,11 @@ int ldb_kv_index_del_element(struct ldb_module *module, return LDB_SUCCESS; } - if (!ldb_kv_is_indexed(module, ltdb, el->name)) { + if (!ldb_kv_is_indexed(module, ldb_kv, el->name)) { return LDB_SUCCESS; } for (i = 0; i < el->num_values; i++) { - ret = ldb_kv_index_del_value(module, ltdb, msg, el, i); + ret = ldb_kv_index_del_value(module, ldb_kv, msg, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -2744,7 +2744,7 @@ int ldb_kv_index_del_element(struct ldb_module *module, int ldb_kv_index_delete(struct ldb_module *module, const struct ldb_message *msg) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); int ret; unsigned int i; @@ -2762,14 +2762,14 @@ int ldb_kv_index_delete(struct ldb_module *module, return ret; } - if (!ltdb->cache->attribute_indexes) { + if (!ldb_kv->cache->attribute_indexes) { /* no indexed fields */ return LDB_SUCCESS; } for (i = 0; i < msg->num_elements; i++) { ret = ldb_kv_index_del_element( - module, ltdb, msg, &msg->elements[i]); + module, ldb_kv, msg, &msg->elements[i]); if (ret != LDB_SUCCESS) { return ret; } @@ -2787,7 +2787,7 @@ int ldb_kv_index_delete(struct ldb_module *module, commit, which in turn greatly reduces DB churn as we will likely be able to do a direct update into the old record. */ -static int delete_index(struct ltdb_private *ltdb, struct ldb_val key, struct ldb_val data, void *state) +static int delete_index(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, void *state) { struct ldb_module *module = state; const char *dnstr = "DN=" LTDB_INDEX ":"; @@ -2808,7 +2808,7 @@ static int delete_index(struct ltdb_private *ltdb, struct ldb_val key, struct ld v.data = key.data + 3; v.length = strnlen((char *)key.data, key.length) - 3; - dn = ldb_dn_from_ldb_val(ltdb, ldb_module_get_ctx(module), &v); + dn = ldb_dn_from_ldb_val(ldb_kv, ldb_module_get_ctx(module), &v); /* * This does not actually touch the DB quite yet, just @@ -2829,7 +2829,7 @@ static int delete_index(struct ltdb_private *ltdb, struct ldb_val key, struct ld /* traversal function that adds @INDEX records during a re index TODO wrong comment */ -static int re_key(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ldb_val val, void *state) +static int re_key(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val val, void *state) { struct ldb_context *ldb; struct ldb_kv_reindex_context *ctx = @@ -2902,7 +2902,7 @@ static int re_key(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ldb_ .data = key2.dptr, .length = key2.dsize }; - ltdb->kv_ops->update_in_iterate(ltdb, ldb_key, ldb_key2, val, ctx); + ldb_kv->kv_ops->update_in_iterate(ldb_kv, ldb_key, ldb_key2, val, ctx); } talloc_free(key2.dptr); @@ -2921,7 +2921,7 @@ static int re_key(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ldb_ /* traversal function that adds @INDEX records during a re index */ -static int re_index(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ldb_val val, void *state) +static int re_index(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val val, void *state) { struct ldb_context *ldb; struct ldb_kv_reindex_context *ctx = @@ -2985,7 +2985,7 @@ static int re_index(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ld return -1; } - ret = ldb_kv_index_add_all(module, ltdb, msg); + ret = ldb_kv_index_add_all(module, ldb_kv, msg); if (ret != LDB_SUCCESS) { ctx->error = ret; @@ -3010,7 +3010,7 @@ static int re_index(struct ltdb_private *ltdb, struct ldb_val ldb_key, struct ld */ int ldb_kv_reindex(struct ldb_module *module) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); int ret; struct ldb_kv_reindex_context ctx; @@ -3018,7 +3018,7 @@ int ldb_kv_reindex(struct ldb_module *module) * Only triggered after a modification, but make clear we do * not re-index a read-only DB */ - if (ltdb->read_only) { + if (ldb_kv->read_only) { return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -3041,7 +3041,7 @@ int ldb_kv_reindex(struct ldb_module *module) /* first traverse the database deleting any @INDEX records by * putting NULL entries in the in-memory tdb */ - ret = ltdb->kv_ops->iterate(ltdb, delete_index, module); + ret = ldb_kv->kv_ops->iterate(ldb_kv, delete_index, module); if (ret < 0) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, "index deletion traverse failed: %s", @@ -3053,7 +3053,7 @@ int ldb_kv_reindex(struct ldb_module *module) ctx.error = 0; ctx.count = 0; - ret = ltdb->kv_ops->iterate(ltdb, re_key, &ctx); + ret = ldb_kv->kv_ops->iterate(ldb_kv, re_key, &ctx); if (ret < 0) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, "key correction traverse failed: %s", @@ -3071,7 +3071,7 @@ int ldb_kv_reindex(struct ldb_module *module) ctx.count = 0; /* now traverse adding any indexes for normal LDB records */ - ret = ltdb->kv_ops->iterate(ltdb, re_index, &ctx); + ret = ldb_kv->kv_ops->iterate(ldb_kv, re_index, &ctx); if (ret < 0) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, "reindexing traverse failed: %s", @@ -3089,7 +3089,7 @@ int ldb_kv_reindex(struct ldb_module *module) ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_WARNING, "Reindexing: re_index successful on %s, " "final index write-out will be in transaction commit", - ltdb->kv_ops->name(ltdb)); + ldb_kv->kv_ops->name(ldb_kv)); } return LDB_SUCCESS; } diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c index 77938b77e56..fd8b64ef1b7 100644 --- a/lib/ldb/ldb_tdb/ldb_search.c +++ b/lib/ldb/ldb_tdb/ldb_search.c @@ -235,7 +235,7 @@ static int ldb_kv_parse_data_unpack(struct ldb_val key, and LDB_SUCCESS on success */ int ldb_kv_search_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct TDB_DATA tdb_key, struct ldb_message *msg, unsigned int unpack_flags) @@ -256,11 +256,11 @@ int ldb_kv_search_key(struct ldb_module *module, msg->num_elements = 0; msg->elements = NULL; - ret = ltdb->kv_ops->fetch_and_parse( - ltdb, ldb_key, ldb_kv_parse_data_unpack, &ctx); + ret = ldb_kv->kv_ops->fetch_and_parse( + ldb_kv, ldb_key, ldb_kv_parse_data_unpack, &ctx); if (ret == -1) { - ret = ltdb->kv_ops->error(ltdb); + ret = ldb_kv->kv_ops->error(ldb_kv); if (ret == LDB_SUCCESS) { /* * Just to be sure we don't turn errors @@ -289,7 +289,7 @@ int ldb_kv_search_dn1(struct ldb_module *module, unsigned int unpack_flags) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); int ret; uint8_t guid_key[LTDB_GUID_KEY_SIZE]; TDB_DATA tdb_key = { @@ -298,7 +298,7 @@ int ldb_kv_search_dn1(struct ldb_module *module, }; TALLOC_CTX *tdb_key_ctx = NULL; - if (ltdb->cache->GUID_index_attribute == NULL || + if (ldb_kv->cache->GUID_index_attribute == NULL || ldb_dn_is_special(dn)) { tdb_key_ctx = talloc_new(msg); @@ -320,13 +320,13 @@ int ldb_kv_search_dn1(struct ldb_module *module, * used for internal memory. * */ - ret = ldb_kv_key_dn_from_idx(module, ltdb, msg, dn, &tdb_key); + ret = ldb_kv_key_dn_from_idx(module, ldb_kv, msg, dn, &tdb_key); if (ret != LDB_SUCCESS) { return ret; } } - ret = ldb_kv_search_key(module, ltdb, tdb_key, msg, unpack_flags); + ret = ldb_kv_search_key(module, ldb_kv, tdb_key, msg, unpack_flags); TALLOC_FREE(tdb_key_ctx); @@ -493,7 +493,7 @@ failed: /* search function for a non-indexed search */ -static int search_func(struct ltdb_private *ltdb, struct ldb_val key, struct ldb_val val, void *state) +static int search_func(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val val, void *state) { struct ldb_context *ldb; struct ldb_kv_context *ac; @@ -583,11 +583,11 @@ static int search_func(struct ltdb_private *ltdb, struct ldb_val key, struct ldb static int ldb_kv_search_full(struct ldb_kv_context *ctx) { void *data = ldb_module_get_private(ctx->module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); int ret; ctx->error = LDB_SUCCESS; - ret = ltdb->kv_ops->iterate(ltdb, search_func, ctx); + ret = ldb_kv->kv_ops->iterate(ldb_kv, search_func, ctx); if (ret < 0) { return LDB_ERR_OPERATIONS_ERROR; @@ -596,7 +596,7 @@ static int ldb_kv_search_full(struct ldb_kv_context *ctx) return ctx->error; } -static int ldb_kv_search_and_return_base(struct ltdb_private *ltdb, +static int ldb_kv_search_and_return_base(struct ldb_kv_private *ldb_kv, struct ldb_kv_context *ctx) { struct ldb_message *msg, *filtered_msg; @@ -617,7 +617,7 @@ static int ldb_kv_search_and_return_base(struct ltdb_private *ltdb, LDB_UNPACK_DATA_FLAG_NO_VALUES_ALLOC); if (ret == LDB_ERR_NO_SUCH_OBJECT) { - if (ltdb->check_base == false) { + if (ldb_kv->check_base == false) { /* * In this case, we are done, as no base * checking is allowed in this DB @@ -708,24 +708,24 @@ int ldb_kv_search(struct ldb_kv_context *ctx) struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); int ret; ldb = ldb_module_get_ctx(module); ldb_request_set_state(req, LDB_ASYNC_PENDING); - if (ltdb->kv_ops->lock_read(module) != 0) { + if (ldb_kv->kv_ops->lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; } if (ldb_kv_cache_load(module) != 0) { - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return LDB_ERR_OPERATIONS_ERROR; } if (req->op.search.tree == NULL) { - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return LDB_ERR_OPERATIONS_ERROR; } @@ -770,13 +770,13 @@ int ldb_kv_search(struct ldb_kv_context *ctx) * will try to look up an index record for a special * record (which doesn't exist). */ - ret = ldb_kv_search_and_return_base(ltdb, ctx); + ret = ldb_kv_search_and_return_base(ldb_kv, ctx); - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return ret; - } else if (ltdb->check_base) { + } else if (ldb_kv->check_base) { /* * This database has been marked as * 'checkBaseOnSearch', so do a spot check of the base @@ -811,7 +811,7 @@ int ldb_kv_search(struct ldb_kv_context *ctx) * callback error */ if ( ! ctx->request_terminated && ret != LDB_SUCCESS) { /* Not indexed, so we need to do a full scan */ - if (ltdb->warn_unindexed || ltdb->disable_full_db_scan) { + if (ldb_kv->warn_unindexed || ldb_kv->disable_full_db_scan) { /* useful for debugging when slow performance * is caused by unindexed searches */ char *expression = ldb_filter_from_tree(ctx, ctx->tree); @@ -834,14 +834,14 @@ int ldb_kv_search(struct ldb_kv_context *ctx) * full search or we may return * duplicate entries */ - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return LDB_ERR_OPERATIONS_ERROR; } - if (ltdb->disable_full_db_scan) { + if (ldb_kv->disable_full_db_scan) { ldb_set_errstring(ldb, "ldb FULL SEARCH disabled"); - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return LDB_ERR_INAPPROPRIATE_MATCHING; } @@ -852,7 +852,7 @@ int ldb_kv_search(struct ldb_kv_context *ctx) } } - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return ret; } diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index d01fa9e4328..c1f5fa3488e 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -97,37 +97,37 @@ int ltdb_err_map(enum TDB_ERROR tdb_code) static 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); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); int tdb_ret = 0; int ret; pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( ldb_module_get_ctx(module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - if (tdb_transaction_active(ltdb->tdb) == false && - ltdb->read_lock_count == 0) { - tdb_ret = tdb_lockall_read(ltdb->tdb); + if (tdb_transaction_active(ldb_kv->tdb) == false && + ldb_kv->read_lock_count == 0) { + tdb_ret = tdb_lockall_read(ldb_kv->tdb); } if (tdb_ret == 0) { - ltdb->read_lock_count++; + ldb_kv->read_lock_count++; return LDB_SUCCESS; } - ret = ltdb_err_map(tdb_error(ltdb->tdb)); + ret = ltdb_err_map(tdb_error(ldb_kv->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), + tdb_errorstr(ldb_kv->tdb), ldb_strerror(ret)); return ret; } @@ -138,24 +138,24 @@ static int ltdb_lock_read(struct ldb_module *module) static int ltdb_unlock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( ldb_module_get_ctx(module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - if (!tdb_transaction_active(ltdb->tdb) && ltdb->read_lock_count == 1) { - tdb_unlockall_read(ltdb->tdb); - ltdb->read_lock_count--; + if (!tdb_transaction_active(ldb_kv->tdb) && ldb_kv->read_lock_count == 1) { + tdb_unlockall_read(ldb_kv->tdb); + ldb_kv->read_lock_count--; return 0; } - ltdb->read_lock_count--; + ldb_kv->read_lock_count--; return 0; } @@ -246,7 +246,7 @@ failed: /* The caller is to provide a correctly sized key */ int ldb_kv_guid_to_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_val *GUID_val, TDB_DATA *key) { @@ -268,7 +268,7 @@ int ldb_kv_guid_to_key(struct ldb_module *module, * the GUID index mode */ int ldb_kv_idx_to_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, TALLOC_CTX *mem_ctx, const struct ldb_val *idx_val, TDB_DATA *key) @@ -276,8 +276,8 @@ int ldb_kv_idx_to_key(struct ldb_module *module, struct ldb_context *ldb = ldb_module_get_ctx(module); struct ldb_dn *dn; - if (ltdb->cache->GUID_index_attribute != NULL) { - return ldb_kv_guid_to_key(module, ltdb, idx_val, key); + if (ldb_kv->cache->GUID_index_attribute != NULL) { + return ldb_kv_guid_to_key(module, ldb_kv, idx_val, key); } dn = ldb_dn_from_ldb_val(mem_ctx, ldb, idx_val); @@ -310,12 +310,12 @@ TDB_DATA ldb_kv_key_msg(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); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); TDB_DATA key; const struct ldb_val *guid_val; int ret; - if (ltdb->cache->GUID_index_attribute == NULL) { + if (ldb_kv->cache->GUID_index_attribute == NULL) { return ldb_kv_key_dn(module, mem_ctx, msg->dn); } @@ -324,13 +324,13 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module, } guid_val = ldb_msg_find_ldb_val(msg, - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); if (guid_val == NULL) { ldb_asprintf_errstring(ldb_module_get_ctx(module), "Did not find GUID attribute %s " "in %s, required for TDB record " "key in " LTDB_IDXGUID " mode.", - ltdb->cache->GUID_index_attribute, + ldb_kv->cache->GUID_index_attribute, ldb_dn_get_linearized(msg->dn)); errno = EINVAL; key.dptr = NULL; @@ -348,7 +348,7 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module, } key.dsize = talloc_get_size(key.dptr); - ret = ldb_kv_guid_to_key(module, ltdb, guid_val, &key); + ret = ldb_kv_guid_to_key(module, ldb_kv, guid_val, &key); if (ret != LDB_SUCCESS) { errno = EINVAL; @@ -399,11 +399,11 @@ static int ldb_kv_check_special_dn(struct ldb_module *module, static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn) { int ret = LDB_SUCCESS; - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private); /* only allow modifies inside a transaction, otherwise the * ldb is unsafe */ - if (ltdb->kv_ops->transaction_active(ltdb) == false) { + if (ldb_kv->kv_ops->transaction_active(ldb_kv) == false) { ldb_set_errstring(ldb_module_get_ctx(module), "ltdb modify without transaction"); return LDB_ERR_OPERATIONS_ERROR; } @@ -412,10 +412,10 @@ static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn) (ldb_dn_check_special(dn, LTDB_INDEXLIST) || ldb_dn_check_special(dn, LTDB_ATTRIBUTES)) ) { - if (ltdb->warn_reindex) { + if (ldb_kv->warn_reindex) { ldb_debug(ldb_module_get_ctx(module), LDB_DEBUG_ERROR, "Reindexing %s due to modification on %s", - ltdb->kv_ops->name(ltdb), ldb_dn_get_linearized(dn)); + ldb_kv->kv_ops->name(ldb_kv), ldb_dn_get_linearized(dn)); } ret = ldb_kv_reindex(module); } @@ -435,13 +435,13 @@ static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn) } if (ret != LDB_SUCCESS) { - ltdb->reindex_failed = true; + ldb_kv->reindex_failed = true; } return ret; } -static int ltdb_store(struct ltdb_private *ltdb, +static int ltdb_store(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val ldb_data, int flags) @@ -454,21 +454,21 @@ static int ltdb_store(struct ltdb_private *ltdb, .dptr = ldb_data.data, .dsize = ldb_data.length }; - bool transaction_active = tdb_transaction_active(ltdb->tdb); + bool transaction_active = tdb_transaction_active(ldb_kv->tdb); if (transaction_active == false){ return LDB_ERR_PROTOCOL_ERROR; } - return tdb_store(ltdb->tdb, key, data, flags); + return tdb_store(ldb_kv->tdb, key, data, flags); } -static int ltdb_error(struct ltdb_private *ltdb) +static int ltdb_error(struct ldb_kv_private *ldb_kv) { - return ltdb_err_map(tdb_error(ltdb->tdb)); + return ltdb_err_map(tdb_error(ldb_kv->tdb)); } -static const char *ltdb_errorstr(struct ltdb_private *ltdb) +static const char *ltdb_errorstr(struct ldb_kv_private *ldb_kv) { - return tdb_errorstr(ltdb->tdb); + return tdb_errorstr(ldb_kv->tdb); } /* @@ -479,7 +479,7 @@ int ldb_kv_store(struct ldb_module *module, int flgs) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); TDB_DATA tdb_key; struct ldb_val ldb_key; struct ldb_val ldb_data; @@ -490,7 +490,7 @@ int ldb_kv_store(struct ldb_module *module, return ldb_module_oom(module); } - if (ltdb->read_only) { + if (ldb_kv->read_only) { talloc_free(tdb_key_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -511,10 +511,10 @@ int ldb_kv_store(struct ldb_module *module, ldb_key.data = tdb_key.dptr; ldb_key.length = tdb_key.dsize; - ret = ltdb->kv_ops->store(ltdb, ldb_key, ldb_data, flgs); + ret = ldb_kv->kv_ops->store(ldb_kv, ldb_key, ldb_data, flgs); if (ret != 0) { bool is_special = ldb_dn_is_special(msg->dn); - ret = ltdb->kv_ops->error(ltdb); + ret = ldb_kv->kv_ops->error(ldb_kv); /* * LDB_ERR_ENTRY_ALREADY_EXISTS means the DN, not @@ -522,7 +522,7 @@ int ldb_kv_store(struct ldb_module *module, */ if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS && !is_special - && ltdb->cache->GUID_index_attribute != NULL) { + && ldb_kv->cache->GUID_index_attribute != NULL) { ret = LDB_ERR_CONSTRAINT_VIOLATION; } goto done; @@ -565,7 +565,7 @@ static bool ldb_kv_single_valued(const struct ldb_schema_attribute *a, } static int ldb_kv_add_internal(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, bool check_single_value) { @@ -647,7 +647,7 @@ static int ldb_kv_add_internal(struct ldb_module *module, return ret; } - ret = ldb_kv_index_add_new(module, ltdb, msg); + ret = ldb_kv_index_add_new(module, ldb_kv, msg); if (ret != LDB_SUCCESS) { /* * If we failed to index, delete the message again. @@ -676,11 +676,11 @@ static int ldb_kv_add(struct ldb_kv_context *ctx) struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); int ret = LDB_SUCCESS; - if (ltdb->max_key_length != 0 && - ltdb->cache->GUID_index_attribute == NULL && + if (ldb_kv->max_key_length != 0 && + ldb_kv->cache->GUID_index_attribute == NULL && !ldb_dn_is_special(req->op.add.message->dn)) { ldb_set_errstring(ldb_module_get_ctx(module), @@ -700,22 +700,22 @@ static int ldb_kv_add(struct ldb_kv_context *ctx) return LDB_ERR_OPERATIONS_ERROR; } - ret = ldb_kv_add_internal(module, ltdb, req->op.add.message, true); + ret = ldb_kv_add_internal(module, ldb_kv, req->op.add.message, true); return ret; } -static int ltdb_delete(struct ltdb_private *ltdb, struct ldb_val ldb_key) +static int ltdb_delete(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key) { TDB_DATA tdb_key = { .dptr = ldb_key.data, .dsize = ldb_key.length }; - bool transaction_active = tdb_transaction_active(ltdb->tdb); + bool transaction_active = tdb_transaction_active(ldb_kv->tdb); if (transaction_active == false){ return LDB_ERR_PROTOCOL_ERROR; } - return tdb_delete(ltdb->tdb, tdb_key); + return tdb_delete(ldb_kv->tdb, tdb_key); } /* @@ -726,7 +726,7 @@ int ldb_kv_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); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_val ldb_key; TDB_DATA tdb_key; int ret; @@ -736,7 +736,7 @@ int ldb_kv_delete_noindex(struct ldb_module *module, return ldb_module_oom(module); } - if (ltdb->read_only) { + if (ldb_kv->read_only) { talloc_free(tdb_key_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -750,11 +750,11 @@ int ldb_kv_delete_noindex(struct ldb_module *module, ldb_key.data = tdb_key.dptr; ldb_key.length = tdb_key.dsize; - ret = ltdb->kv_ops->delete(ltdb, ldb_key); + ret = ldb_kv->kv_ops->delete(ldb_kv, ldb_key); TALLOC_FREE(tdb_key_ctx); if (ret != 0) { - ret = ltdb->kv_ops->error(ltdb); + ret = ldb_kv->kv_ops->error(ldb_kv); } return ret; @@ -890,7 +890,7 @@ static int ldb_kv_msg_add_element(struct ldb_message *msg, delete all elements having a specified attribute name */ static int ldb_kv_msg_delete_attribute(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_message *msg, const char *name) { @@ -900,12 +900,12 @@ static int ldb_kv_msg_delete_attribute(struct ldb_module *module, bool is_special = ldb_dn_is_special(msg->dn); if (!is_special - && ltdb->cache->GUID_index_attribute != NULL - && ldb_attr_cmp(name, ltdb->cache->GUID_index_attribute) == 0) { + && ldb_kv->cache->GUID_index_attribute != NULL + && ldb_attr_cmp(name, ldb_kv->cache->GUID_index_attribute) == 0) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, "Must not modify GUID " "attribute %s (used as DB index)", - ltdb->cache->GUID_index_attribute); + ldb_kv->cache->GUID_index_attribute); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -915,7 +915,7 @@ static int ldb_kv_msg_delete_attribute(struct ldb_module *module, } i = el - msg->elements; - ret = ldb_kv_index_del_element(module, ltdb, msg, el); + ret = ldb_kv_index_del_element(module, ldb_kv, msg, el); if (ret != LDB_SUCCESS) { return ret; } @@ -937,7 +937,7 @@ static int ldb_kv_msg_delete_attribute(struct ldb_module *module, return LDB Error on failure */ static int ldb_kv_msg_delete_element(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct ldb_message *msg, const char *name, const struct ldb_val *val) @@ -971,10 +971,10 @@ static int ldb_kv_msg_delete_element(struct ldb_module *module, if (matched) { if (el->num_values == 1) { return ldb_kv_msg_delete_attribute( - module, ltdb, msg, name); + module, ldb_kv, msg, name); } - ret = ldb_kv_index_del_value(module, ltdb, msg, el, i); + ret = ldb_kv_index_del_value(module, ldb_kv, msg, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -1011,7 +1011,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, { struct ldb_context *ldb = ldb_module_get_ctx(module); void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_message *msg2; unsigned int i, j; int ret = LDB_SUCCESS, idx; @@ -1097,7 +1097,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, goto done; } ret = ldb_kv_index_add_element( - module, ltdb, msg2, el); + module, ldb_kv, msg2, el); if (ret != LDB_SUCCESS) { goto done; } @@ -1178,7 +1178,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, el2->num_values += el->num_values; ret = ldb_kv_index_add_element( - module, ltdb, msg2, el); + module, ldb_kv, msg2, el); if (ret != LDB_SUCCESS) { goto done; } @@ -1243,7 +1243,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, /* Delete the attribute if it exists in the DB */ if (ldb_kv_msg_delete_attribute( - module, ltdb, msg2, el->name) != 0) { + module, ldb_kv, msg2, el->name) != 0) { ret = LDB_ERR_OTHER; goto done; } @@ -1255,7 +1255,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, goto done; } - ret = ldb_kv_index_add_element(module, ltdb, msg2, el); + ret = ldb_kv_index_add_element(module, ldb_kv, msg2, el); if (ret != LDB_SUCCESS) { goto done; } @@ -1272,7 +1272,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, if (msg->elements[i].num_values == 0) { /* Delete the whole attribute */ ret = ldb_kv_msg_delete_attribute( - module, ltdb, msg2, msg->elements[i].name); + module, ldb_kv, msg2, msg->elements[i].name); if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE && control_permissive) { ret = LDB_SUCCESS; @@ -1289,7 +1289,7 @@ int ldb_kv_modify_internal(struct ldb_module *module, for (j=0; j < msg->elements[i].num_values; j++) { ret = ldb_kv_msg_delete_element( module, - ltdb, + ldb_kv, msg2, msg->elements[i].name, &msg->elements[i].values[j]); @@ -1364,7 +1364,7 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx) { struct ldb_module *module = ctx->module; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); struct ldb_request *req = ctx->req; struct ldb_message *msg; int ret = LDB_SUCCESS; @@ -1464,110 +1464,110 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx) * deleted attributes. We could go through all elements but that's * maybe not the most efficient way */ - ret = ldb_kv_add_internal(module, ltdb, msg, false); + ret = ldb_kv_add_internal(module, ldb_kv, msg, false); talloc_free(msg); return ret; } -static int ltdb_transaction_start(struct ltdb_private *ltdb) +static int ltdb_transaction_start(struct ldb_kv_private *ldb_kv) { pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( - ldb_module_get_ctx(ltdb->module), + ldb_module_get_ctx(ldb_kv->module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - return tdb_transaction_start(ltdb->tdb); + return tdb_transaction_start(ldb_kv->tdb); } -static int ltdb_transaction_cancel(struct ltdb_private *ltdb) +static int ltdb_transaction_cancel(struct ldb_kv_private *ldb_kv) { pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( - ldb_module_get_ctx(ltdb->module), + ldb_module_get_ctx(ldb_kv->module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - return tdb_transaction_cancel(ltdb->tdb); + return tdb_transaction_cancel(ldb_kv->tdb); } -static int ltdb_transaction_prepare_commit(struct ltdb_private *ltdb) +static int ltdb_transaction_prepare_commit(struct ldb_kv_private *ldb_kv) { pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( - ldb_module_get_ctx(ltdb->module), + ldb_module_get_ctx(ldb_kv->module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - return tdb_transaction_prepare_commit(ltdb->tdb); + return tdb_transaction_prepare_commit(ldb_kv->tdb); } -static int ltdb_transaction_commit(struct ltdb_private *ltdb) +static int ltdb_transaction_commit(struct ldb_kv_private *ldb_kv) { pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( - ldb_module_get_ctx(ltdb->module), + ldb_module_get_ctx(ldb_kv->module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - return tdb_transaction_commit(ltdb->tdb); + return tdb_transaction_commit(ldb_kv->tdb); } static int ldb_kv_start_trans(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( - ldb_module_get_ctx(ltdb->module), + ldb_module_get_ctx(ldb_kv->module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } /* Do not take out the transaction lock on a read-only DB */ - if (ltdb->read_only) { + if (ldb_kv->read_only) { return LDB_ERR_UNWILLING_TO_PERFORM; } - if (ltdb->kv_ops->begin_write(ltdb) != 0) { - return ltdb->kv_ops->error(ltdb); + if (ldb_kv->kv_ops->begin_write(ldb_kv) != 0) { + return ldb_kv->kv_ops->error(ldb_kv); } ldb_kv_index_transaction_start(module); - ltdb->reindex_failed = false; + ldb_kv->reindex_failed = false; return LDB_SUCCESS; } @@ -1582,20 +1582,20 @@ static int ldb_kv_prepare_commit(struct ldb_module *module) { int ret; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); pid_t pid = getpid(); - if (ltdb->pid != pid) { + if (ldb_kv->pid != pid) { ldb_asprintf_errstring( ldb_module_get_ctx(module), __location__": Reusing ldb opend by pid %d in " "process %d\n", - ltdb->pid, + ldb_kv->pid, pid); return LDB_ERR_PROTOCOL_ERROR; } - if (!ltdb->kv_ops->transaction_active(ltdb)) { + if (!ldb_kv->kv_ops->transaction_active(ldb_kv)) { ldb_set_errstring(ldb_module_get_ctx(module), "ltdb_prepare_commit() called " "without transaction active"); @@ -1608,7 +1608,7 @@ static int ldb_kv_prepare_commit(struct ldb_module *module) * This can happen if for example a duplicate value was marked * unique. We must not write a partial re-index into the DB. */ - if (ltdb->reindex_failed) { + if (ldb_kv->reindex_failed) { /* * We must instead abort the transaction so we get the * old values and old index back @@ -1622,22 +1622,22 @@ static int ldb_kv_prepare_commit(struct ldb_module *module) ret = ldb_kv_index_transaction_commit(module); if (ret != LDB_SUCCESS) { - ltdb->kv_ops->abort_write(ltdb); + ldb_kv->kv_ops->abort_write(ldb_kv); return ret; } - if (ltdb->kv_ops->prepare_write(ltdb) != 0) { - ret = ltdb->kv_ops->error(ltdb); + if (ldb_kv->kv_ops->prepare_write(ldb_kv) != 0) { + ret = ldb_kv->kv_ops->error(ldb_kv); ldb_debug_set(ldb_module_get_ctx(module), LDB_DEBUG_FATAL, "Failure during " "prepare_write): %s -> %s", - ltdb->kv_ops->errorstr(ltdb), + ldb_kv->kv_ops->errorstr(ldb_kv), ldb_strerror(ret)); return ret; } - ltdb->prepared_commit = true; + ldb_kv->prepared_commit = true; return LDB_SUCCESS; } @@ -1646,22 +1646,22 @@ static int ldb_kv_end_trans(struct ldb_module *module) { int ret; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); - if (!ltdb->prepared_commit) { + if (!ldb_kv->prepared_commit) { ret = ldb_kv_prepare_commit(module); if (ret != LDB_SUCCESS) { return ret; } } - ltdb->prepared_commit = false; + ldb_kv->prepared_commit = false; - if (ltdb->kv_ops->finish_write(ltdb) != 0) { - ret = ltdb->kv_ops->error(ltdb); + if (ldb_kv->kv_ops->finish_write(ldb_kv) != 0) { + ret = ldb_kv->kv_ops->error(ldb_kv); ldb_asprintf_errstring(ldb_module_get_ctx(module), "Failure during tdb_transaction_commit(): %s -> %s", - ltdb->kv_ops->errorstr(ltdb), + ldb_kv->kv_ops->errorstr(ldb_kv), ldb_strerror(ret)); return ret; } @@ -1672,14 +1672,14 @@ static int ldb_kv_end_trans(struct ldb_module *module) static int ldb_kv_del_trans(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); if (ldb_kv_index_transaction_cancel(module) != 0) { - ltdb->kv_ops->abort_write(ltdb); - return ltdb->kv_ops->error(ltdb); + ldb_kv->kv_ops->abort_write(ldb_kv); + return ldb_kv->kv_ops->error(ldb_kv); } - ltdb->kv_ops->abort_write(ltdb); + ldb_kv->kv_ops->abort_write(ldb_kv); return LDB_SUCCESS; } @@ -1693,7 +1693,7 @@ static int ldb_kv_sequence_number(struct ldb_kv_context *ctx, struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); TALLOC_CTX *tmp_ctx = NULL; struct ldb_seqnum_request *seq; struct ldb_seqnum_result *res; @@ -1712,7 +1712,7 @@ static int ldb_kv_sequence_number(struct ldb_kv_context *ctx, ldb_request_set_state(req, LDB_ASYNC_PENDING); - if (ltdb->kv_ops->lock_read(module) != 0) { + if (ldb_kv->kv_ops->lock_read(module) != 0) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1775,7 +1775,7 @@ static int ldb_kv_sequence_number(struct ldb_kv_context *ctx, done: talloc_free(tmp_ctx); - ltdb->kv_ops->unlock_read(module); + ldb_kv->kv_ops->unlock_read(module); return ret; } @@ -1875,7 +1875,7 @@ static void ldb_kv_handle_extended(struct ldb_kv_context *ctx) struct kv_ctx { ldb_kv_traverse_fn kv_traverse_fn; void *ctx; - struct ltdb_private *ltdb; + struct ldb_kv_private *ldb_kv; int (*parser)(struct ldb_val key, struct ldb_val data, void *private_data); @@ -1895,28 +1895,28 @@ static int ltdb_traverse_fn_wrapper(struct tdb_context *tdb, .length = tdb_data.dsize, .data = tdb_data.dptr, }; - return kv_ctx->kv_traverse_fn(kv_ctx->ltdb, key, data, kv_ctx->ctx); + return kv_ctx->kv_traverse_fn(kv_ctx->ldb_kv, key, data, kv_ctx->ctx); } -static int ltdb_traverse_fn(struct ltdb_private *ltdb, +static int ltdb_traverse_fn(struct ldb_kv_private *ldb_kv, ldb_kv_traverse_fn fn, void *ctx) { struct kv_ctx kv_ctx = { .kv_traverse_fn = fn, .ctx = ctx, - .ltdb = ltdb + .ldb_kv = ldb_kv }; - if (tdb_transaction_active(ltdb->tdb)) { + if (tdb_transaction_active(ldb_kv->tdb)) { return tdb_traverse( - ltdb->tdb, ltdb_traverse_fn_wrapper, &kv_ctx); + ldb_kv->tdb, ltdb_traverse_fn_wrapper, &kv_ctx); } else { return tdb_traverse_read( - ltdb->tdb, ltdb_traverse_fn_wrapper, &kv_ctx); + ldb_kv->tdb, ltdb_traverse_fn_wrapper, &kv_ctx); } } -static int ltdb_update_in_iterate(struct ltdb_private *ltdb, +static int ltdb_update_in_iterate(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val ldb_key2, struct ldb_val ldb_data, @@ -1942,7 +1942,7 @@ static int ltdb_update_in_iterate(struct ltdb_private *ltdb, ldb = ldb_module_get_ctx(module); - tdb_ret = tdb_delete(ltdb->tdb, key); + tdb_ret = tdb_delete(ldb_kv->tdb, key); if (tdb_ret != 0) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to delete %*.*s " @@ -1951,11 +1951,11 @@ static int ltdb_update_in_iterate(struct ltdb_private *ltdb, (const char *)key.dptr, (int)key2.dsize, (int)key2.dsize, (const char *)key.dptr, - tdb_errorstr(ltdb->tdb)); - ctx->error = ltdb_err_map(tdb_error(ltdb->tdb)); + tdb_errorstr(ldb_kv->tdb)); + ctx->error = ltdb_err_map(tdb_error(ldb_kv->tdb)); return -1; } - tdb_ret = tdb_store(ltdb->tdb, key2, data, 0); + tdb_ret = tdb_store(ldb_kv->tdb, key2, data, 0); if (tdb_ret != 0) { ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to rekey %*.*s as %*.*s: %s", @@ -1963,8 +1963,8 @@ static int ltdb_update_in_iterate(struct ltdb_private *ltdb, (const char *)key.dptr, (int)key2.dsize, (int)key2.dsize, (const char *)key.dptr, - tdb_errorstr(ltdb->tdb)); - ctx->error = ltdb_err_map(tdb_error(ltdb->tdb)); + tdb_errorstr(ldb_kv->tdb)); + ctx->error = ltdb_err_map(tdb_error(ldb_kv->tdb)); return -1; } return tdb_ret; @@ -1987,7 +1987,7 @@ static int ltdb_parse_record_wrapper(TDB_DATA tdb_key, return kv_ctx->parser(key, data, kv_ctx->ctx); } -static int ltdb_parse_record(struct ltdb_private *ltdb, +static int ltdb_parse_record(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, int (*parser)(struct ldb_val key, struct ldb_val data, @@ -1997,7 +1997,7 @@ static int ltdb_parse_record(struct ltdb_private *ltdb, struct kv_ctx kv_ctx = { .parser = parser, .ctx = ctx, - .ltdb = ltdb + .ldb_kv = ldb_kv }; TDB_DATA key = { .dptr = ldb_key.data, @@ -2005,37 +2005,37 @@ static int ltdb_parse_record(struct ltdb_private *ltdb, }; int ret; - if (tdb_transaction_active(ltdb->tdb) == false && - ltdb->read_lock_count == 0) { + if (tdb_transaction_active(ldb_kv->tdb) == false && + ldb_kv->read_lock_count == 0) { return LDB_ERR_PROTOCOL_ERROR; } ret = tdb_parse_record( - ltdb->tdb, key, ltdb_parse_record_wrapper, &kv_ctx); + ldb_kv->tdb, key, ltdb_parse_record_wrapper, &kv_ctx); if (ret == 0) { return LDB_SUCCESS; } - return ltdb_err_map(tdb_error(ltdb->tdb)); + return ltdb_err_map(tdb_error(ldb_kv->tdb)); } -static const char *ltdb_name(struct ltdb_private *ltdb) +static const char *ltdb_name(struct ldb_kv_private *ldb_kv) { - return tdb_name(ltdb->tdb); + return tdb_name(ldb_kv->tdb); } -static bool ltdb_changed(struct ltdb_private *ltdb) +static bool ltdb_changed(struct ldb_kv_private *ldb_kv) { - int seq = tdb_get_seqnum(ltdb->tdb); - bool has_changed = (seq != ltdb->tdb_seqnum); + int seq = tdb_get_seqnum(ldb_kv->tdb); + bool has_changed = (seq != ldb_kv->tdb_seqnum); - ltdb->tdb_seqnum = seq; + ldb_kv->tdb_seqnum = seq; return has_changed; } -static bool ltdb_transaction_active(struct ltdb_private *ltdb) +static bool ltdb_transaction_active(struct ldb_kv_private *ldb_kv) { - return tdb_transaction_active(ltdb->tdb); + return tdb_transaction_active(ldb_kv->tdb); } static const struct kv_db_ops key_value_ops = { @@ -2209,15 +2209,15 @@ static int ldb_kv_init_rootdse(struct ldb_module *module) static int ldb_kv_lock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); - return ltdb->kv_ops->lock_read(module); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); + return ldb_kv->kv_ops->lock_read(module); } static int ldb_kv_unlock_read(struct ldb_module *module) { void *data = ldb_module_get_private(module); - struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); - return ltdb->kv_ops->unlock_read(module); + struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private); + return ldb_kv->kv_ops->unlock_read(module); } static const struct ldb_module_ops ldb_kv_ops = { @@ -2237,41 +2237,41 @@ static const struct ldb_module_ops ldb_kv_ops = { .read_unlock = ldb_kv_unlock_read, }; -int ldb_kv_init_store(struct ltdb_private *ltdb, +int ldb_kv_init_store(struct ldb_kv_private *ldb_kv, const char *name, struct ldb_context *ldb, const char *options[], struct ldb_module **_module) { if (getenv("LDB_WARN_UNINDEXED")) { - ltdb->warn_unindexed = true; + ldb_kv->warn_unindexed = true; } if (getenv("LDB_WARN_REINDEX")) { - ltdb->warn_reindex = true; + ldb_kv->warn_reindex = true; } - ltdb->sequence_number = 0; + ldb_kv->sequence_number = 0; - ltdb->pid = getpid(); + ldb_kv->pid = getpid(); - ltdb->module = ldb_module_new(ldb, ldb, name, &ldb_kv_ops); - if (!ltdb->module) { + ldb_kv->module = ldb_module_new(ldb, ldb, name, &ldb_kv_ops); + if (!ldb_kv->module) { ldb_oom(ldb); - talloc_free(ltdb); + talloc_free(ldb_kv); return LDB_ERR_OPERATIONS_ERROR; } - ldb_module_set_private(ltdb->module, ltdb); - talloc_steal(ltdb->module, ltdb); + ldb_module_set_private(ldb_kv->module, ldb_kv); + talloc_steal(ldb_kv->module, ldb_kv); - if (ldb_kv_cache_load(ltdb->module) != 0) { + if (ldb_kv_cache_load(ldb_kv->module) != 0) { ldb_asprintf_errstring(ldb, "Unable to load ltdb cache " "records for backend '%s'", name); - talloc_free(ltdb->module); + talloc_free(ldb_kv->module); return LDB_ERR_OPERATIONS_ERROR; } - *_module = ltdb->module; + *_module = ldb_kv->module; /* * Set or override the maximum key length * @@ -2287,7 +2287,7 @@ int ldb_kv_init_store(struct ltdb_private *ltdb, "max_key_len_for_self_test"); if (len_str != NULL) { unsigned len = strtoul(len_str, NULL, 0); - ltdb->max_key_length = len; + ldb_kv->max_key_length = len; } } @@ -2303,7 +2303,7 @@ int ldb_kv_init_store(struct ltdb_private *ltdb, ldb_options_find(ldb, options, "disable_full_db_scan_for_self_test"); if (len_str != NULL) { - ltdb->disable_full_db_scan = true; + ldb_kv->disable_full_db_scan = true; } } @@ -2319,7 +2319,7 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, { const char *path; int tdb_flags, open_flags; - struct ltdb_private *ltdb; + struct ldb_kv_private *ldb_kv; /* * We hold locks, so we must use a private event context @@ -2351,8 +2351,8 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, tdb_flags |= TDB_NOMMAP; } - ltdb = talloc_zero(ldb, struct ltdb_private); - if (!ltdb) { + ldb_kv = talloc_zero(ldb, struct ldb_kv_private); + if (!ldb_kv) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; } @@ -2366,7 +2366,7 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, */ open_flags = O_RDWR; - ltdb->read_only = true; + ldb_kv->read_only = true; } else if (flags & LDB_FLG_DONT_CREATE_DB) { /* @@ -2381,19 +2381,19 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, open_flags = O_CREAT | O_RDWR; } - ltdb->kv_ops = &key_value_ops; + ldb_kv->kv_ops = &key_value_ops; errno = 0; /* note that we use quite a large default hash size */ - ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, + ldb_kv->tdb = ltdb_wrap_open(ldb_kv, path, 10000, tdb_flags, open_flags, ldb_get_create_perms(ldb), ldb); - if (!ltdb->tdb) { + if (!ldb_kv->tdb) { ldb_asprintf_errstring(ldb, "Unable to open tdb '%s': %s", path, strerror(errno)); ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s': %s", path, strerror(errno)); - talloc_free(ltdb); + talloc_free(ldb_kv); if (errno == EACCES || errno == EPERM) { return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS; } @@ -2401,5 +2401,5 @@ int ltdb_connect(struct ldb_context *ldb, const char *url, } return ldb_kv_init_store( - ltdb, "ldb_tdb backend", ldb, options, _module); + ldb_kv, "ldb_tdb backend", ldb, options, _module); } diff --git a/lib/ldb/ldb_tdb/ldb_tdb.h b/lib/ldb/ldb_tdb/ldb_tdb.h index 9a9471e8c91..930405d0f63 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.h +++ b/lib/ldb/ldb_tdb/ldb_tdb.h @@ -4,37 +4,37 @@ #include "tdb.h" #include "ldb_module.h" -struct ltdb_private; -typedef int (*ldb_kv_traverse_fn)(struct ltdb_private *ltdb, +struct ldb_kv_private; +typedef int (*ldb_kv_traverse_fn)(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, void *ctx); struct kv_db_ops { - int (*store)(struct ltdb_private *ltdb, struct ldb_val key, struct ldb_val data, int flags); - int (*delete)(struct ltdb_private *ltdb, struct ldb_val key); - int (*iterate)(struct ltdb_private *ltdb, ldb_kv_traverse_fn fn, void *ctx); - int (*update_in_iterate)(struct ltdb_private *ltdb, struct ldb_val key, + int (*store)(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, int flags); + int (*delete)(struct ldb_kv_private *ldb_kv, struct ldb_val key); + int (*iterate)(struct ldb_kv_private *ldb_kv, ldb_kv_traverse_fn fn, void *ctx); + int (*update_in_iterate)(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val key2, struct ldb_val data, void *ctx); - int (*fetch_and_parse)(struct ltdb_private *ltdb, struct ldb_val key, + int (*fetch_and_parse)(struct ldb_kv_private *ldb_kv, struct ldb_val key, int (*parser)(struct ldb_val key, struct ldb_val data, void *private_data), void *ctx); int (*lock_read)(struct ldb_module *); int (*unlock_read)(struct ldb_module *); - int (*begin_write)(struct ltdb_private *); - int (*prepare_write)(struct ltdb_private *); - int (*abort_write)(struct ltdb_private *); - int (*finish_write)(struct ltdb_private *); - int (*error)(struct ltdb_private *ltdb); - const char * (*errorstr)(struct ltdb_private *ltdb); - const char * (*name)(struct ltdb_private *ltdb); - bool (*has_changed)(struct ltdb_private *ltdb); - bool (*transaction_active)(struct ltdb_private *ltdb); + int (*begin_write)(struct ldb_kv_private *); + int (*prepare_write)(struct ldb_kv_private *); + int (*abort_write)(struct ldb_kv_private *); + int (*finish_write)(struct ldb_kv_private *); + int (*error)(struct ldb_kv_private *ldb_kv); + const char * (*errorstr)(struct ldb_kv_private *ldb_kv); + const char * (*name)(struct ldb_kv_private *ldb_kv); + bool (*has_changed)(struct ldb_kv_private *ldb_kv); + bool (*transaction_active)(struct ldb_kv_private *ldb_kv); }; -/* this private structure is used by the ltdb backend in the +/* this private structure is used by the key value backends in the ldb_context */ -struct ltdb_private { +struct ldb_kv_private { const struct kv_db_ops *kv_ops; struct ldb_module *module; TDB_CONTEXT *tdb; @@ -164,20 +164,20 @@ struct ldb_parse_tree; int ldb_kv_search_indexed(struct ldb_kv_context *ctx, uint32_t *); int ldb_kv_index_add_new(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg); int ldb_kv_index_delete(struct ldb_module *module, const struct ldb_message *msg); int ldb_kv_index_del_element(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el); int ldb_kv_index_add_element(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el); int ldb_kv_index_del_value(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_message *msg, struct ldb_message_element *el, unsigned int v_idx); @@ -186,7 +186,7 @@ int ldb_kv_index_transaction_start(struct ldb_module *module); int ldb_kv_index_transaction_commit(struct ldb_module *module); int ldb_kv_index_transaction_cancel(struct ldb_module *module); int ldb_kv_key_dn_from_idx(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, TALLOC_CTX *mem_ctx, struct ldb_dn *dn, TDB_DATA *tdb_key); @@ -205,7 +205,7 @@ int ldb_kv_search_base(struct ldb_module *module, struct ldb_dn *dn, struct ldb_dn **ret_dn); int ldb_kv_search_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, struct TDB_DATA tdb_key, struct ldb_message *msg, unsigned int unpack_flags); @@ -228,11 +228,11 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module, TALLOC_CTX *mem_ctx, const struct ldb_message *msg); int ldb_kv_guid_to_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, const struct ldb_val *GUID_val, TDB_DATA *key); int ldb_kv_idx_to_key(struct ldb_module *module, - struct ltdb_private *ltdb, + struct ldb_kv_private *ldb_kv, TALLOC_CTX *mem_ctx, const struct ldb_val *idx_val, TDB_DATA *key); @@ -251,7 +251,7 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx, const char *path, int hash_size, int tdb_flags, int open_flags, mode_t mode, struct ldb_context *ldb); -int ldb_kv_init_store(struct ltdb_private *ltdb, +int ldb_kv_init_store(struct ldb_kv_private *ldb_kv, const char *name, struct ldb_context *ldb, const char *options[], diff --git a/lib/ldb/tests/ldb_kv_ops_test.c b/lib/ldb/tests/ldb_kv_ops_test.c index 30ce019fac8..74aaf03fde2 100644 --- a/lib/ldb/tests/ldb_kv_ops_test.c +++ b/lib/ldb/tests/ldb_kv_ops_test.c @@ -171,18 +171,18 @@ static int teardown(void **state) return 0; } -static struct ltdb_private *get_ltdb(struct ldb_context *ldb) +static struct ldb_kv_private *get_ldb_kv(struct ldb_context *ldb) { void *data = NULL; - struct ltdb_private *ltdb = NULL; + struct ldb_kv_private *ldb_kv = NULL; data = ldb_module_get_private(ldb->modules); assert_non_null(data); - ltdb = talloc_get_type(data, struct ltdb_private); - assert_non_null(ltdb); + ldb_kv = talloc_get_type(data, struct ldb_kv_private); + assert_non_null(ldb_kv); - return ltdb; + return ldb_kv; } static int parse(struct ldb_val key, @@ -209,7 +209,7 @@ static void test_add_get(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -233,34 +233,34 @@ static void test_add_get(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); talloc_free(tmp_ctx); } @@ -273,7 +273,7 @@ static void test_read_outside_transaction(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -297,26 +297,26 @@ static void test_read_outside_transaction(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back * Note there is no read transaction active */ - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, LDB_ERR_PROTOCOL_ERROR); talloc_free(tmp_ctx); @@ -330,7 +330,7 @@ static void test_delete(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -354,59 +354,59 @@ static void test_delete(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Now delete it. */ - ret = ltdb->kv_ops->delete(ltdb, key); + ret = ldb_kv->kv_ops->delete(ldb_kv, key); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now try to read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, LDB_ERR_NO_SUCH_OBJECT); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); talloc_free(tmp_ctx); @@ -421,7 +421,7 @@ static void test_transaction_abort_write(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -445,19 +445,19 @@ static void test_transaction_abort_write(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); @@ -466,17 +466,17 @@ static void test_transaction_abort_write(void **state) /* * Now abort the transaction */ - ret = ltdb->kv_ops->abort_write(ltdb); + ret = ldb_kv->kv_ops->abort_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back, should not be there */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, LDB_ERR_NO_SUCH_OBJECT); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); talloc_free(tmp_ctx); @@ -491,7 +491,7 @@ static void test_transaction_abort_delete(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -515,67 +515,67 @@ static void test_transaction_abort_delete(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Now delete it. */ - ret = ltdb->kv_ops->delete(ltdb, key); + ret = ldb_kv->kv_ops->delete(ldb_kv, key); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, LDB_ERR_NO_SUCH_OBJECT); /* * Abort the transaction */ - ret = ltdb->kv_ops->abort_write(ltdb); + ret = ldb_kv->kv_ops->abort_write(ldb_kv); assert_int_equal(ret, 0); /* * And now try to read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); talloc_free(tmp_ctx); @@ -589,7 +589,7 @@ static void test_write_outside_transaction(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -612,7 +612,7 @@ static void test_write_outside_transaction(void **state) /* * Attempt to write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, LDB_ERR_PROTOCOL_ERROR); talloc_free(tmp_ctx); @@ -626,7 +626,7 @@ static void test_delete_outside_transaction(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); uint8_t key_val[] = "TheKey"; struct ldb_val key = { .data = key_val, @@ -650,55 +650,55 @@ static void test_delete_outside_transaction(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* * Write the record */ - ret = ltdb->kv_ops->store(ltdb, key, data, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, data, flags); assert_int_equal(ret, 0); /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * And now read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); /* * Now attempt to delete a record */ - ret = ltdb->kv_ops->delete(ltdb, key); + ret = ldb_kv->kv_ops->delete(ldb_kv, key); assert_int_equal(ret, LDB_ERR_PROTOCOL_ERROR); /* * And now read it back */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &read); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &read); assert_int_equal(ret, 0); assert_int_equal(sizeof(value), read.length); assert_memory_equal(value, read.data, sizeof(value)); - ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); talloc_free(tmp_ctx); } -static int traverse_fn(struct ltdb_private *ltdb, +static int traverse_fn(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, void *ctx) { @@ -722,7 +722,7 @@ static void test_iterate(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); int i; int num_recs = 1024; int visits[num_recs]; @@ -735,7 +735,7 @@ static void test_iterate(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* @@ -755,7 +755,7 @@ static void test_iterate(void **state) i); rec.length = strlen((char *)rec.data) + 1; - ret = ltdb->kv_ops->store(ltdb, key, rec, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, rec, flags); assert_int_equal(ret, 0); TALLOC_FREE(key.data); @@ -765,20 +765,20 @@ static void test_iterate(void **state) /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* * Now iterate over the kv store and ensure that all the * records are visited. */ - ret = ltdb->kv_ops->lock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->lock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->iterate(ltdb, traverse_fn, visits); + ret = ldb_kv->kv_ops->iterate(ldb_kv, traverse_fn, visits); for (i = 0; i kv_ops->unlock_read(test_ctx->ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(test_ctx->ldb->modules); assert_int_equal(ret, 0); TALLOC_FREE(tmp_ctx); @@ -789,7 +789,7 @@ struct update_context { int visits[NUM_RECS]; }; -static int update_fn(struct ltdb_private *ltdb, +static int update_fn(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, void *ctx) { @@ -800,7 +800,7 @@ static int update_fn(struct ltdb_private *ltdb, int ret = LDB_SUCCESS; TALLOC_CTX *tmp_ctx; - tmp_ctx = talloc_new(ltdb); + tmp_ctx = talloc_new(ldb_kv); assert_non_null(tmp_ctx); context = talloc_get_type_abort(ctx, struct update_context); @@ -815,7 +815,7 @@ static int update_fn(struct ltdb_private *ltdb, new_key.length = key.length; new_key.data[0] = 'K'; - ret = ltdb->kv_ops->update_in_iterate(ltdb, + ret = ldb_kv->kv_ops->update_in_iterate(ldb_kv, key, new_key, data, @@ -833,7 +833,7 @@ static void test_update_in_iterate(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); int i; struct update_context *context = NULL; @@ -849,7 +849,7 @@ static void test_update_in_iterate(void **state) /* * Begin a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); /* @@ -868,7 +868,7 @@ static void test_update_in_iterate(void **state) i); rec.length = strlen((char *)rec.data) + 1; - ret = ltdb->kv_ops->store(ltdb, key, rec, flags); + ret = ldb_kv->kv_ops->store(ldb_kv, key, rec, flags); assert_int_equal(ret, 0); TALLOC_FREE(key.data); @@ -878,7 +878,7 @@ static void test_update_in_iterate(void **state) /* * Commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); /* @@ -889,15 +889,15 @@ static void test_update_in_iterate(void **state) /* * Needs to be done inside a transaction */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->iterate(ltdb, update_fn, context); + ret = ldb_kv->kv_ops->iterate(ldb_kv, update_fn, context); for (i = 0; i < NUM_RECS; i++) { assert_int_equal(1, context->visits[i]); } - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); TALLOC_FREE(tmp_ctx); @@ -912,7 +912,7 @@ static void test_write_transaction_isolation(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); struct ldb_val key; struct ldb_val val; @@ -939,7 +939,7 @@ static void test_write_transaction_isolation(void **state) /* * Add a record to the database */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); @@ -948,10 +948,10 @@ static void test_write_transaction_isolation(void **state) val.data = (uint8_t *)talloc_strdup(tmp_ctx, VAL1); val.length = strlen(VAL1) + 1; - ret = ltdb->kv_ops->store(ltdb, key, val, 0); + ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); @@ -987,9 +987,9 @@ static void test_write_transaction_isolation(void **state) exit(ret); } - ltdb = get_ltdb(ldb); + ldb_kv = get_ldb_kv(ldb); - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": lock_read returned (%d)\n", ret); @@ -1002,7 +1002,7 @@ static void test_write_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); key.length = strlen(KEY1) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1024,7 +1024,7 @@ static void test_write_transaction_isolation(void **state) exit(LDB_ERR_OPERATIONS_ERROR); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1037,14 +1037,14 @@ static void test_write_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); key.length = strlen(KEY2 + 1); - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": lock_read returned (%d)\n", ret); exit(ret); } - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_ERR_NO_SUCH_OBJECT) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1052,7 +1052,7 @@ static void test_write_transaction_isolation(void **state) exit(ret); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1082,7 +1082,7 @@ static void test_write_transaction_isolation(void **state) /* * Check that KEY1 is there */ - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1091,7 +1091,7 @@ static void test_write_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); key.length = strlen(KEY1) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1113,7 +1113,7 @@ static void test_write_transaction_isolation(void **state) exit(LDB_ERR_OPERATIONS_ERROR); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1124,7 +1124,7 @@ static void test_write_transaction_isolation(void **state) /* * Check that KEY2 is there */ - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1134,7 +1134,7 @@ static void test_write_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); key.length = strlen(KEY2) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1156,7 +1156,7 @@ static void test_write_transaction_isolation(void **state) exit(LDB_ERR_OPERATIONS_ERROR); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1172,7 +1172,7 @@ static void test_write_transaction_isolation(void **state) * Begin a transaction and add a record to the database * but leave the transaction open */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); @@ -1181,7 +1181,7 @@ static void test_write_transaction_isolation(void **state) val.data = (uint8_t *)talloc_strdup(tmp_ctx, VAL2); val.length = strlen(VAL2) + 1; - ret = ltdb->kv_ops->store(ltdb, key, val, 0); + ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0); assert_int_equal(ret, 0); /* @@ -1200,7 +1200,7 @@ static void test_write_transaction_isolation(void **state) /* * commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(0, ret); /* @@ -1229,7 +1229,7 @@ static void test_delete_transaction_isolation(void **state) int ret; struct test_ctx *test_ctx = talloc_get_type_abort(*state, struct test_ctx); - struct ltdb_private *ltdb = get_ltdb(test_ctx->ldb); + struct ldb_kv_private *ldb_kv = get_ldb_kv(test_ctx->ldb); struct ldb_val key; struct ldb_val val; @@ -1256,7 +1256,7 @@ static void test_delete_transaction_isolation(void **state) /* * Add records to the database */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); @@ -1265,7 +1265,7 @@ static void test_delete_transaction_isolation(void **state) val.data = (uint8_t *)talloc_strdup(tmp_ctx, VAL1); val.length = strlen(VAL1) + 1; - ret = ltdb->kv_ops->store(ltdb, key, val, 0); + ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0); assert_int_equal(ret, 0); key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); @@ -1274,10 +1274,10 @@ static void test_delete_transaction_isolation(void **state) val.data = (uint8_t *)talloc_strdup(tmp_ctx, VAL2); val.length = strlen(VAL2) + 1; - ret = ltdb->kv_ops->store(ltdb, key, val, 0); + ret = ldb_kv->kv_ops->store(ldb_kv, key, val, 0); assert_int_equal(ret, 0); - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(ret, 0); @@ -1314,9 +1314,9 @@ static void test_delete_transaction_isolation(void **state) exit(ret); } - ltdb = get_ltdb(ldb); + ldb_kv = get_ldb_kv(ldb); - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": lock_read returned (%d)\n", ret); @@ -1329,7 +1329,7 @@ static void test_delete_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); key.length = strlen(KEY1) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1358,7 +1358,7 @@ static void test_delete_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); key.length = strlen(KEY2) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1380,7 +1380,7 @@ static void test_delete_transaction_isolation(void **state) exit(LDB_ERR_OPERATIONS_ERROR); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1410,7 +1410,7 @@ static void test_delete_transaction_isolation(void **state) /* * Check that KEY1 is there */ - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1419,7 +1419,7 @@ static void test_delete_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY1); key.length = strlen(KEY1) + 1; - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_SUCCESS) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1447,14 +1447,14 @@ static void test_delete_transaction_isolation(void **state) key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); key.length = strlen(KEY2 + 1); - ret = ltdb->kv_ops->lock_read(ldb->modules); + ret = ldb_kv->kv_ops->lock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": lock_read returned (%d)\n", ret); exit(ret); } - ret = ltdb->kv_ops->fetch_and_parse(ltdb, key, parse, &val); + ret = ldb_kv->kv_ops->fetch_and_parse(ldb_kv, key, parse, &val); if (ret != LDB_ERR_NO_SUCH_OBJECT) { print_error(__location__": fetch_and_parse returned " "(%d)\n", @@ -1462,7 +1462,7 @@ static void test_delete_transaction_isolation(void **state) exit(ret); } - ret = ltdb->kv_ops->unlock_read(ldb->modules); + ret = ldb_kv->kv_ops->unlock_read(ldb->modules); if (ret != LDB_SUCCESS) { print_error(__location__": unlock_read returned (%d)\n", ret); @@ -1478,13 +1478,13 @@ static void test_delete_transaction_isolation(void **state) * Begin a transaction and delete a record from the database * but leave the transaction open */ - ret = ltdb->kv_ops->begin_write(ltdb); + ret = ldb_kv->kv_ops->begin_write(ldb_kv); assert_int_equal(ret, 0); key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2); key.length = strlen(KEY2) + 1; - ret = ltdb->kv_ops->delete(ltdb, key); + ret = ldb_kv->kv_ops->delete(ldb_kv, key); assert_int_equal(ret, 0); /* * Signal the child process @@ -1502,7 +1502,7 @@ static void test_delete_transaction_isolation(void **state) /* * commit the transaction */ - ret = ltdb->kv_ops->finish_write(ltdb); + ret = ldb_kv->kv_ops->finish_write(ldb_kv); assert_int_equal(0, ret); /* diff --git a/lib/ldb/tests/ldb_lmdb_test.c b/lib/ldb/tests/ldb_lmdb_test.c index a254a849f4a..364a4f6cff1 100644 --- a/lib/ldb/tests/ldb_lmdb_test.c +++ b/lib/ldb/tests/ldb_lmdb_test.c @@ -414,17 +414,17 @@ static void test_ldb_add_dn_no_guid_mode(void **state) static struct MDB_env *get_mdb_env(struct ldb_context *ldb) { void *data = NULL; - struct ltdb_private *ltdb = NULL; + struct ldb_kv_private *ldb_kv = NULL; struct lmdb_private *lmdb = NULL; struct MDB_env *env = NULL; data = ldb_module_get_private(ldb->modules); assert_non_null(data); - ltdb = talloc_get_type(data, struct ltdb_private); - assert_non_null(ltdb); + ldb_kv = talloc_get_type(data, struct ldb_kv_private); + assert_non_null(ldb_kv); - lmdb = ltdb->lmdb_private; + lmdb = ldb_kv->lmdb_private; assert_non_null(lmdb); env = lmdb->env; diff --git a/lib/ldb/tests/ldb_tdb_test.c b/lib/ldb/tests/ldb_tdb_test.c index 686a35104ea..226fcb1d454 100644 --- a/lib/ldb/tests/ldb_tdb_test.c +++ b/lib/ldb/tests/ldb_tdb_test.c @@ -150,16 +150,16 @@ static int ldbtest_teardown(void **state) static TDB_CONTEXT *get_tdb_context(struct ldb_context *ldb) { void *data = NULL; - struct ltdb_private *ltdb = NULL; + struct ldb_kv_private *ldb_kv = NULL; TDB_CONTEXT *tdb = NULL; data = ldb_module_get_private(ldb->modules); assert_non_null(data); - ltdb = talloc_get_type(data, struct ltdb_private); - assert_non_null(ltdb); + ldb_kv = talloc_get_type(data, struct ldb_kv_private); + assert_non_null(ldb_kv); - tdb = ltdb->tdb; + tdb = ldb_kv->tdb; assert_non_null(tdb); return tdb; -- 2.34.1