struct ldb_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_reply *))
+ struct ldb_request *req)
{
struct ltdb_context *ac;
struct ldb_handle *h;
- h = talloc_zero(ltdb, struct ldb_handle);
+ h = talloc_zero(req, struct ldb_handle);
if (h == NULL) {
ldb_set_errstring(module->ldb, "Out of Memory");
return NULL;
h->status = LDB_SUCCESS;
ac->module = module;
- ac->context = context;
- ac->callback = callback;
+ ac->context = req->context;
+ ac->callback = req->callback;
return h;
}
the rest
*/
- dn_folded = ldb_dn_linearize_casefold(ldb, dn);
+ dn_folded = ldb_dn_linearize_casefold(ldb, ldb, dn);
if (!dn_folded) {
goto failed;
}
*/
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
int ret;
}
}
- req->handle = init_ltdb_handle(ltdb, module, req->context, req->callback);
+ req->handle = init_ltdb_handle(ltdb, module, req);
if (req->handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
*/
int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
TDB_DATA tdb_key;
int ret;
ret = ltdb_modified(module, dn);
if (ret != LDB_SUCCESS) {
+ talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = init_ltdb_handle(ltdb, module, req->context, req->callback);
+ req->handle = init_ltdb_handle(ltdb, module, req);
if (req->handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg)
{
struct ldb_context *ldb = module->ldb;
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
struct ldb_message *msg2;
unsigned i, j;
req->handle = NULL;
- req->handle = init_ltdb_handle(ltdb, module, req->context, req->callback);
+ req->handle = init_ltdb_handle(ltdb, module, req);
if (req->handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle = init_ltdb_handle(ltdb, module, req->context, req->callback);
+ req->handle = init_ltdb_handle(ltdb, module, req);
if (req->handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
static int ltdb_start_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
if (tdb_transaction_start(ltdb->tdb) != 0) {
return ltdb_err_map(tdb_error(ltdb->tdb));
static int ltdb_end_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
if (tdb_transaction_commit(ltdb->tdb) != 0) {
return ltdb_err_map(tdb_error(ltdb->tdb));
static int ltdb_del_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb = module->private_data;
+ struct ltdb_private *ltdb =
+ talloc_get_type(module->private_data, struct ltdb_private);
if (tdb_transaction_cancel(ltdb->tdb) != 0) {
return ltdb_err_map(tdb_error(ltdb->tdb));
path = url;
}
- tdb_flags = TDB_DEFAULT;
+ tdb_flags = TDB_DEFAULT | TDB_SEQNUM;
/* check for the 'nosync' option */
if (flags & LDB_FLG_NOSYNC) {
talloc_free(ltdb);
return -1;
}
+ talloc_set_name_const(*module, "ldb_tdb backend");
(*module)->ldb = ldb;
(*module)->prev = (*module)->next = NULL;
(*module)->private_data = ltdb;
(*module)->ops = <db_ops;
+ if (ltdb_cache_load(*module) != 0) {
+ talloc_free(*module);
+ talloc_free(ltdb);
+ return -1;
+ }
+
return 0;
}