summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-01-29 18:39:30 -0500
committerSimo Sorce <idra@samba.org>2009-01-30 01:02:03 -0500
commit380874ef863866c94c999ef53252b9d30df65e88 (patch)
treeaafdb720253d5a6013e2a23a0e81b0a9b90f054b /source4
parenta5f0640bf99e6f7e38b0b1e7a7a56f8f58ec7e47 (diff)
downloadsamba-380874ef863866c94c999ef53252b9d30df65e88.tar.gz
samba-380874ef863866c94c999ef53252b9d30df65e88.tar.bz2
samba-380874ef863866c94c999ef53252b9d30df65e88.zip
Fix the mess with ldb includes.
Separate again the public from the private headers. Add a new header specific for modules. Also add service function for modules as now ldb_context and ldb_module are opaque structures for them.
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/repl/drepl_periodic.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/anr.c41
-rw-r--r--source4/dsdb/samdb/ldb_modules/config.mk2
-rw-r--r--source4/dsdb/samdb/ldb_modules/instancetype.c23
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c22
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/ranged_results.c27
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_delete.c16
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_rename.c21
-rw-r--r--source4/dsdb/samdb/ldb_modules/update_keytab.c67
-rw-r--r--source4/lib/ldb-samba/ldif_handlers.c2
-rw-r--r--source4/lib/ldb/common/attrib_handlers.c2
-rw-r--r--source4/lib/ldb/common/ldb.c17
-rw-r--r--source4/lib/ldb/common/ldb_attributes.c2
-rw-r--r--source4/lib/ldb/common/ldb_controls.c2
-rw-r--r--source4/lib/ldb/common/ldb_debug.c2
-rw-r--r--source4/lib/ldb/common/ldb_dn.c2
-rw-r--r--source4/lib/ldb/common/ldb_ldif.c2
-rw-r--r--source4/lib/ldb/common/ldb_match.c2
-rw-r--r--source4/lib/ldb/common/ldb_modules.c37
-rw-r--r--source4/lib/ldb/common/ldb_msg.c2
-rw-r--r--source4/lib/ldb/common/ldb_parse.c2
-rw-r--r--source4/lib/ldb/common/ldb_utf8.c2
-rw-r--r--source4/lib/ldb/common/qsort.c2
-rw-r--r--source4/lib/ldb/examples/ldbreader.c2
-rw-r--r--source4/lib/ldb/examples/ldifreader.c2
-rw-r--r--source4/lib/ldb/include/dlinklist.h4
-rw-r--r--source4/lib/ldb/include/ldb.h6
-rw-r--r--source4/lib/ldb/include/ldb_includes.h2
-rw-r--r--source4/lib/ldb/include/ldb_module.h160
-rw-r--r--source4/lib/ldb/include/ldb_private.h105
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c62
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c110
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.c83
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_inbound.c72
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_outbound.c33
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_private.h2
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_cache.c59
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c100
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_pack.c8
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c39
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c129
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h2
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c2
-rw-r--r--source4/lib/ldb/modules/asq.c36
-rw-r--r--source4/lib/ldb/modules/operational.c12
-rw-r--r--source4/lib/ldb/modules/paged_results.c19
-rw-r--r--source4/lib/ldb/modules/paged_searches.c27
-rw-r--r--source4/lib/ldb/modules/rdn_name.c26
-rw-r--r--source4/lib/ldb/modules/skel.c15
-rw-r--r--source4/lib/ldb/modules/sort.c32
-rw-r--r--source4/lib/ldb/pyldb.c2
-rw-r--r--source4/lib/ldb/tests/sample_module.c4
-rw-r--r--source4/lib/ldb/tools/cmdline.c8
-rw-r--r--source4/lib/ldb/tools/ldbadd.c2
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source4/lib/ldb/tools/ldbrename.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c2
-rw-r--r--source4/lib/ldb/tools/ldbtest.c2
-rw-r--r--source4/libcli/ldap/config.mk2
-rw-r--r--source4/libcli/ldap/ldap.h43
-rw-r--r--source4/libcli/ldap/ldap_errors.h66
-rw-r--r--source4/libcli/security/security_token.c1
-rw-r--r--source4/libcli/util/nterr.c2
-rw-r--r--source4/nbt_server/config.mk2
-rw-r--r--source4/nbt_server/wins/wins_ldb.c1
-rw-r--r--source4/ntvfs/ipc/rap_server.c1
-rw-r--r--source4/ntvfs/posix/vfs_posix.c1
-rw-r--r--source4/ntvfs/posix/vfs_posix.h2
-rw-r--r--source4/rpc_server/config.mk1
-rw-r--r--source4/smb_server/smb_samba3.c1
-rw-r--r--source4/utils/ad2oLschema.c2
-rw-r--r--source4/utils/net/net_machinepw.c2
-rw-r--r--source4/utils/oLschema2ldif.c2
77 files changed, 1031 insertions, 578 deletions
diff --git a/source4/dsdb/repl/drepl_periodic.c b/source4/dsdb/repl/drepl_periodic.c
index 4a6de8d700..b88d2cee1e 100644
--- a/source4/dsdb/repl/drepl_periodic.c
+++ b/source4/dsdb/repl/drepl_periodic.c
@@ -20,10 +20,10 @@
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "smbd/service.h"
-#include "lib/events/events.h"
#include "lib/messaging/irpc.h"
#include "dsdb/repl/drepl_service.h"
#include "lib/ldb/include/ldb_errors.h"
diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c
index 49e453ffa1..a04f5ebfa6 100644
--- a/source4/dsdb/samdb/ldb_modules/anr.c
+++ b/source4/dsdb/samdb/ldb_modules/anr.c
@@ -30,7 +30,7 @@
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "dsdb/samdb/samdb.h"
/**
@@ -40,11 +40,14 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module,
TALLOC_CTX *mem_ctx, enum ldb_parse_op op,
struct ldb_parse_tree *first_arm, struct ldb_parse_tree *second_arm)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *list;
+ ldb = ldb_module_get_ctx(module);
+
list = talloc(mem_ctx, struct ldb_parse_tree);
if (list == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
list->operation = op;
@@ -52,7 +55,7 @@ static struct ldb_parse_tree *make_parse_list(struct ldb_module *module,
list->u.list.num_elements = 2;
list->u.list.elements = talloc_array(list, struct ldb_parse_tree *, 2);
if (!list->u.list.elements) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
list->u.list.elements[0] = talloc_steal(list, first_arm);
@@ -67,8 +70,11 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module,
TALLOC_CTX *mem_ctx, enum ldb_parse_op op,
const char *attr, const DATA_BLOB *match)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *match_tree;
+ ldb = ldb_module_get_ctx(module);
+
match_tree = talloc(mem_ctx, struct ldb_parse_tree);
/* Depending on what type of match was selected, fill in the right part of the union */
@@ -83,7 +89,7 @@ static struct ldb_parse_tree *make_match_tree(struct ldb_module *module,
match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2);
if (match_tree->u.substring.chunks == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
match_tree->u.substring.chunks[0] = match;
@@ -120,12 +126,16 @@ static int anr_replace_value(struct anr_context *ac,
struct ldb_module *module = ac->module;
struct ldb_parse_tree *match_tree;
struct dsdb_attribute *cur;
- const struct dsdb_schema *schema = dsdb_get_schema(module->ldb);
+ const struct dsdb_schema *schema;
+ struct ldb_context *ldb;
uint8_t *p;
enum ldb_parse_op op;
+ ldb = ldb_module_get_ctx(module);
+
+ schema = dsdb_get_schema(ldb);
if (!schema) {
- ldb_asprintf_errstring(module->ldb, "no schema with which to construct anr filter");
+ ldb_asprintf_errstring(ldb, "no schema with which to construct anr filter");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -135,7 +145,7 @@ static int anr_replace_value(struct anr_context *ac,
DATA_BLOB *match2 = talloc(mem_ctx, DATA_BLOB);
*match2 = data_blob_const(match->data+1, match->length - 1);
if (match2 == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
match = match2;
@@ -151,7 +161,7 @@ static int anr_replace_value(struct anr_context *ac,
/* Inject an 'or' with the current tree */
tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree);
if (tree == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
@@ -170,7 +180,7 @@ static int anr_replace_value(struct anr_context *ac,
DATA_BLOB *first_match = talloc(tree, DATA_BLOB);
DATA_BLOB *second_match = talloc(tree, DATA_BLOB);
if (!first_match || !second_match) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
*first_match = data_blob_const(match->data, p-match->data);
@@ -183,7 +193,7 @@ static int anr_replace_value(struct anr_context *ac,
first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2);
if (first_split_filter == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -192,14 +202,14 @@ static int anr_replace_value(struct anr_context *ac,
second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2);
if (second_split_filter == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR,
first_split_filter, second_split_filter);
if (split_filters == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -305,14 +315,17 @@ static int anr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
/* search */
static int anr_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *anr_tree;
struct ldb_request *down_req;
struct anr_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc(req, struct anr_context);
if (!ac) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -335,7 +348,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req)
}
ret = ldb_build_search_req_ex(&down_req,
- module->ldb, ac,
+ ldb, ac,
req->op.search.base,
req->op.search.scope,
anr_tree,
diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk
index 1c50923eba..01f5188b6f 100644
--- a/source4/dsdb/samdb/ldb_modules/config.mk
+++ b/source4/dsdb/samdb/ldb_modules/config.mk
@@ -2,7 +2,7 @@
# Start MODULE ldb_objectguid
[MODULE::ldb_objectguid]
SUBSYSTEM = LIBLDB
-PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR
+PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR
INIT_FUNCTION = LDB_MODULE(objectguid)
# End MODULE ldb_objectguid
################################################
diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c
index a8c45dee4c..8d648d6d82 100644
--- a/source4/dsdb/samdb/ldb_modules/instancetype.c
+++ b/source4/dsdb/samdb/ldb_modules/instancetype.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
@@ -47,10 +47,11 @@ struct it_context {
static int it_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct it_context *ac;
ac = talloc_get_type(req->context, struct it_context);
-
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -62,7 +63,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares)
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -74,6 +75,7 @@ static int it_callback(struct ldb_request *req, struct ldb_reply *ares)
/* add_record: add instancetype attribute */
static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message *msg;
struct it_context *ac;
@@ -81,9 +83,10 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
int ret;
const struct ldb_control *partition_ctrl;
const struct dsdb_control_current_partition *partition;
-
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
@@ -92,7 +95,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID);
if (!partition_ctrl) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"instancetype_add: no current partition control found");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
@@ -111,7 +114,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
/* we have to copy the message as the caller might have it as a const */
msg = ldb_msg_copy_shallow(ac, req->op.add.message);
if (msg == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -121,18 +124,18 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
instance_type = INSTANCE_TYPE_WRITE;
if (ldb_dn_compare(partition->dn, msg->dn) == 0) {
instance_type |= INSTANCE_TYPE_IS_NC_HEAD;
- if (ldb_dn_compare(msg->dn, samdb_base_dn(module->ldb)) != 0) {
+ if (ldb_dn_compare(msg->dn, samdb_base_dn(ldb)) != 0) {
instance_type |= INSTANCE_TYPE_NC_ABOVE;
}
}
ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type);
if (ret != LDB_SUCCESS) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
msg,
req->controls,
ac, it_callback,
diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index 3d725686e7..46ba8ebdb3 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -34,7 +34,7 @@
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "param/param.h"
@@ -136,6 +136,7 @@ static int og_op_callback(struct ldb_request *req, struct ldb_reply *ares)
/* add_record: add objectGUID attribute */
static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message_element *attribute;
struct ldb_message *msg;
@@ -147,7 +148,9 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
time_t t = time(NULL);
struct og_context *ac;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
@@ -176,7 +179,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
guid = GUID_random();
ndr_err = ndr_push_struct_blob(&v, msg,
- lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")),
+ lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
&guid,
(ndr_push_flags_fn_t)ndr_push_GUID);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
@@ -196,7 +199,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
/* Get a sequence number from the backend */
/* FIXME: ldb_sequence_number is a semi-async call,
* make sure this function is split and a callback is used */
- ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num);
+ ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 ||
add_uint64_element(msg, "uSNChanged", seq_num) != 0) {
@@ -204,7 +207,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
}
}
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
msg,
req->controls,
ac, og_op_callback,
@@ -220,6 +223,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
/* modify_record: update timestamps */
static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message *msg;
int ret;
@@ -227,7 +231,9 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
uint64_t seq_num;
struct og_context *ac;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
@@ -252,14 +258,14 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
}
/* Get a sequence number from the backend */
- ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num);
+ ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
}
- ret = ldb_build_mod_req(&down_req, module->ldb, ac,
+ ret = ldb_build_mod_req(&down_req, ldb, ac,
msg,
req->controls,
ac, og_op_callback,
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 0000c87f72..71a1b8e942 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -34,7 +34,7 @@
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_private.h"
#include "dsdb/samdb/samdb.h"
struct partition_private_data {
diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c
index eeb161bdde..8f36baa7d6 100644
--- a/source4/dsdb/samdb/ldb_modules/ranged_results.c
+++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c
@@ -29,7 +29,7 @@
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct rr_context {
struct ldb_module *module;
@@ -43,7 +43,7 @@ static struct rr_context *rr_init_context(struct ldb_module *module,
ac = talloc_zero(req, struct rr_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb_module_get_ctx(module), "Out of Memory");
return NULL;
}
@@ -55,10 +55,12 @@ static struct rr_context *rr_init_context(struct ldb_module *module,
static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct rr_context *ac;
int i, j;
ac = talloc_get_type(req->context, struct rr_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -106,7 +108,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
(size_t)(p - ac->req->op.search.attrs[i]));
if (!new_attr) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -123,7 +125,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
} else {
end_str = talloc_asprintf(el, "%u", end);
if (!end_str) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -137,7 +139,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
orig_num_values = el->num_values;
if ((start + end < start) || (start + end < end)) {
- ldb_asprintf_errstring(ac->module->ldb,
+ ldb_asprintf_errstring(ldb,
"range request error: start or end would overflow!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_UNWILLING_TO_PERFORM);
@@ -147,7 +149,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
el->values = talloc_array(el, struct ldb_val, (end - start) + 1);
if (!el->values) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -158,7 +160,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
}
el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str);
if (!el->name) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -170,6 +172,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
/* search */
static int rr_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
int i;
unsigned int start, end;
const char **new_attrs = NULL;
@@ -178,6 +181,8 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req)
struct rr_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Strip the range request from the attribute */
for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) {
char *p;
@@ -194,14 +199,14 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req)
end = (unsigned int)-1;
if (sscanf(p, ";range=%u-*", &start) != 1) {
if (sscanf(p, ";range=%u-%u", &start, &end) != 2) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"range request error: "
"range request malformed");
return LDB_ERR_UNWILLING_TO_PERFORM;
}
}
if (start > end) {
- ldb_asprintf_errstring(module->ldb, "range request error: start must not be greater than end");
+ ldb_asprintf_errstring(ldb, "range request error: start must not be greater than end");
return LDB_ERR_UNWILLING_TO_PERFORM;
}
@@ -210,7 +215,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req)
(size_t)(p - new_attrs[i]));
if (!new_attrs[i]) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
}
@@ -221,7 +226,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&down_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index 10e2dc25ce..55a24549dd 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -29,7 +29,7 @@
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct subtree_delete_context {
struct ldb_module *module;
@@ -41,11 +41,14 @@ struct subtree_delete_context {
static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct subtree_delete_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct subtree_delete_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
@@ -58,10 +61,12 @@ static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module,
static int subtree_delete_search_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct subtree_delete_context *ac;
int ret;
ac = talloc_get_type(req->context, struct subtree_delete_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -89,7 +94,7 @@ static int subtree_delete_search_callback(struct ldb_request *req,
if (ac->num_children > 0) {
talloc_free(ares);
- ldb_asprintf_errstring(ac->module->ldb,
+ ldb_asprintf_errstring(ldb,
"Cannot delete %s, not a leaf node "
"(has %d children)\n",
ldb_dn_get_linearized(ac->req->op.del.dn),
@@ -112,6 +117,7 @@ static int subtree_delete_search_callback(struct ldb_request *req,
static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
static const char * const attrs[2] = { "distinguishedName", NULL };
struct ldb_request *search_req;
struct subtree_delete_context *ac;
@@ -120,6 +126,8 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
+ ldb = ldb_module_get_ctx(module);
+
/* This gets complex: We need to:
- Do a search for all entires under this entry
- Wait for these results to appear
@@ -135,7 +143,7 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
/* we do not really need to find all descendents,
* if there is even one single direct child, that's
* enough to bail out */
- ret = ldb_build_search_req(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req(&search_req, ldb, ac,
req->op.del.dn, LDB_SCOPE_ONELEVEL,
"(objectClass=*)", attrs,
req->controls,
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c
index d3ceb8ad97..e2f6b1d059 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c
@@ -28,7 +28,7 @@
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct subren_msg_store {
struct subren_msg_store *next;
@@ -47,11 +47,14 @@ struct subtree_rename_context {
static struct subtree_rename_context *subren_ctx_init(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct subtree_rename_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct subtree_rename_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
@@ -66,10 +69,12 @@ static int subtree_rename_next_request(struct subtree_rename_context *ac);
static int subtree_rename_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct subtree_rename_context *ac;
int ret;
ac = talloc_get_type(req->context, struct subtree_rename_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -82,7 +87,7 @@ static int subtree_rename_callback(struct ldb_request *req,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(ac->module->ldb, "Invalid reply type!\n");
+ ldb_set_errstring(ldb, "Invalid reply type!\n");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -104,14 +109,17 @@ static int subtree_rename_callback(struct ldb_request *req,
static int subtree_rename_next_request(struct subtree_rename_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (ac->current == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_rename_req(&req, ac->module->ldb, ac->current,
+ ret = ldb_build_rename_req(&req, ldb, ac->current,
ac->current->olddn,
ac->current->newdn,
ac->req->controls,
@@ -204,6 +212,7 @@ static int subtree_rename_search_callback(struct ldb_request *req,
/* rename */
static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
static const char *attrs[2] = { "distinguishedName", NULL };
struct ldb_request *search_req;
struct subtree_rename_context *ac;
@@ -212,6 +221,8 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
+ ldb = ldb_module_get_ctx(module);
+
/* This gets complex: We need to:
- Do a search for all entires under this entry
- Wait for these results to appear
@@ -235,7 +246,7 @@ static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
ac->current->newdn = req->op.rename.newdn;
ac->list = ac->current;
- ret = ldb_build_search_req(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req(&search_req, ldb, ac,
req->op.rename.olddn,
LDB_SCOPE_SUBTREE,
"(objectClass=*)",
diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c
index 7b82763403..e178ebb9dc 100644
--- a/source4/dsdb/samdb/ldb_modules/update_keytab.c
+++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c
@@ -28,7 +28,7 @@
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "system/kerberos.h"
@@ -60,7 +60,7 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module,
ac = talloc_zero(req, struct update_kt_ctx);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb_module_get_ctx(module));
return NULL;
}
@@ -76,7 +76,8 @@ static struct update_kt_ctx *update_kt_ctx_init(struct ldb_module *module,
* of async issues). -SSS
*/
static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) {
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
struct dn_list *item;
char *filter;
struct ldb_result *res;
@@ -87,11 +88,11 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet
filter = talloc_asprintf(data, "(&(dn=%s)(&(objectClass=kerberosSecret)(privateKeytab=*)))",
ldb_dn_get_linearized(dn));
if (!filter) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(module->ldb, data, &res,
+ ret = ldb_search(ldb, data, &res,
dn, LDB_SCOPE_BASE, attrs, "%s", filter);
if (ret != LDB_SUCCESS) {
talloc_free(filter);
@@ -109,7 +110,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet
item = talloc(data->changed_dns? (void *)data->changed_dns: (void *)data, struct dn_list);
if (!item) {
talloc_free(filter);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -117,12 +118,12 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet
if (!item->creds) {
DEBUG(1, ("cli_credentials_init failed!"));
talloc_free(filter);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm"));
- status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
+ cli_credentials_set_conf(item->creds, ldb_get_opaque(ldb, "loadparm"));
+ status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"), ldb, NULL, filter);
talloc_free(filter);
if (NT_STATUS_IS_OK(status)) {
if (delete) {
@@ -142,10 +143,12 @@ static int ukt_search_modified(struct update_kt_ctx *ac);
static int update_kt_op_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
int ret;
ac = talloc_get_type(req->context, struct update_kt_ctx);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -157,7 +160,7 @@ static int update_kt_op_callback(struct ldb_request *req,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(ac->module->ldb, "Invalid request type!\n");
+ ldb_set_errstring(ldb, "Invalid request type!\n");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -179,10 +182,13 @@ static int update_kt_op_callback(struct ldb_request *req,
static int ukt_del_op(struct update_kt_ctx *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
int ret;
- ret = ldb_build_del_req(&down_req, ac->module->ldb, ac,
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ret = ldb_build_del_req(&down_req, ldb, ac,
ac->dn,
ac->req->controls,
ac, update_kt_op_callback,
@@ -246,11 +252,14 @@ static int ukt_search_modified_callback(struct ldb_request *req,
static int ukt_search_modified(struct update_kt_ctx *ac)
{
+ struct ldb_context *ldb;
static const char * const attrs[] = { "distinguishedName", NULL };
struct ldb_request *search_req;
int ret;
- ret = ldb_build_search_req(&search_req, ac->module->ldb, ac,
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ret = ldb_build_search_req(&search_req, ldb, ac,
ac->dn, LDB_SCOPE_BASE,
"(&(objectClass=kerberosSecret)"
"(privateKeytab=*))", attrs,
@@ -267,10 +276,13 @@ static int ukt_search_modified(struct update_kt_ctx *ac)
/* add */
static int update_kt_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -278,7 +290,7 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req)
ac->dn = req->op.add.message->dn;
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
req->op.add.message,
req->controls,
ac, update_kt_op_callback,
@@ -293,10 +305,13 @@ static int update_kt_add(struct ldb_module *module, struct ldb_request *req)
/* modify */
static int update_kt_modify(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -304,7 +319,7 @@ static int update_kt_modify(struct ldb_module *module, struct ldb_request *req)
ac->dn = req->op.mod.message->dn;
- ret = ldb_build_mod_req(&down_req, module->ldb, ac,
+ ret = ldb_build_mod_req(&down_req, ldb, ac,
req->op.mod.message,
req->controls,
ac, update_kt_op_callback,
@@ -335,10 +350,13 @@ static int update_kt_delete(struct ldb_module *module, struct ldb_request *req)
/* rename */
static int update_kt_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -346,7 +364,7 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req)
ac->dn = req->op.rename.newdn;
- ret = ldb_build_rename_req(&down_req, module->ldb, ac,
+ ret = ldb_build_rename_req(&down_req, ldb, ac,
req->op.rename.olddn,
req->op.rename.newdn,
req->controls,
@@ -362,16 +380,19 @@ static int update_kt_rename(struct ldb_module *module, struct ldb_request *req)
/* end a transaction */
static int update_kt_end_trans(struct ldb_module *module)
{
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct ldb_context *ldb;
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
struct dn_list *p;
+ ldb = ldb_module_get_ctx(module);
+
for (p=data->changed_dns; p; p = p->next) {
int kret;
- kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"));
+ kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"));
if (kret != 0) {
talloc_free(data->changed_dns);
data->changed_dns = NULL;
- ldb_asprintf_errstring(module->ldb, "Failed to update keytab: %s", error_message(kret));
+ ldb_asprintf_errstring(ldb, "Failed to update keytab: %s", error_message(kret));
return LDB_ERR_OPERATIONS_ERROR;
}
}
@@ -385,7 +406,7 @@ static int update_kt_end_trans(struct ldb_module *module)
/* end a transaction */
static int update_kt_del_trans(struct ldb_module *module)
{
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
talloc_free(data->changed_dns);
data->changed_dns = NULL;
@@ -395,17 +416,21 @@ static int update_kt_del_trans(struct ldb_module *module)
static int update_kt_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct update_kt_private *data;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct update_kt_private);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
data->changed_dns = NULL;
+ ldb_module_set_private(module, data);
+
return ldb_next_init(module);
}
diff --git a/source4/lib/ldb-samba/ldif_handlers.c b/source4/lib/ldb-samba/ldif_handlers.c
index 5ab31d771b..d92f211946 100644
--- a/source4/lib/ldb-samba/ldif_handlers.c
+++ b/source4/lib/ldb-samba/ldif_handlers.c
@@ -22,7 +22,7 @@
*/
#include "includes.h"
-#include "lib/ldb/include/ldb_includes.h"
+#include "ldb_private.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_misc.h"
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index 5ec86b5b8f..80725ec04f 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -25,7 +25,7 @@
see rfc2252
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
#include "ldb_handlers.h"
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index fe55d1499a..2fb5a8f9be 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -32,7 +32,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
initialise a ldb context
@@ -481,6 +481,11 @@ void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms)
ldb->create_perms = perms;
}
+unsigned int ldb_get_create_perms(struct ldb_context *ldb)
+{
+ return ldb->create_perms;
+}
+
void ldb_set_event_context(struct ldb_context *ldb, struct tevent_context *ev)
{
ldb->ev_ctx = ev;
@@ -491,6 +496,16 @@ struct tevent_context * ldb_get_event_context(struct ldb_context *ldb)
return ldb->ev_ctx;
}
+void ldb_request_set_state(struct ldb_request *req, int state)
+{
+ req->handle->state = state;
+}
+
+int ldb_request_get_status(struct ldb_request *req)
+{
+ return req->handle->status;
+}
+
/*
start an ldb request
NOTE: the request must be a talloc context.
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c
index 001bc45ee1..4d688a4d7e 100644
--- a/source4/lib/ldb/common/ldb_attributes.c
+++ b/source4/lib/ldb/common/ldb_attributes.c
@@ -28,7 +28,7 @@
message matching logic generic
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
add a attribute to the ldb_schema
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index 6fad5012b6..0c587e0905 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -31,7 +31,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/* check if a control with the specified "oid" exist and return it */
/* returns NULL if not found */
diff --git a/source4/lib/ldb/common/ldb_debug.c b/source4/lib/ldb/common/ldb_debug.c
index 0f78e37c1c..f8009eb8a3 100644
--- a/source4/lib/ldb/common/ldb_debug.c
+++ b/source4/lib/ldb/common/ldb_debug.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
this allows the user to choose their own debug function
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index 02e21a2b25..402d629501 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -33,7 +33,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include <ctype.h>
#define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed
diff --git a/source4/lib/ldb/common/ldb_ldif.c b/source4/lib/ldb/common/ldb_ldif.c
index 619c10e11e..400fb352ff 100644
--- a/source4/lib/ldb/common/ldb_ldif.c
+++ b/source4/lib/ldb/common/ldb_ldif.c
@@ -35,7 +35,7 @@
see RFC2849 for the LDIF format definition
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
/*
diff --git a/source4/lib/ldb/common/ldb_match.c b/source4/lib/ldb/common/ldb_match.c
index 4cde739d67..c622701d30 100644
--- a/source4/lib/ldb/common/ldb_match.c
+++ b/source4/lib/ldb/common/ldb_match.c
@@ -32,7 +32,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
check if the scope matches in a search result
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 8db28d262c..03d1e6ebe2 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -31,7 +31,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#if (_SAMBA_BUILD_ >= 4)
#include "includes.h"
@@ -486,6 +486,41 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
} while (0)
+struct ldb_module *ldb_module_new(TALLOC_CTX *memctx,
+ struct ldb_context *ldb,
+ const char *module_name,
+ const struct ldb_module_ops *ops)
+{
+ struct ldb_module *module;
+
+ module = talloc(memctx, struct ldb_module);
+ if (!module) {
+ ldb_oom(ldb);
+ return NULL;
+ }
+ talloc_set_name_const(module, module_name);
+ module->ldb = ldb;
+ module->prev = module->next = NULL;
+ module->ops = ops;
+
+ return module;
+}
+
+struct ldb_context *ldb_module_get_ctx(struct ldb_module *module)
+{
+ return module->ldb;
+}
+
+void *ldb_module_get_private(struct ldb_module *module)
+{
+ return module->private_data;
+}
+
+void ldb_module_set_private(struct ldb_module *module, void *private_data)
+{
+ module->private_data = private_data;
+}
+
/*
helper functions to call the next module in chain
*/
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index 2f5fe1d18c..ad53a3d29d 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
create a new ldb_message in a given memory context (NULL for top level)
diff --git a/source4/lib/ldb/common/ldb_parse.c b/source4/lib/ldb/common/ldb_parse.c
index b233975220..654a635abf 100644
--- a/source4/lib/ldb/common/ldb_parse.c
+++ b/source4/lib/ldb/common/ldb_parse.c
@@ -40,7 +40,7 @@
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
/*
diff --git a/source4/lib/ldb/common/ldb_utf8.c b/source4/lib/ldb/common/ldb_utf8.c
index 69ee2b6964..0a8a89ac1d 100644
--- a/source4/lib/ldb/common/ldb_utf8.c
+++ b/source4/lib/ldb/common/ldb_utf8.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
diff --git a/source4/lib/ldb/common/qsort.c b/source4/lib/ldb/common/qsort.c
index 0fa76d3b47..1a0b886b8c 100644
--- a/source4/lib/ldb/common/qsort.c
+++ b/source4/lib/ldb/common/qsort.c
@@ -23,7 +23,7 @@
* Simo Sorce <idra@samba.org> 2005
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/* Byte-wise swap two items of size SIZE. */
#define SWAP(a, b, size) \
diff --git a/source4/lib/ldb/examples/ldbreader.c b/source4/lib/ldb/examples/ldbreader.c
index e48b3d338a..3496baf4ce 100644
--- a/source4/lib/ldb/examples/ldbreader.c
+++ b/source4/lib/ldb/examples/ldbreader.c
@@ -29,9 +29,7 @@ It lists / dumps the records in a LDB database to standard output.
*/
-#include "ldb_includes.h"
#include "ldb.h"
-#include "ldb_errors.h"
/*
ldb_ldif_write takes a function pointer to a custom output
diff --git a/source4/lib/ldb/examples/ldifreader.c b/source4/lib/ldb/examples/ldifreader.c
index 12e7a1a6fd..dcd9daf812 100644
--- a/source4/lib/ldb/examples/ldifreader.c
+++ b/source4/lib/ldb/examples/ldifreader.c
@@ -29,9 +29,7 @@ It lists / dumps the entries in an LDIF file to standard output.
*/
-#include "ldb_includes.h"
#include "ldb.h"
-#include "ldb_errors.h"
/*
ldb_ldif_write takes a function pointer to a custom output
diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h
index d3252751db..acab9fa043 100644
--- a/source4/lib/ldb/include/dlinklist.h
+++ b/source4/lib/ldb/include/dlinklist.h
@@ -20,6 +20,8 @@
/* To use these macros you must have a structure containing a next and
prev pointer */
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
/* hook into the front of the list */
#define DLIST_ADD(list, p) \
@@ -108,3 +110,5 @@ do { \
} \
} \
} while (0)
+
+#endif /* _DLINKLIST_H */
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 28c54f5a3c..589887b4c5 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -46,18 +46,18 @@
#define _LDB_H_ 1
/*! \endcond */
+#include "ldb_includes.h"
+
/*
major restrictions as compared to normal LDAP:
- - no async calls.
- each record must have a unique key field
- the key must be representable as a NULL terminated C string and may not
contain a comma or braces
major restrictions as compared to tdb:
- - no explicit locking calls
- UPDATE: we have transactions now, better than locking --SSS.
+ - no explicit locking calls, but we have transactions when using ldb_tdb
*/
diff --git a/source4/lib/ldb/include/ldb_includes.h b/source4/lib/ldb/include/ldb_includes.h
index 8356404409..a2927139c8 100644
--- a/source4/lib/ldb/include/ldb_includes.h
+++ b/source4/lib/ldb/include/ldb_includes.h
@@ -21,9 +21,7 @@
#include "system/time.h"
#include <talloc.h>
#include <tevent.h>
-#include "ldb.h"
#include "ldb_errors.h"
-#include "ldb_private.h"
#include "dlinklist.h"
#endif /*_LDB_PRIVATE_INCLUDES_H_*/
diff --git a/source4/lib/ldb/include/ldb_module.h b/source4/lib/ldb/include/ldb_module.h
new file mode 100644
index 0000000000..8742b1058c
--- /dev/null
+++ b/source4/lib/ldb/include/ldb_module.h
@@ -0,0 +1,160 @@
+/*
+ ldb database library
+
+ Copyright (C) Simo Sorce 2008
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * Name: ldb
+ *
+ * Component: ldb module header
+ *
+ * Description: defines ldb modules structures and helpers
+ *
+ */
+
+#ifndef _LDB_MODULE_H_
+#define _LDB_MODULE_H_
+
+#include "ldb.h"
+
+struct ldb_context;
+struct ldb_module;
+
+/*
+ these function pointers define the operations that a ldb module can intercept
+*/
+struct ldb_module_ops {
+ const char *name;
+ int (*init_context) (struct ldb_module *);
+ int (*search)(struct ldb_module *, struct ldb_request *); /* search */
+ int (*add)(struct ldb_module *, struct ldb_request *); /* add */
+ int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */
+ int (*del)(struct ldb_module *, struct ldb_request *); /* delete */
+ int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */
+ int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */
+ int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */
+ int (*start_transaction)(struct ldb_module *);
+ int (*end_transaction)(struct ldb_module *);
+ int (*del_transaction)(struct ldb_module *);
+ int (*sequence_number)(struct ldb_module *, struct ldb_request *);
+ void *private_data;
+};
+
+
+/* The following definitions come from lib/ldb/common/ldb_debug.c */
+void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+
+#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
+
+/* The following definitions come from lib/ldb/common/ldb.c */
+
+void ldb_request_set_state(struct ldb_request *req, int state);
+int ldb_request_get_status(struct ldb_request *req);
+
+unsigned int ldb_get_create_perms(struct ldb_context *ldb);
+
+const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb,
+ const char *syntax);
+
+/* The following definitions come from lib/ldb/common/ldb_attributes.c */
+
+int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb,
+ const char *name,
+ unsigned flags,
+ const struct ldb_schema_syntax *syntax);
+int ldb_schema_attribute_add(struct ldb_context *ldb,
+ const char *name,
+ unsigned flags,
+ const char *syntax);
+void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name);
+
+/* The following definitions come from lib/ldb/common/ldb_controls.c */
+struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
+int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
+int check_critical_controls(struct ldb_control **controls);
+
+/* The following definitions come from lib/ldb/common/ldb_ldif.c */
+int ldb_should_b64_encode(const struct ldb_val *val);
+
+/* The following definitions come from lib/ldb/common/ldb_match.c */
+int ldb_match_msg(struct ldb_context *ldb,
+ const struct ldb_message *msg,
+ const struct ldb_parse_tree *tree,
+ struct ldb_dn *base,
+ enum ldb_scope scope);
+
+/* The following definitions come from lib/ldb/common/ldb_modules.c */
+
+struct ldb_module *ldb_module_new(TALLOC_CTX *memctx,
+ struct ldb_context *ldb,
+ const char *module_name,
+ const struct ldb_module_ops *ops);
+
+struct ldb_context *ldb_module_get_ctx(struct ldb_module *module);
+void *ldb_module_get_private(struct ldb_module *module);
+void ldb_module_set_private(struct ldb_module *module, void *private_data);
+
+int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
+int ldb_next_start_trans(struct ldb_module *module);
+int ldb_next_end_trans(struct ldb_module *module);
+int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_init(struct ldb_module *module);
+
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+void ldb_reset_err_string(struct ldb_context *ldb);
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_module(const struct ldb_module_ops *);
+
+typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
+ unsigned int flags, const char *options[],
+ struct ldb_module **module);
+
+struct ldb_backend_ops {
+ const char *name;
+ ldb_connect_fn connect_fn;
+};
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
+
+struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
+
+int ldb_module_send_entry(struct ldb_request *req,
+ struct ldb_message *msg,
+ struct ldb_control **ctrls);
+
+int ldb_module_send_referral(struct ldb_request *req,
+ char *ref);
+
+int ldb_module_done(struct ldb_request *req,
+ struct ldb_control **ctrls,
+ struct ldb_extended *response,
+ int error);
+
+int ldb_mod_register_control(struct ldb_module *module, const char *oid);
+
+#endif
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index cf4017ef14..04ee002dd5 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -37,6 +37,9 @@
#ifndef _LDB_PRIVATE_H_
#define _LDB_PRIVATE_H_ 1
+#include "ldb.h"
+#include "ldb_module.h"
+
struct ldb_context;
struct ldb_module_ops;
@@ -58,26 +61,6 @@ struct ldb_module {
};
/*
- these function pointers define the operations that a ldb module can intercept
-*/
-struct ldb_module_ops {
- const char *name;
- int (*init_context) (struct ldb_module *);
- int (*search)(struct ldb_module *, struct ldb_request *); /* search */
- int (*add)(struct ldb_module *, struct ldb_request *); /* add */
- int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */
- int (*del)(struct ldb_module *, struct ldb_request *); /* delete */
- int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */
- int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */
- int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */
- int (*start_transaction)(struct ldb_module *);
- int (*end_transaction)(struct ldb_module *);
- int (*del_transaction)(struct ldb_module *);
- int (*sequence_number)(struct ldb_module *, struct ldb_request *);
- void *private_data;
-};
-
-/*
schema related information needed for matching rules
*/
struct ldb_schema {
@@ -130,24 +113,12 @@ struct ldb_context {
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
-/*
- simplify out of memory handling
-*/
-#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
-
/* The following definitions come from lib/ldb/common/ldb.c */
int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
struct ldb_module **backend_module);
void ldb_set_default_dns(struct ldb_context *ldb);
-/* The following definitions come from lib/ldb/common/ldb_debug.c */
-void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
- const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-
-/* The following definitions come from lib/ldb/common/ldb_ldif.c */
-int ldb_should_b64_encode(const struct ldb_val *val);
extern const struct ldb_module_ops ldb_objectclass_module_ops;
extern const struct ldb_module_ops ldb_operational_module_ops;
@@ -173,26 +144,6 @@ extern const struct ldb_backend_ops ldb_ldap_backend_ops;
extern const struct ldb_backend_ops ldb_ldapi_backend_ops;
extern const struct ldb_backend_ops ldb_ldaps_backend_ops;
-int ldb_match_msg(struct ldb_context *ldb,
- const struct ldb_message *msg,
- const struct ldb_parse_tree *tree,
- struct ldb_dn *base,
- enum ldb_scope scope);
-
-const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb,
- const char *syntax);
-
-/* The following definitions come from lib/ldb/common/ldb_attributes.c */
-
-int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb,
- const char *name,
- unsigned flags,
- const struct ldb_schema_syntax *syntax);
-int ldb_schema_attribute_add(struct ldb_context *ldb,
- const char *name,
- unsigned flags,
- const char *syntax);
-void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name);
int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname);
@@ -204,11 +155,6 @@ int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx,
int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2);
-/* The following definitions come from lib/ldb/common/ldb_controls.c */
-struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
-int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
-int check_critical_controls(struct ldb_control **controls);
-
/* The following definitions come from lib/ldb/common/ldb_utf8.c */
char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n);
@@ -227,57 +173,12 @@ int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, ui
#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02
-/* MODULES specific headers -- SSS */
-
/* The following definitions come from lib/ldb/common/ldb_modules.c */
const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
-int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
-int ldb_next_start_trans(struct ldb_module *module);
-int ldb_next_end_trans(struct ldb_module *module);
-int ldb_next_del_trans(struct ldb_module *module);
-int ldb_next_init(struct ldb_module *module);
-
-void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
-void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-void ldb_reset_err_string(struct ldb_context *ldb);
-
-const char *ldb_default_modules_dir(void);
-
-int ldb_register_module(const struct ldb_module_ops *);
-
-typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
- unsigned int flags, const char *options[],
- struct ldb_module **module);
-
-struct ldb_backend_ops {
- const char *name;
- ldb_connect_fn connect_fn;
-};
-
-const char *ldb_default_modules_dir(void);
-
-int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
-
-struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
-
-int ldb_module_send_entry(struct ldb_request *req,
- struct ldb_message *msg,
- struct ldb_control **ctrls);
-
-int ldb_module_send_referral(struct ldb_request *req,
- char *ref);
-
-int ldb_module_done(struct ldb_request *req,
- struct ldb_control **ctrls,
- struct ldb_extended *response,
- int error);
-
-int ldb_mod_register_control(struct ldb_module *module, const char *oid);
-
struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str);
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 791cc75dc1..3901b9b436 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -42,7 +42,7 @@
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "tevent.h"
#include "libcli/ldap/ldap.h"
@@ -70,8 +70,11 @@ struct ildb_context {
static void ildb_request_done(struct ildb_context *ctx,
struct ldb_control **ctrls, int error)
{
+ struct ldb_context *ldb;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+
ctx->done = true;
if (ctx->req == NULL) {
@@ -81,7 +84,7 @@ static void ildb_request_done(struct ildb_context *ctx,
ares = talloc_zero(ctx->req, struct ldb_reply);
if (!ares) {
- ldb_oom(ctx->req->handle->ldb);
+ ldb_oom(ldb);
ctx->req->callback(ctx->req, NULL);
return;
}
@@ -163,17 +166,21 @@ failed:
*/
static int ildb_map_error(struct ldb_module *module, NTSTATUS status)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ildb_private *ildb;
+ struct ldb_context *ldb;
+
+ ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private);
+ ldb = ldb_module_get_ctx(module);
TALLOC_CTX *mem_ctx = talloc_new(ildb);
if (NT_STATUS_IS_OK(status)) {
return LDB_SUCCESS;
}
if (!mem_ctx) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ldb_set_errstring(module->ldb,
+ ldb_set_errstring(ldb,
ldap_errstr(ildb->ldap, mem_ctx, status));
talloc_free(mem_ctx);
if (NT_STATUS_IS_LDAP(status)) {
@@ -196,6 +203,7 @@ static void ildb_request_timeout(struct tevent_context *ev, struct tevent_timer
static void ildb_callback(struct ldap_request *req)
{
+ struct ldb_context *ldb;
struct ildb_context *ac;
NTSTATUS status;
struct ldap_SearchResEntry *search;
@@ -209,6 +217,7 @@ static void ildb_callback(struct ldap_request *req)
int i;
ac = talloc_get_type(req->async.private_data, struct ildb_context);
+ ldb = ldb_module_get_ctx(ac->module);
callback_failed = false;
request_done = false;
controls = NULL;
@@ -285,7 +294,7 @@ static void ildb_callback(struct ldap_request *req)
controls = talloc_steal(ac, msg->controls);
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage);
+ ldb_set_errstring(ldb, msg->r.SearchResultDone.errormessage);
}
}
@@ -303,7 +312,7 @@ static void ildb_callback(struct ldap_request *req)
search = &(msg->r.SearchResultEntry);
- ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn);
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, search->dn);
if ( ! ldb_dn_validate(ldbmsg->dn)) {
ret = LDB_ERR_OPERATIONS_ERROR;
break;
@@ -368,21 +377,24 @@ static void ildb_callback(struct ldap_request *req)
static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg)
{
+ struct ldb_context *ldb;
struct ldap_request *req;
if (!ac) {
return LDB_ERR_OPERATIONS_ERROR;
}
+ ldb = ldb_module_get_ctx(ac->module);
+
req = ldap_request_send(ac->ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(ac->module->ldb, "async send request failed");
+ ldb_set_errstring(ldb, "async send request failed");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->ireq = talloc_steal(ac, req);
if (!ac->ireq->conn) {
- ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?");
+ ldb_set_errstring(ldb, "connection to remote LDAP server dropped?");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -405,23 +417,26 @@ static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg)
*/
static int ildb_search(struct ildb_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *req = ac->req;
struct ldap_message *msg;
int n;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (!req->callback || !req->context) {
- ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context");
+ ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree");
+ ldb_set_errstring(ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(req);
if (msg == NULL) {
- ldb_set_errstring(ac->module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -433,7 +448,7 @@ static int ildb_search(struct ildb_context *ac)
msg->r.SearchRequest.basedn = ldb_dn_get_extended_linearized(msg, req->op.search.base, 0);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN");
+ ldb_set_errstring(ldb, "Unable to determine baseDN");
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -659,21 +674,23 @@ static bool ildb_dn_is_special(struct ldb_request *req)
static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ildb_private *ildb;
struct ildb_context *ac;
struct tevent_timer *te;
int ret;
- ildb = talloc_get_type(module->private_data, struct ildb_private);
+ ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private);
+ ldb = ldb_module_get_ctx(module);
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
ac = talloc_zero(req, struct ildb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -743,22 +760,15 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
NTSTATUS status;
struct cli_credentials *creds;
- module = talloc(ldb, struct ldb_module);
- if (!module) {
- ldb_oom(ldb);
- return -1;
- }
- talloc_set_name_const(module, "ldb_ildap backend");
- module->ldb = ldb;
- module->prev = module->next = NULL;
- module->ops = &ildb_ops;
+ module = ldb_module_new(ldb, ldb, "ldb_ildap backend", &ildb_ops);
+ if (!module) return -1;
ildb = talloc(module, struct ildb_private);
if (!ildb) {
ldb_oom(ldb);
goto failed;
}
- module->private_data = ildb;
+ ldb_module_set_private(module, ildb);
ildb->event_ctx = ldb_get_event_context(ldb);
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 8e053818e5..e1fcdb1353 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -38,7 +38,7 @@
* author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#define LDAP_DEPRECATED 1
#include <ldap.h>
@@ -195,6 +195,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
*/
static int lldb_search(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
@@ -204,21 +205,23 @@ static int lldb_search(struct lldb_context *lldb_ac)
char *expression;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context");
+ ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, "Invalid expression parse tree");
+ ldb_set_errstring(ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->controls != NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
}
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) {
@@ -259,7 +262,7 @@ static int lldb_search(struct lldb_context *lldb_ac)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -270,6 +273,7 @@ static int lldb_search(struct lldb_context *lldb_ac)
*/
static int lldb_add(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
@@ -277,7 +281,9 @@ static int lldb_add(struct lldb_context *lldb_ac)
char *dn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) {
@@ -295,7 +301,7 @@ static int lldb_add(struct lldb_context *lldb_ac)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -306,6 +312,7 @@ static int lldb_add(struct lldb_context *lldb_ac)
*/
static int lldb_modify(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
@@ -313,7 +320,9 @@ static int lldb_modify(struct lldb_context *lldb_ac)
char *dn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) {
@@ -331,7 +340,7 @@ static int lldb_modify(struct lldb_context *lldb_ac)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -342,13 +351,16 @@ static int lldb_modify(struct lldb_context *lldb_ac)
*/
static int lldb_delete(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *dnstr;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn);
@@ -358,7 +370,7 @@ static int lldb_delete(struct lldb_context *lldb_ac)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -369,6 +381,7 @@ static int lldb_delete(struct lldb_context *lldb_ac)
*/
static int lldb_rename(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
@@ -377,7 +390,9 @@ static int lldb_rename(struct lldb_context *lldb_ac)
char *parentdn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
@@ -401,7 +416,7 @@ static int lldb_rename(struct lldb_context *lldb_ac)
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
@@ -428,14 +443,17 @@ static int lldb_del_trans(struct ldb_module *module)
return LDB_SUCCESS;
}
-void lldb_request_done(struct ldb_request *req,
+void lldb_request_done(struct lldb_context *ac,
struct ldb_control **ctrls, int error)
{
+ struct ldb_request *req;
struct ldb_reply *ares;
+ req = ac->req;
+
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb_module_get_ctx(ac->module));
req->callback(req, NULL);
return;
}
@@ -451,6 +469,7 @@ void lldb_request_done(struct ldb_request *req,
*/
static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = ac->lldb;
LDAPControl **serverctrlsp = NULL;
char **referralsp = NULL;
@@ -466,6 +485,8 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
int ret;
int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
type = ldap_msgtype(result);
callback_failed = false;
request_done = false;
@@ -490,7 +511,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
ret = LDB_ERR_OPERATIONS_ERROR;
break;
}
- ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn);
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, dn);
if ( ! ldb_dn_validate(ldbmsg->dn)) {
talloc_free(ldbmsg);
ret = LDB_ERR_OPERATIONS_ERROR;
@@ -509,7 +530,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
bval = ldap_get_values_len(lldb->ldap, msg, attr);
if (bval) {
- lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval);
+ lldb_add_msg_attr(ldb, ldbmsg, attr, bval);
ldap_value_free_len(bval);
}
}
@@ -595,7 +616,7 @@ static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
}
if (request_done) {
- lldb_request_done(ac->req, ac->controls, ret);
+ lldb_request_done(ac, ac->controls, ret);
lret = true;
goto free_and_return;
}
@@ -606,7 +627,7 @@ free_and_return:
if (matcheddnp) ldap_memfree(matcheddnp);
if (errmsgp && *errmsgp) {
- ldb_set_errstring(ac->module->ldb, errmsgp);
+ ldb_set_errstring(ldb, errmsgp);
}
if (errmsgp) {
ldap_memfree(errmsgp);
@@ -627,7 +648,7 @@ static void lldb_timeout(struct tevent_context *ev,
struct lldb_context *ac;
ac = talloc_get_type(private_data, struct lldb_context);
- lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
+ lldb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
}
static void lldb_callback(struct tevent_context *ev,
@@ -644,7 +665,7 @@ static void lldb_callback(struct tevent_context *ev,
ac = talloc_get_type(private_data, struct lldb_context);
if (!ac->msgid) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
return;
}
@@ -655,7 +676,7 @@ static void lldb_callback(struct tevent_context *ev,
goto respin;
}
if (lret == -1) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
return;
}
@@ -668,9 +689,9 @@ static void lldb_callback(struct tevent_context *ev,
respin:
tv.tv_sec = 0;
tv.tv_usec = 100;
- lte = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ lte = tevent_add_timer(ev, ac, tv, lldb_callback, ac);
if (NULL == lte) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
}
}
@@ -709,11 +730,12 @@ static void lldb_auto_done_callback(struct tevent_context *ev,
struct lldb_context *ac;
ac = talloc_get_type(private_data, struct lldb_context);
- lldb_request_done(ac->req, NULL, LDB_SUCCESS);
+ lldb_request_done(ac, NULL, LDB_SUCCESS);
}
static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb;
struct lldb_context *ac;
struct tevent_context *ev;
@@ -721,21 +743,22 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re
struct timeval tv;
int ret;
- lldb = talloc_get_type(module->private_data, struct lldb_private);
+ lldb = talloc_get_type(ldb_module_get_private(module), struct lldb_private);
+ ldb = ldb_module_get_ctx(module);
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
- ev = ldb_get_event_context(module->ldb);
+ ev = ldb_get_event_context(ldb);
if (NULL == ev) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_zero(module->ldb, struct lldb_context);
+ ac = talloc_zero(ldb, struct lldb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -747,7 +770,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re
if (lldb_dn_is_special(req)) {
tv.tv_sec = 0;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv,
+ te = tevent_add_timer(ev, ac, tv,
lldb_auto_done_callback, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -779,13 +802,13 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re
}
if (ret != LDB_SUCCESS) {
- lldb_request_done(req, NULL, ret);
+ lldb_request_done(ac, NULL, ret);
return ret;
}
tv.tv_sec = 0;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ te = tevent_add_timer(ev, ac, tv, lldb_callback, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -793,7 +816,7 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re
tv.tv_sec = req->starttime + req->timeout;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv, lldb_timeout, ac);
+ te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -835,24 +858,15 @@ static int lldb_connect(struct ldb_context *ldb,
int version = 3;
int ret;
- module = talloc(ldb, struct ldb_module);
- if (module == NULL) {
- ldb_oom(ldb);
- talloc_free(lldb);
- return -1;
- }
- talloc_set_name_const(module, "ldb_ldap backend");
- module->ldb = ldb;
- module->prev = module->next = NULL;
- module->ops = &lldb_ops;
+ module = ldb_module_new(ldb, ldb, "ldb_ldap backend", &lldb_ops);
+ if (!module) return -1;
- lldb = talloc(module, struct lldb_private);
+ lldb = talloc_zero(module, struct lldb_private);
if (!lldb) {
ldb_oom(ldb);
goto failed;
}
- module->private_data = lldb;
- lldb->ldap = NULL;
+ ldb_module_set_private(module, lldb);
ret = ldap_initialize(&lldb->ldap, url);
if (ret != LDAP_SUCCESS) {
diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c
index 72d8378a07..ea2bfd1dc1 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.c
+++ b/source4/lib/ldb/ldb_map/ldb_map.c
@@ -35,7 +35,7 @@
* Author: Jelmer Vernooij, Martin Kuehl
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
@@ -102,7 +102,7 @@
/* Extract mappings from private data. */
const struct ldb_map_context *map_get_context(struct ldb_module *module)
{
- const struct map_private *data = talloc_get_type(module->private_data, struct map_private);
+ const struct map_private *data = talloc_get_type(ldb_module_get_private(module), struct map_private);
return data->context;
}
@@ -110,11 +110,14 @@ const struct ldb_map_context *map_get_context(struct ldb_module *module)
struct map_context *map_init_context(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct map_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct map_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return NULL;
}
@@ -202,8 +205,11 @@ static struct ldb_dn *ldb_dn_rebase_remote(void *mem_ctx, const struct ldb_map_c
int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message *msg;
+ ldb = ldb_module_get_ctx(module);
+
switch (request->operation) {
case LDB_SEARCH:
if (request->op.search.base) {
@@ -236,7 +242,7 @@ int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *reque
break;
default:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Invalid remote request!\n");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -462,6 +468,7 @@ bool ldb_dn_check_local(struct ldb_module *module, struct ldb_dn *dn)
struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_dn *newdn;
const struct ldb_map_attribute *map;
enum ldb_map_attr_type map_type;
@@ -473,6 +480,8 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct
return NULL;
}
+ ldb = ldb_module_get_ctx(module);
+
newdn = ldb_dn_copy(mem_ctx, dn);
if (newdn == NULL) {
map_oom(module);
@@ -493,14 +502,14 @@ struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct
switch (map_type) {
case MAP_IGNORE:
case MAP_GENERATE:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"MAP_IGNORE/MAP_GENERATE attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
case MAP_CONVERT:
if (map->u.convert.convert_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"'convert_local' not set for attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
@@ -534,6 +543,7 @@ failed:
struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_dn *newdn;
const struct ldb_map_attribute *map;
enum ldb_map_attr_type map_type;
@@ -545,6 +555,8 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc
return NULL;
}
+ ldb = ldb_module_get_ctx(module);
+
newdn = ldb_dn_copy(mem_ctx, dn);
if (newdn == NULL) {
map_oom(module);
@@ -565,14 +577,14 @@ struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struc
switch (map_type) {
case MAP_IGNORE:
case MAP_GENERATE:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"MAP_IGNORE/MAP_GENERATE attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
case MAP_CONVERT:
if (map->u.convert.convert_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"'convert_remote' not set for attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
@@ -623,10 +635,13 @@ struct ldb_dn *ldb_dn_map_rebase_remote(struct ldb_module *module, void *mem_ctx
/* Map a DN contained in an ldb value into the remote partition. */
static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn, *newdn;
struct ldb_val newval;
- dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val);
if (! ldb_dn_validate(dn)) {
newval.length = 0;
newval.data = NULL;
@@ -649,10 +664,13 @@ static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_
/* Map a DN contained in an ldb value into the local partition. */
static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn, *newdn;
struct ldb_val newval;
- dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val);
if (! ldb_dn_validate(dn)) {
newval.length = 0;
newval.data = NULL;
@@ -693,11 +711,14 @@ static struct ldb_val map_objectclass_convert_local(struct ldb_module *module, v
static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message_element *el, *oc;
struct ldb_val val;
bool found_extensibleObject = false;
int i;
+ ldb = ldb_module_get_ctx(module);
+
/* Find old local objectClass */
oc = ldb_msg_find_element(old, "objectClass");
if (oc == NULL) {
@@ -707,7 +728,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha
/* Prepare new element */
el = talloc_zero(remote, struct ldb_message_element);
if (el == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return; /* TODO: fail? */
}
@@ -716,7 +737,7 @@ static void map_objectclass_generate_remote(struct ldb_module *module, const cha
el->values = talloc_array(el, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return; /* TODO: fail? */
}
@@ -766,10 +787,13 @@ static struct ldb_val map_objectclass_convert_remote(struct ldb_module *module,
static struct ldb_message_element *map_objectclass_generate_local(struct ldb_module *module, void *mem_ctx, const char *local_attr, const struct ldb_message *remote)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message_element *el, *oc;
struct ldb_val val;
int i;
+ ldb = ldb_module_get_ctx(module);
+
/* Find old remote objectClass */
oc = ldb_msg_find_element(remote, "objectClass");
if (oc == NULL) {
@@ -779,7 +803,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod
/* Prepare new element */
el = talloc_zero(mem_ctx, struct ldb_message_element);
if (el == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
@@ -788,7 +812,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod
el->values = talloc_array(el, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
@@ -809,7 +833,7 @@ static struct ldb_message_element *map_objectclass_generate_local(struct ldb_mod
el->values = talloc_realloc(el, el->values, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
}
@@ -847,9 +871,12 @@ static int map_objectclass_convert_operator(struct ldb_module *module, void *mem
struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback)
{
const struct ldb_parse_tree *search_tree;
+ struct ldb_context *ldb;
struct ldb_request *req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (tree) {
search_tree = tree;
} else {
@@ -859,7 +886,7 @@ struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *d
}
}
- ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac,
+ ret = ldb_build_search_req_ex(&req, ldb, ac,
dn, LDB_SCOPE_BASE,
search_tree, attrs,
NULL,
@@ -879,11 +906,14 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac,
void *context,
ldb_map_callback_t callback)
{
+ struct ldb_context *ldb;
struct ldb_request *req;
struct ldb_message *msg;
const char *dn;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Prepare message */
msg = ldb_msg_new(ac);
if (msg == NULL) {
@@ -905,7 +935,7 @@ struct ldb_request *map_build_fixup_req(struct map_context *ac,
}
/* Prepare request */
- ret = ldb_build_mod_req(&req, ac->module->ldb,
+ ret = ldb_build_mod_req(&req, ldb,
ac, msg, NULL,
context, callback,
ac->req);
@@ -961,6 +991,7 @@ static const struct ldb_map_attribute objectclass_attribute_map = {
static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name)
{
static const char * const attrs[] = { MAP_DN_FROM, MAP_DN_TO, NULL };
+ struct ldb_context *ldb;
struct ldb_dn *dn;
struct ldb_message *msg;
struct ldb_result *res;
@@ -972,34 +1003,36 @@ static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data,
return LDB_SUCCESS;
}
- dn = ldb_dn_new_fmt(data, module->ldb, "%s=%s", MAP_DN_NAME, name);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new_fmt(data, ldb, "%s=%s", MAP_DN_NAME, name);
if ( ! ldb_dn_validate(dn)) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Failed to construct '%s' DN!\n", MAP_DN_NAME);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
+ ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
talloc_free(dn);
if (ret != LDB_SUCCESS) {
return ret;
}
if (res->count == 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"No results for '%s=%s'!\n", MAP_DN_NAME, name);
talloc_free(res);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
if (res->count > 1) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Too many results for '%s=%s'!\n", MAP_DN_NAME, name);
talloc_free(res);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
msg = res->msgs[0];
- data->local_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_FROM);
- data->remote_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_TO);
+ data->local_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_FROM);
+ data->remote_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_TO);
talloc_free(res);
return LDB_SUCCESS;
@@ -1075,7 +1108,7 @@ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attrib
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
+ ldb_module_set_private(module, data);
data->context = talloc_zero(data, struct ldb_map_context);
if (!data->context) {
diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
index 96605f23eb..e915a5f46a 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
@@ -24,7 +24,7 @@
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
@@ -69,10 +69,11 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l
const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map = map_attr_find_local(data, attr_name);
struct ldb_message_element *el=NULL;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
/* Unknown attribute: ignore */
if (map == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': no mapping found\n",
old->name);
goto local;
@@ -84,7 +85,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l
case MAP_CONVERT:
if (map->u.convert.convert_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': "
"'convert_local' not set\n",
map->local_name);
@@ -98,7 +99,7 @@ static int ldb_msg_el_partition(struct ldb_module *module, struct ldb_message *l
case MAP_GENERATE:
if (map->u.generate.generate_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': "
"'generate_remote' not set\n",
map->local_name);
@@ -158,12 +159,15 @@ static bool ldb_msg_check_remote(struct ldb_module *module, const struct ldb_mes
static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg)
{
/* const char * const names[]; */
+ struct ldb_context *ldb;
int i, ret;
+ ldb = ldb_module_get_ctx(module);
+
for (i = 0; i < msg->num_elements; i++) {
/* Skip 'IS_MAPPED' */
if (ldb_attr_cmp(msg->elements[i].name, IS_MAPPED) == 0) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Skipping attribute '%s'\n",
msg->elements[i].name);
continue;
@@ -195,10 +199,12 @@ static int map_rename_local_callback(struct ldb_request *req,
/* Store the DN of a single search result in context. */
static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -214,7 +220,7 @@ static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *a
case LDB_REPLY_ENTRY:
/* We have already found a remote DN */
if (ac->local_dn) {
- ldb_set_errstring(ac->module->ldb,
+ ldb_set_errstring(ldb,
"Too many results!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
@@ -284,10 +290,12 @@ static int map_search_self_req(struct ldb_request **req,
static int map_op_local_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -299,7 +307,7 @@ static int map_op_local_callback(struct ldb_request *req,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -317,9 +325,11 @@ static int map_op_local_callback(struct ldb_request *req,
static int map_op_remote_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -331,7 +341,7 @@ static int map_op_remote_callback(struct ldb_request *req,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -350,11 +360,14 @@ static int map_op_remote_callback(struct ldb_request *req,
int map_add(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.add.message;
+ struct ldb_context *ldb;
struct map_context *ac;
struct ldb_message *remote_msg;
const char *dn;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
return ldb_next_request(module, req);
@@ -397,7 +410,7 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
- ret = ldb_build_add_req(&ac->remote_req, module->ldb,
+ ret = ldb_build_add_req(&ac->remote_req, ldb,
ac, remote_msg,
req->controls,
ac, map_op_remote_callback,
@@ -426,10 +439,13 @@ int map_add(struct ldb_module *module, struct ldb_request *req)
static int map_add_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Prepare the local operation */
- ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_add_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
@@ -451,9 +467,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req)
const struct ldb_message *msg = req->op.mod.message;
struct ldb_request *search_req;
struct ldb_message *remote_msg;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
return ldb_next_request(module, req);
@@ -498,7 +517,7 @@ int map_modify(struct ldb_module *module, struct ldb_request *req)
ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
- ret = ldb_build_mod_req(&ac->remote_req, module->ldb,
+ ret = ldb_build_mod_req(&ac->remote_req, ldb,
ac, remote_msg,
req->controls,
ac, map_op_remote_callback,
@@ -526,9 +545,12 @@ int map_modify(struct ldb_module *module, struct ldb_request *req)
static int map_modify_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
char *dn;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (ac->local_dn == NULL) {
/* No local record present, add it instead */
/* Add local 'IS_MAPPED' */
@@ -544,7 +566,7 @@ static int map_modify_do_local(struct map_context *ac)
}
/* Prepare the local operation */
- ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_add_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
@@ -555,7 +577,7 @@ static int map_modify_do_local(struct map_context *ac)
}
} else {
/* Prepare the local operation */
- ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_mod_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
@@ -577,9 +599,12 @@ static int map_modify_do_local(struct map_context *ac)
int map_delete(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *search_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.del.dn)) {
return ldb_next_request(module, req);
@@ -598,7 +623,7 @@ int map_delete(struct ldb_module *module, struct ldb_request *req)
}
/* Prepare the remote operation */
- ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac,
+ ret = ldb_build_del_req(&ac->remote_req, ldb, ac,
ldb_dn_map_local(module, ac, req->op.del.dn),
req->controls,
ac,
@@ -628,8 +653,11 @@ int map_delete(struct ldb_module *module, struct ldb_request *req)
static int map_delete_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* No local record, continue remotely */
if (ac->local_dn == NULL) {
/* Do the remote request. */
@@ -637,7 +665,7 @@ static int map_delete_do_local(struct map_context *ac)
}
/* Prepare the local operation */
- ret = ldb_build_del_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_del_req(&local_req, ldb, ac,
ac->req->op.del.dn,
ac->req->controls,
ac,
@@ -657,9 +685,12 @@ static int map_delete_do_local(struct map_context *ac)
int map_rename(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *search_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.rename.olddn)) {
return ldb_next_request(module, req);
@@ -685,7 +716,7 @@ int map_rename(struct ldb_module *module, struct ldb_request *req)
}
/* Prepare the remote operation */
- ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac,
+ ret = ldb_build_rename_req(&ac->remote_req, ldb, ac,
ldb_dn_map_local(module, ac, req->op.rename.olddn),
ldb_dn_map_local(module, ac, req->op.rename.newdn),
req->controls,
@@ -715,8 +746,11 @@ int map_rename(struct ldb_module *module, struct ldb_request *req)
static int map_rename_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* No local record, continue remotely */
if (ac->local_dn == NULL) {
/* Do the remote request. */
@@ -724,7 +758,7 @@ static int map_rename_do_local(struct map_context *ac)
}
/* Prepare the local operation */
- ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_rename_req(&local_req, ldb, ac,
ac->req->op.rename.olddn,
ac->req->op.rename.newdn,
ac->req->controls,
@@ -741,10 +775,12 @@ static int map_rename_do_local(struct map_context *ac)
static int map_rename_local_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -756,7 +792,7 @@ static int map_rename_local_callback(struct ldb_request *req,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
index 5588eaaf46..327fa92f8d 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -25,7 +25,7 @@
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
@@ -264,6 +264,9 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
const struct ldb_map_attribute *map;
struct ldb_message_element *old, *el=NULL;
const char *remote_name = NULL;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(module);
/* We handle wildcards in ldb_msg_el_merge_wildcard */
if (ldb_attr_cmp(attr_name, "*") == 0) {
@@ -300,7 +303,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
case MAP_CONVERT:
if (map->u.convert.convert_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Skipping attribute '%s': "
"'convert_remote' not set\n",
attr_name);
@@ -319,7 +322,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
case MAP_GENERATE:
if (map->u.generate.generate_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Skipping attribute '%s': "
"'generate_local' not set\n",
attr_name);
@@ -869,6 +872,9 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx,
{
const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(module);
if (tree == NULL) {
return 0;
@@ -893,7 +899,7 @@ static int map_subtree_collect_remote(struct ldb_module *module, void *mem_ctx,
}
if (map->type == MAP_GENERATE) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Skipping attribute '%s': "
"'convert_operator' not set\n",
tree->u.equality.attr);
@@ -1045,14 +1051,17 @@ int map_return_entry(struct map_context *ac, struct ldb_reply *ares)
{
struct ldb_message_element *el;
const char * const *attrs;
+ struct ldb_context *ldb;
int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Merged result doesn't match original query, skip */
- if (!ldb_match_msg(ac->module->ldb, ares->message,
+ if (!ldb_match_msg(ldb, ares->message,
ac->req->op.search.tree,
ac->req->op.search.base,
ac->req->op.search.scope)) {
- ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: "
"Skipping record '%s': "
"doesn't match original search\n",
ldb_dn_get_linearized(ares->message->dn));
@@ -1086,13 +1095,17 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
struct ldb_parse_tree *remote_tree;
struct ldb_parse_tree *local_tree;
struct ldb_request *remote_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
const char *wildcard[] = { "*", NULL };
const char * const *attrs;
- if (!module->private_data) /* if we're not yet initialized, go to the next module */
+ ldb = ldb_module_get_ctx(module);
+
+ /* if we're not yet initialized, go to the next module */
+ if (!ldb_module_get_private(module))
return ldb_next_request(module, req);
/* Do not manipulate our control entries */
@@ -1165,7 +1178,7 @@ int map_search(struct ldb_module *module, struct ldb_request *req)
ac->local_tree = local_tree;
/* Prepare the remote operation */
- ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&remote_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
remote_tree,
@@ -1282,10 +1295,12 @@ static int map_search_local(struct map_context *ac)
/* Merge the remote and local parts of a search result. */
int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -1301,7 +1316,7 @@ int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares)
/* We have already found a local record */
if (ac->r_current->local) {
talloc_free(ares);
- ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!");
+ ldb_set_errstring(ldb, "ldb_map: Too many results!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h
index 0543ba71b9..0c46443253 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_private.h
+++ b/source4/lib/ldb/ldb_map/ldb_map_private.h
@@ -1,6 +1,6 @@
/* A handy macro to report Out of Memory conditions */
-#define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+#define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory"));
/* The type of search callback functions */
typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index be99c29d1e..39a77a5505 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -32,7 +32,7 @@
* Author: Derrell Lipman (based on Andrew Tridgell's LDAP backend)
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include <sqlite3.h>
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c
index 2576e2c7bd..43b965f239 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_cache.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c
@@ -31,8 +31,6 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
#define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
@@ -57,10 +55,14 @@ static const struct {
*/
static void ltdb_attributes_unload(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
int i;
+ ldb = ldb_module_get_ctx(module);
+
if (ltdb->cache->attributes == NULL) {
/* no previously loaded attributes */
return;
@@ -68,7 +70,7 @@ static void ltdb_attributes_unload(struct ldb_module *module)
msg = ltdb->cache->attributes;
for (i=0;i<msg->num_elements;i++) {
- ldb_schema_attribute_remove(module->ldb, msg->elements[i].name);
+ ldb_schema_attribute_remove(ldb, msg->elements[i].name);
}
talloc_free(ltdb->cache->attributes);
@@ -104,12 +106,16 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v)
*/
static int ltdb_attributes_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg = ltdb->cache->attributes;
struct ldb_dn *dn;
int i, r;
- dn = ldb_dn_new(module, module->ldb, LTDB_ATTRIBUTES);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new(module, ldb, LTDB_ATTRIBUTES);
if (dn == NULL) goto failed;
r = ltdb_search_dn1(module, dn, msg);
@@ -128,7 +134,7 @@ static int ltdb_attributes_load(struct ldb_module *module)
const struct ldb_schema_syntax *s;
if (ltdb_attributes_flags(&msg->elements[i], &flags) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name);
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name);
goto failed;
}
switch (flags & ~LTDB_FLAG_HIDDEN) {
@@ -142,22 +148,22 @@ static int ltdb_attributes_load(struct ldb_module *module)
syntax = LDB_SYNTAX_INTEGER;
break;
default:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid flag combination 0x%x for '%s' in @ATTRIBUTES\n",
flags, msg->elements[i].name);
goto failed;
}
- s = ldb_standard_syntax_by_name(module->ldb, syntax);
+ s = ldb_standard_syntax_by_name(ldb, syntax);
if (s == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid attribute syntax '%s' for '%s' in @ATTRIBUTES\n",
syntax, msg->elements[i].name);
goto failed;
}
flags |= LDB_ATTR_FLAG_ALLOCATED;
- if (ldb_schema_attribute_add_with_syntax(module->ldb, msg->elements[i].name, flags, s) != 0) {
+ if (ldb_schema_attribute_add_with_syntax(ldb, msg->elements[i].name, flags, s) != 0) {
goto failed;
}
}
@@ -173,7 +179,9 @@ failed:
*/
static int ltdb_baseinfo_init(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
struct ldb_message_element el;
struct ldb_val val;
@@ -183,6 +191,8 @@ static int ltdb_baseinfo_init(struct ldb_module *module)
out. */
const char *initial_sequence_number = "1";
+ ldb = ldb_module_get_ctx(module);
+
ltdb->sequence_number = atof(initial_sequence_number);
msg = talloc(ltdb, struct ldb_message);
@@ -192,7 +202,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module)
msg->num_elements = 1;
msg->elements = &el;
- msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO);
+ msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO);
if (!msg->dn) {
goto failed;
}
@@ -226,7 +236,8 @@ failed:
*/
static void ltdb_cache_free(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->sequence_number = 0;
talloc_free(ltdb->cache);
@@ -248,13 +259,17 @@ int ltdb_cache_reload(struct ldb_module *module)
*/
int ltdb_cache_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
struct ldb_dn *indexlist_dn = NULL;
uint64_t seq;
struct ldb_message *baseinfo = NULL, *options = NULL;
int r;
+ ldb = ldb_module_get_ctx(module);
+
/* a very fast check to avoid extra database reads */
if (ltdb->cache != NULL &&
tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) {
@@ -275,7 +290,7 @@ int ltdb_cache_load(struct ldb_module *module)
baseinfo = talloc(ltdb->cache, struct ldb_message);
if (baseinfo == NULL) goto failed;
- baseinfo_dn = ldb_dn_new(module, module->ldb, LTDB_BASEINFO);
+ baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO);
if (baseinfo_dn == NULL) goto failed;
r= ltdb_search_dn1(module, baseinfo_dn, baseinfo);
@@ -307,7 +322,7 @@ int ltdb_cache_load(struct ldb_module *module)
options = talloc(ltdb->cache, struct ldb_message);
if (options == NULL) goto failed;
- options_dn = ldb_dn_new(options, module->ldb, LTDB_OPTIONS);
+ options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS);
if (options_dn == NULL) goto failed;
r= ltdb_search_dn1(module, options_dn, options);
@@ -336,7 +351,7 @@ int ltdb_cache_load(struct ldb_module *module)
goto failed;
}
- indexlist_dn = ldb_dn_new(module, module->ldb, LTDB_INDEXLIST);
+ indexlist_dn = ldb_dn_new(module, ldb, LTDB_INDEXLIST);
if (indexlist_dn == NULL) goto failed;
r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist);
@@ -369,7 +384,9 @@ failed:
*/
int ltdb_increase_sequence_number(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
struct ldb_message_element el[2];
struct ldb_val val;
@@ -378,6 +395,8 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
char *s = NULL;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
msg = talloc(ltdb, struct ldb_message);
if (msg == NULL) {
errno = ENOMEM;
@@ -392,7 +411,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
msg->num_elements = ARRAY_SIZE(el);
msg->elements = el;
- msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO);
+ msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO);
if (msg->dn == NULL) {
talloc_free(msg);
errno = ENOMEM;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index c4c23022f8..cdbef3944b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -31,8 +31,6 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
@@ -69,8 +67,8 @@ struct ltdb_idxptr {
*/
static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->idxptr->dn_list = talloc_realloc(ltdb->idxptr, ltdb->idxptr->dn_list,
const char *, ltdb->idxptr->num_dns+1);
if (ltdb->idxptr->dn_list == NULL) {
@@ -177,8 +175,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_
struct ldb_index_pointer *ptr, *tmp;
int i;
struct ldb_val *val2;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ptr = NULL;
@@ -216,8 +214,8 @@ static int ltdb_convert_to_idxptr(struct ldb_module *module, struct ldb_message_
/* enable the idxptr mode when transactions start */
int ltdb_index_transaction_start(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->idxptr = talloc_zero(module, struct ltdb_idxptr);
return LDB_SUCCESS;
}
@@ -260,11 +258,14 @@ static int ltdb_search_dn1_index(struct ldb_module *module,
*/
static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn;
struct ldb_message *msg = ldb_msg_new(module);
int ret;
- dn = ldb_dn_new(msg, module->ldb, strdn);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new(msg, ldb, strdn);
if (ltdb_search_dn1_index(module, dn, msg) == LDB_SUCCESS) {
ret = ltdb_store(module, msg, TDB_REPLACE);
}
@@ -276,8 +277,8 @@ static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn)
int ltdb_index_transaction_commit(struct ldb_module *module)
{
int i;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
/* fix all the DNs that we have modified */
if (ltdb->idxptr) {
@@ -298,8 +299,8 @@ int ltdb_index_transaction_commit(struct ldb_module *module)
/* cleanup the idxptr mode when transaction cancels */
int ltdb_index_transaction_cancel(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
talloc_free(ltdb->idxptr);
ltdb->idxptr = NULL;
return LDB_SUCCESS;
@@ -314,8 +315,8 @@ int ltdb_index_transaction_cancel(struct ldb_module *module)
*/
int ltdb_store_idxptr(struct ldb_module *module, const struct ldb_message *msg, int flgs)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb->idxptr) {
@@ -510,12 +511,14 @@ static int ltdb_index_dn_simple(struct ldb_module *module,
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_dn *dn;
int ret;
unsigned int i, j;
struct ldb_message *msg;
+ ldb = ldb_module_get_ctx(module);
+
list->count = 0;
list->dn = NULL;
@@ -587,15 +590,18 @@ static int ltdb_index_dn_leaf(struct ldb_module *module,
const struct ldb_message *index_list,
struct dn_list *list)
{
+ struct ldb_context *ldb;
+ ldb = ldb_module_get_ctx(module);
+
if (ldb_attr_dn(tree->u.equality.attr) == 0) {
list->dn = talloc_array(list, char *, 1);
if (list->dn == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
list->dn[0] = talloc_strdup(list->dn, (char *)tree->u.equality.value.data);
if (list->dn[0] == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
list->count = 1;
@@ -707,10 +713,12 @@ static int ltdb_index_dn_or(struct ldb_module *module,
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
@@ -791,10 +799,12 @@ static int ltdb_index_dn_and(struct ldb_module *module,
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
@@ -852,7 +862,7 @@ static int ltdb_index_dn_one(struct ldb_module *module,
struct ldb_dn *parent_dn,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct dn_list *list2;
struct ldb_message *msg;
struct ldb_dn *key;
@@ -860,6 +870,8 @@ static int ltdb_index_dn_one(struct ldb_module *module,
unsigned int i, j;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
list2 = talloc_zero(module, struct dn_list);
if (list2 == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -991,9 +1003,12 @@ static int ltdb_index_dn(struct ldb_module *module,
static int ltdb_index_filter(const struct dn_list *dn_list,
struct ltdb_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_message *msg;
unsigned int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn;
int ret;
@@ -1003,7 +1018,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]);
+ dn = ldb_dn_new(msg, ldb, dn_list->dn[i]);
if (dn == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
@@ -1023,7 +1038,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
return LDB_ERR_OPERATIONS_ERROR;
}
- if (!ldb_match_msg(ac->module->ldb, msg,
+ if (!ldb_match_msg(ldb, msg,
ac->tree, ac->base, ac->scope)) {
talloc_free(msg);
continue;
@@ -1054,10 +1069,14 @@ static int ltdb_index_filter(const struct dn_list *dn_list,
*/
int ltdb_search_indexed(struct ltdb_context *ac)
{
- struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(ac->module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct dn_list *dn_list;
int ret, idxattr, idxone;
+ ldb = ldb_module_get_ctx(ac->module);
+
idxattr = idxone = 0;
ret = ldb_msg_find_idx(ltdb->cache->indexlist, NULL, NULL, LTDB_IDXATTR);
if (ret == 0 ) {
@@ -1087,12 +1106,12 @@ int ltdb_search_indexed(struct ltdb_context *ac)
/* with BASE searches only one DN can match */
dn_list->dn = talloc_array(dn_list, char *, 1);
if (dn_list->dn == NULL) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dn_list->dn[0] = ldb_dn_alloc_linearized(dn_list, ac->base);
if (dn_list->dn[0] == NULL) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dn_list->count = 1;
@@ -1198,12 +1217,14 @@ static int ltdb_index_add1_add(struct ldb_context *ldb,
static int ltdb_index_add1(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_message *msg;
struct ldb_dn *dn_key;
int ret;
unsigned int i;
+ ldb = ldb_module_get_ctx(module);
+
msg = talloc(module, struct ldb_message);
if (msg == NULL) {
errno = ENOMEM;
@@ -1253,7 +1274,8 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn,
static int ltdb_index_add0(struct ldb_module *module, const char *dn,
struct ldb_message_element *elements, int num_el)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
unsigned int i, j;
@@ -1308,12 +1330,14 @@ int ltdb_index_add(struct ldb_module *module, const struct ldb_message *msg)
int ltdb_index_del_value(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_message *msg;
struct ldb_dn *dn_key;
int ret, i;
unsigned int j;
+ ldb = ldb_module_get_ctx(module);
+
if (dn[0] == '@') {
return LDB_SUCCESS;
}
@@ -1351,7 +1375,7 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
ldb_dn_get_linearized(dn_key));
ldif.changetype = LDB_CHANGETYPE_NONE;
ldif.msg = msg;
- ldb_ldif_write_file(module->ldb, stdout, &ldif);
+ ldb_ldif_write_file(ldb, stdout, &ldif);
sleep(100);
/* it ain't there. hmmm */
talloc_free(dn_key);
@@ -1383,7 +1407,8 @@ int ltdb_index_del_value(struct ldb_module *module, const char *dn,
*/
int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
const char *dn;
unsigned int i, j;
@@ -1425,7 +1450,8 @@ int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
*/
int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message_element el;
struct ldb_val val;
struct ldb_dn *pdn;
@@ -1489,12 +1515,15 @@ static int delete_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, vo
*/
static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
+ struct ldb_context *ldb;
struct ldb_module *module = (struct ldb_module *)state;
struct ldb_message *msg;
const char *dn = NULL;
int ret;
TDB_DATA key2;
+ ldb = ldb_module_get_ctx(module);
+
if (strncmp((char *)key.dptr, "DN=@", 4) == 0 ||
strncmp((char *)key.dptr, "DN=", 3) != 0) {
return 0;
@@ -1516,7 +1545,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
key2 = ltdb_key(module, msg->dn);
if (key2.dptr == NULL) {
/* probably a corrupt record ... darn */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n",
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n",
ldb_dn_get_linearized(msg->dn));
talloc_free(msg);
return 0;
@@ -1537,7 +1566,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
if (ret == LDB_SUCCESS) {
ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements);
} else {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Adding special ONE LEVEL index failed (%s)!\n",
ldb_dn_get_linearized(msg->dn));
}
@@ -1554,7 +1583,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
*/
int ltdb_reindex(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb_cache_reload(module) != 0) {
diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c
index afb07dcbca..1995606f88 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_pack.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c
@@ -31,7 +31,6 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
#include "ldb_tdb.h"
/* change this if the data format ever changes */
@@ -79,13 +78,15 @@ int ltdb_pack_data(struct ldb_module *module,
const struct ldb_message *message,
struct TDB_DATA *data)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i, j, real_elements=0;
size_t size;
const char *dn;
uint8_t *p;
size_t len;
+ ldb = ldb_module_get_ctx(module);
+
dn = ldb_dn_get_linearized(message->dn);
if (dn == NULL) {
errno = ENOMEM;
@@ -159,13 +160,14 @@ int ltdb_unpack_data(struct ldb_module *module,
const struct TDB_DATA *data,
struct ldb_message *message)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
uint8_t *p;
unsigned int remaining;
unsigned int i, j;
unsigned format;
size_t len;
+ ldb = ldb_module_get_ctx(module);
message->elements = NULL;
p = data->dptr;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 35149c4b77..0f595267fc 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -31,8 +31,6 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
@@ -112,10 +110,12 @@ static int msg_add_distinguished_name(struct ldb_message *msg)
static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *ret,
const struct ldb_message *msg)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int check_duplicates = (ret->num_elements != 0);
+ ldb = ldb_module_get_ctx(module);
+
if (msg_add_distinguished_name(ret) != 0) {
return -1;
}
@@ -207,7 +207,8 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module,
*/
static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
if (ldb_dn_is_null(dn)) {
@@ -239,7 +240,8 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
*/
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
TDB_DATA tdb_key, tdb_data;
@@ -371,11 +373,13 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs)
*/
static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
+ struct ldb_context *ldb;
struct ltdb_context *ac;
struct ldb_message *msg;
int ret;
ac = talloc_get_type(state, struct ltdb_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (key.dsize < 4 ||
strncmp((char *)key.dptr, "DN=", 3) != 0) {
@@ -395,7 +399,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
}
if (!msg->dn) {
- msg->dn = ldb_dn_new(msg, ac->module->ldb,
+ msg->dn = ldb_dn_new(msg, ldb,
(char *)key.dptr + 3);
if (msg->dn == NULL) {
talloc_free(msg);
@@ -404,7 +408,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
}
/* see if it matches the given expression */
- if (!ldb_match_msg(ac->module->ldb, msg,
+ if (!ldb_match_msg(ldb, msg,
ac->tree, ac->base, ac->scope)) {
talloc_free(msg);
return 0;
@@ -435,7 +439,8 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi
*/
static int ltdb_search_full(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(ctx->module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb->in_transaction != 0) {
@@ -457,12 +462,16 @@ static int ltdb_search_full(struct ltdb_context *ctx)
*/
int ltdb_search(struct ltdb_context *ctx)
{
+ struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
- struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -483,12 +492,12 @@ int ltdb_search(struct ltdb_context *ctx)
/* Check what we should do with a NULL dn */
switch (req->op.search.scope) {
case LDB_SCOPE_BASE:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a base search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
case LDB_SCOPE_ONELEVEL:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a one-level search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
@@ -500,7 +509,7 @@ int ltdb_search(struct ltdb_context *ctx)
} else if (ldb_dn_is_valid(req->op.search.base) == false) {
/* We don't want invalid base DNs here */
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Invalid Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
ret = LDB_ERR_INVALID_DN_SYNTAX;
@@ -510,7 +519,7 @@ int ltdb_search(struct ltdb_context *ctx)
ret = ltdb_search_base(module, req->op.search.base);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"No such Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
}
@@ -539,7 +548,7 @@ int ltdb_search(struct ltdb_context *ctx)
/* Not indexed, so we need to do a full scan */
ret = ltdb_search_full(ctx);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n");
+ ldb_set_errstring(ldb, "Indexed and full searches both failed!\n");
}
}
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 9528f5a662..d6276c4b86 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -45,8 +45,6 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
@@ -84,7 +82,8 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code)
*/
int ltdb_lock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (ltdb->in_transaction == 0) {
return tdb_lockall_read(ltdb->tdb);
}
@@ -96,7 +95,8 @@ int ltdb_lock_read(struct ldb_module *module)
*/
int ltdb_unlock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (ltdb->in_transaction == 0) {
return tdb_unlockall_read(ltdb->tdb);
}
@@ -113,7 +113,7 @@ int ltdb_unlock_read(struct ldb_module *module)
*/
struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
TDB_DATA key;
char *key_str = NULL;
const char *dn_folded = NULL;
@@ -164,6 +164,7 @@ failed:
static int ltdb_check_special_dn(struct ldb_module *module,
const struct ldb_message *msg)
{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
int i, j;
if (! ldb_dn_is_special(msg->dn) ||
@@ -176,7 +177,7 @@ static int ltdb_check_special_dn(struct ldb_module *module,
for (i = 0; i < msg->num_elements; i++) {
for (j = 0; j < msg->elements[i].num_values; j++) {
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
- ldb_set_errstring(module->ldb, "Invalid attribute value in an @ATTRIBUTES entry");
+ ldb_set_errstring(ldb, "Invalid attribute value in an @ATTRIBUTES entry");
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
}
@@ -214,8 +215,8 @@ static int ltdb_modified(struct ldb_module *module, struct ldb_dn *dn)
*/
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
int ret;
@@ -252,6 +253,7 @@ done:
static int ltdb_add_internal(struct ldb_module *module,
const struct ldb_message *msg)
{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
int ret;
ret = ltdb_check_special_dn(module, msg);
@@ -266,7 +268,7 @@ static int ltdb_add_internal(struct ldb_module *module,
ret = ltdb_store(module, msg, TDB_INSERT);
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Entry %s already exists",
ldb_dn_get_linearized(msg->dn));
return ret;
@@ -296,7 +298,7 @@ static int ltdb_add(struct ltdb_context *ctx)
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
@@ -312,8 +314,8 @@ static int ltdb_add(struct ltdb_context *ctx)
*/
int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key;
int ret;
@@ -386,7 +388,7 @@ static int ltdb_delete(struct ltdb_context *ctx)
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_cache_load(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -514,7 +516,7 @@ static int msg_delete_element(struct ldb_module *module,
const char *name,
const struct ldb_val *val)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
unsigned int i;
int found;
struct ldb_message_element *el;
@@ -560,9 +562,9 @@ static int msg_delete_element(struct ldb_module *module,
int ltdb_modify_internal(struct ldb_module *module,
const struct ldb_message *msg)
{
- struct ldb_context *ldb = module->ldb;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ 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);
TDB_DATA tdb_key, tdb_data;
struct ldb_message *msg2;
unsigned i, j;
@@ -625,12 +627,12 @@ int ltdb_modify_internal(struct ldb_module *module,
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d already exists", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d already exists", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
@@ -661,7 +663,7 @@ int ltdb_modify_internal(struct ldb_module *module,
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
@@ -688,7 +690,7 @@ int ltdb_modify_internal(struct ldb_module *module,
if (msg->elements[i].num_values == 0) {
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
- ldb_asprintf_errstring(module->ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn);
+ ldb_asprintf_errstring(ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -699,7 +701,7 @@ int ltdb_modify_internal(struct ldb_module *module,
msg2,
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
- ldb_asprintf_errstring(module->ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn);
+ ldb_asprintf_errstring(ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
@@ -710,7 +712,7 @@ int ltdb_modify_internal(struct ldb_module *module,
}
break;
default:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Invalid ldb_modify flags on %s: 0x%x",
msg->elements[i].name,
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
@@ -750,7 +752,7 @@ static int ltdb_modify(struct ltdb_context *ctx)
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
@@ -779,7 +781,7 @@ static int ltdb_rename(struct ltdb_context *ctx)
struct ldb_message *msg;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_cache_load(ctx->module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -841,8 +843,8 @@ static int ltdb_rename(struct ltdb_context *ctx)
static int ltdb_start_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (tdb_transaction_start(ltdb->tdb) != 0) {
return ltdb_err_map(tdb_error(ltdb->tdb));
@@ -857,8 +859,8 @@ static int ltdb_start_trans(struct ldb_module *module)
static int ltdb_end_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->in_transaction--;
@@ -875,8 +877,8 @@ static int ltdb_end_trans(struct ldb_module *module)
static int ltdb_del_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->in_transaction--;
@@ -897,6 +899,7 @@ static int ltdb_del_trans(struct ldb_module *module)
static int ltdb_sequence_number(struct ltdb_context *ctx,
struct ldb_extended **ext)
{
+ struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
TALLOC_CTX *tmp_ctx;
@@ -907,13 +910,15 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
const char *date;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
seq = talloc_get_type(req->op.extended.data,
struct ldb_seqnum_request);
if (seq == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -930,7 +935,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx,
goto done;
}
- dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO);
+ dn = ldb_dn_new(tmp_ctx, ldb, LTDB_BASEINFO);
msg = talloc(tmp_ctx, struct ldb_message);
if (msg == NULL) {
@@ -978,18 +983,23 @@ done:
return ret;
}
-static void ltdb_request_done(struct ldb_request *req, int error)
+static void ltdb_request_done(struct ltdb_context *ctx, int error)
{
+ struct ldb_context *ldb;
+ struct ldb_request *req;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+ req = ctx->req;
+
/* if we already returned an error just return */
- if (req->handle->status != LDB_SUCCESS) {
+ if (ldb_request_get_status(req) != LDB_SUCCESS) {
return;
}
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb);
req->callback(req, NULL);
return;
}
@@ -1007,23 +1017,28 @@ static void ltdb_timeout(struct tevent_context *ev,
struct ltdb_context *ctx;
ctx = talloc_get_type(private_data, struct ltdb_context);
- ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED);
+ ltdb_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED);
}
-static void ltdb_request_extended_done(struct ldb_request *req,
+static void ltdb_request_extended_done(struct ltdb_context *ctx,
struct ldb_extended *ext,
int error)
{
+ struct ldb_context *ldb;
+ struct ldb_request *req;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+ req = ctx->req;
+
/* if we already returned an error just return */
- if (req->handle->status != LDB_SUCCESS) {
+ if (ldb_request_get_status(req) != LDB_SUCCESS) {
return;
}
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb);
req->callback(req, NULL);
return;
}
@@ -1048,7 +1063,7 @@ static void ltdb_handle_extended(struct ltdb_context *ctx)
ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
- ltdb_request_extended_done(ctx->req, ext, ret);
+ ltdb_request_extended_done(ctx, ext, ret);
}
static void ltdb_callback(struct tevent_context *ev,
@@ -1088,13 +1103,14 @@ static void ltdb_callback(struct tevent_context *ev,
if (!ctx->callback_failed) {
/* Once we are done, we do not need timeout events */
talloc_free(ctx->timeout_event);
- ltdb_request_done(ctx->req, ret);
+ ltdb_request_done(ctx, ret);
}
}
static int ltdb_handle_request(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct tevent_context *ev;
struct ltdb_context *ac;
struct tevent_timer *te;
@@ -1104,16 +1120,18 @@ static int ltdb_handle_request(struct ldb_module *module,
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
+ ldb = ldb_module_get_ctx(module);
+
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
- ev = ldb_get_event_context(module->ldb);
+ ev = ldb_get_event_context(ldb);
ac = talloc_zero(req, struct ltdb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -1154,8 +1172,9 @@ static const struct ldb_module_ops ltdb_ops = {
*/
static int ltdb_connect(struct ldb_context *ldb, const char *url,
unsigned int flags, const char *options[],
- struct ldb_module **module)
+ struct ldb_module **_module)
{
+ struct ldb_module *module;
const char *path;
int tdb_flags, open_flags;
struct ltdb_private *ltdb;
@@ -1199,7 +1218,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
/* note that we use quite a large default hash size */
ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000,
tdb_flags, open_flags,
- ldb->create_perms, ldb);
+ ldb_get_create_perms(ldb), ldb);
if (!ltdb->tdb) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Unable to open tdb '%s'\n", path);
@@ -1209,24 +1228,20 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
ltdb->sequence_number = 0;
- *module = talloc(ldb, struct ldb_module);
- if ((*module) == NULL) {
- ldb_oom(ldb);
+ module = ldb_module_new(ldb, ldb, "ldb_tdb backend", &ltdb_ops);
+ if (!module) {
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 = &ltdb_ops;
+ ldb_module_set_private(module, ltdb);
- if (ltdb_cache_load(*module) != 0) {
- talloc_free(*module);
+ if (ltdb_cache_load(module) != 0) {
+ talloc_free(module);
talloc_free(ltdb);
return -1;
}
+ *_module = module;
return 0;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index b373d37b7e..7ebf199f6f 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -6,6 +6,8 @@
#include "tdb.h"
#endif
+#include "ldb_module.h"
+
/* this private structure is used by the ltdb backend in the
ldb_context */
struct ltdb_private {
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
index 4fea43c8c8..6ee8417e25 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
@@ -21,8 +21,6 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index c650970af4..475b609e41 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -32,7 +32,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct asq_context {
@@ -63,11 +63,14 @@ struct asq_context {
static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct asq_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct asq_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
@@ -206,9 +209,12 @@ static int asq_reqs_callback(struct ldb_request *req, struct ldb_reply *ares)
static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req)
{
+ struct ldb_context *ldb;
const char **base_attrs;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
ac->req_attrs = ac->req->op.search.attrs;
ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute);
if (ac->req_attribute == NULL)
@@ -222,7 +228,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request **
base_attrs[1] = NULL;
- ret = ldb_build_search_req(base_req, ac->module->ldb, ac,
+ ret = ldb_build_search_req(base_req, ldb, ac,
ac->req->op.search.base,
LDB_SCOPE_BASE,
NULL,
@@ -239,6 +245,7 @@ static int asq_build_first_request(struct asq_context *ac, struct ldb_request **
static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
{
+ struct ldb_context *ldb;
struct ldb_control **saved_controls;
struct ldb_control *control;
struct ldb_dn *dn;
@@ -249,6 +256,8 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
return LDB_ERR_NO_SUCH_OBJECT;
}
+ ldb = ldb_module_get_ctx(ac->module);
+
el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute);
/* no values found */
if (el == NULL) {
@@ -266,7 +275,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
for (i = 0; i < el->num_values; i++) {
- dn = ldb_dn_new(ac, ac->module->ldb,
+ dn = ldb_dn_new(ac, ldb,
(const char *)el->values[i].data);
if ( ! ldb_dn_validate(dn)) {
ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX;
@@ -275,7 +284,7 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
}
ret = ldb_build_search_req_ex(&ac->reqs[i],
- ac->module->ldb, ac,
+ ldb, ac,
dn, LDB_SCOPE_BASE,
ac->req->op.search.tree,
ac->req_attrs,
@@ -298,9 +307,12 @@ static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
static int asq_search_continue(struct asq_context *ac)
{
+ struct ldb_context *ldb;
bool terminated = false;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
switch (ac->step) {
case ASQ_SEARCH_BASE:
@@ -312,7 +324,7 @@ static int asq_search_continue(struct asq_context *ac)
ac->step = ASQ_SEARCH_MULTI;
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
+ return ldb_request(ldb, ac->reqs[ac->cur_req]);
case ASQ_SEARCH_MULTI:
@@ -323,7 +335,7 @@ static int asq_search_continue(struct asq_context *ac)
return asq_search_terminate(ac);
}
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
+ return ldb_request(ldb, ac->reqs[ac->cur_req]);
}
return LDB_ERR_OPERATIONS_ERROR;
@@ -331,11 +343,14 @@ static int asq_search_continue(struct asq_context *ac)
static int asq_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *base_req;
struct ldb_control *control;
struct asq_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID);
if (control == NULL) {
@@ -366,16 +381,19 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req)
ac->step = ASQ_SEARCH_BASE;
- return ldb_request(module->ldb, base_req);
+ return ldb_request(ldb, base_req);
}
static int asq_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = ldb_mod_register_control(module, LDB_CONTROL_ASQ_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n");
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n");
}
return ldb_next_init(module);
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 11c06c81bb..d862638389 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -73,7 +73,7 @@
modifiersName: not supported by w2k3?
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
/*
construct a canonical name from a message
@@ -126,8 +126,11 @@ static int operational_search_post_process(struct ldb_module *module,
struct ldb_message *msg,
const char * const *attrs)
{
+ struct ldb_context *ldb;
int i, a=0;
+ ldb = ldb_module_get_ctx(module);
+
for (a=0;attrs && attrs[a];a++) {
for (i=0;i<ARRAY_SIZE(search_sub);i++) {
if (ldb_attr_cmp(attrs[a], search_sub[i].attr) != 0) {
@@ -161,7 +164,7 @@ static int operational_search_post_process(struct ldb_module *module,
return 0;
failed:
- ldb_debug_set(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug_set(ldb, LDB_DEBUG_WARNING,
"operational_search_post_process failed for attribute '%s'\n",
attrs[a]);
return -1;
@@ -224,12 +227,15 @@ static int operational_callback(struct ldb_request *req, struct ldb_reply *ares)
static int operational_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct operational_context *ac;
struct ldb_request *down_req;
const char **search_attrs = NULL;
int i, a;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc(req, struct operational_context);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -268,7 +274,7 @@ static int operational_search(struct ldb_module *module, struct ldb_request *req
}
}
- ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&down_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index dfc565fef8..7d7cdf66a0 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -32,7 +32,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct message_store {
/* keep the whole ldb_reply as an optimization
@@ -290,6 +290,7 @@ static int paged_search_callback(struct ldb_request *req, struct ldb_reply *ares
static int paged_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_control *control;
struct private_data *private_data;
struct ldb_paged_control *paged_ctrl;
@@ -298,6 +299,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
struct paged_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID);
if (control == NULL) {
@@ -310,11 +313,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_PROTOCOL_ERROR;
}
- private_data = talloc_get_type(module->private_data, struct private_data);
+ private_data = talloc_get_type(ldb_module_get_private(module),
+ struct private_data);
ac = talloc_zero(req, struct paged_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -333,7 +337,7 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req_ex(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&search_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
@@ -385,9 +389,12 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
static int paged_request_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct private_data *data;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
return LDB_ERR_OTHER;
@@ -395,11 +402,11 @@ static int paged_request_init(struct ldb_module *module)
data->next_free_id = 1;
data->store = NULL;
- module->private_data = data;
+ ldb_module_set_private(module, data);
ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"paged_request:"
"Unable to register control with rootdse!\n");
}
diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c
index 56f9b1cac3..01e77cb22c 100644
--- a/source4/lib/ldb/modules/paged_searches.c
+++ b/source4/lib/ldb/modules/paged_searches.c
@@ -33,7 +33,7 @@
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#define PS_DEFAULT_PAGE_SIZE 500
/* 500 objects per query seem to be a decent compromise
@@ -211,10 +211,12 @@ static int ps_callback(struct ldb_request *req, struct ldb_reply *ares)
static int ps_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct private_data *private_data;
struct ps_context *ac;
- private_data = talloc_get_type(module->private_data, struct private_data);
+ private_data = talloc_get_type(ldb_module_get_private(module), struct private_data);
+ ldb = ldb_module_get_ctx(module);
/* check if paging is supported and if there is a any control */
if (!private_data || !private_data->paged_supported || req->controls) {
@@ -226,7 +228,7 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req)
ac = talloc_zero(req, struct ps_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -241,11 +243,14 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req)
static int ps_next_request(struct ps_context *ac) {
+ struct ldb_context *ldb;
struct ldb_paged_control *control;
struct ldb_control **controls;
struct ldb_request *new_req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
controls = talloc_array(ac, struct ldb_control *, 2);
if (!controls) {
return LDB_ERR_OPERATIONS_ERROR;
@@ -270,7 +275,7 @@ static int ps_next_request(struct ps_context *ac) {
controls[0]->data = control;
controls[1] = NULL;
- ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac,
+ ret = ldb_build_search_req_ex(&new_req, ldb, ac,
ac->req->op.search.base,
ac->req->op.search.scope,
ac->req->op.search.tree,
@@ -324,26 +329,30 @@ static int check_supported_paged(struct ldb_request *req,
static int ps_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
static const char *attrs[] = { "supportedControl", NULL };
struct private_data *data;
struct ldb_dn *base;
int ret;
struct ldb_request *req;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
data->paged_supported = false;
- base = ldb_dn_new(module, module->ldb, "");
+ ldb_module_set_private(module, data);
+
+ base = ldb_dn_new(module, ldb, "");
if (base == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req(&req, module->ldb, module,
+ ret = ldb_build_search_req(&req, ldb, module,
base, LDB_SCOPE_BASE,
"(objectClass=*)",
attrs, NULL,
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 62b8ce5112..a5ffcc034a 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -36,7 +36,7 @@
* Simo Sorce Mar 2006
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct rename_context {
@@ -86,6 +86,7 @@ static int rdn_name_add_callback(struct ldb_request *req,
static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct rename_context *ac;
struct ldb_message *msg;
@@ -95,7 +96,8 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
struct ldb_val rdn_val;
int i, ret;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
@@ -141,10 +143,10 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
- a = ldb_schema_attribute_by_name(module->ldb, rdn_name);
+ a = ldb_schema_attribute_by_name(ldb, rdn_name);
for (i = 0; i < attribute->num_values; i++) {
- ret = a->syntax->comparison_fn(module->ldb, msg,
+ ret = a->syntax->comparison_fn(ldb, msg,
&rdn_val, &attribute->values[i]);
if (ret == 0) {
/* overwrite so it matches in case */
@@ -153,7 +155,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
}
}
if (i == attribute->num_values) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"RDN mismatch on %s: %s (%s)",
ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
talloc_free(ac);
@@ -162,7 +164,7 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
}
}
- ret = ldb_build_add_req(&down_req, module->ldb, req,
+ ret = ldb_build_add_req(&down_req, ldb, req,
msg,
req->controls,
ac, rdn_name_add_callback,
@@ -205,6 +207,7 @@ static int rdn_modify_callback(struct ldb_request *req, struct ldb_reply *ares)
static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct rename_context *ac;
struct ldb_request *mod_req;
const char *rdn_name;
@@ -213,6 +216,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
int ret;
ac = talloc_get_type(req->context, struct rename_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
goto error;
@@ -258,7 +262,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
goto error;
}
- ret = ldb_build_mod_req(&mod_req, ac->module->ldb,
+ ret = ldb_build_mod_req(&mod_req, ldb,
ac, msg, NULL,
ac, rdn_modify_callback,
req);
@@ -268,7 +272,7 @@ static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
talloc_steal(mod_req, msg);
/* do the mod call */
- return ldb_request(ac->module->ldb, mod_req);
+ return ldb_request(ldb, mod_req);
error:
return ldb_module_done(ac->req, NULL, NULL,
@@ -277,11 +281,13 @@ error:
static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct rename_context *ac;
struct ldb_request *down_req;
int ret;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
+ ldb = ldb_module_get_ctx(module);
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.rename.newdn)) {
@@ -297,7 +303,7 @@ static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
ac->req = req;
ret = ldb_build_rename_req(&down_req,
- module->ldb,
+ ldb,
ac,
req->op.rename.olddn,
req->op.rename.newdn,
diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c
index 0cd29ac4b7..248f9b346b 100644
--- a/source4/lib/ldb/modules/skel.c
+++ b/source4/lib/ldb/modules/skel.c
@@ -31,7 +31,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct private_data {
@@ -87,9 +87,13 @@ static int skel_del_trans(struct ldb_module *module)
static int skel_destructor(struct ldb_module *ctx)
{
- struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
+ struct private_data *data;
+
+ data = talloc_get_type(ldb_module_get_private(ctx), struct private_data);
+
/* put your clean-up functions here */
if (data->some_private_data) talloc_free(data->some_private_data);
+
return 0;
}
@@ -100,16 +104,19 @@ static int skel_request(struct ldb_module *module, struct ldb_request *req)
static int skel_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct private_data *data;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
data->some_private_data = NULL;
- module->private_data = data;
+ ldb_module_set_private(module, data);
talloc_set_destructor (module, skel_destructor);
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 25e56b24c8..2b2a1ab1e3 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -31,7 +31,7 @@
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct opaque {
struct ldb_context *ldb;
@@ -104,6 +104,9 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
{
struct sort_context *ac = talloc_get_type(opaque, struct sort_context);
struct ldb_message_element *el1, *el2;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(ac->module);
if (!ac || ac->sort_result != 0) {
/* an error occurred previously,
@@ -122,17 +125,20 @@ static int sort_compare(struct ldb_message **msg1, struct ldb_message **msg2, vo
}
if (ac->reverse)
- return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el2->values[0], &el1->values[0]);
+ return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);
- return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]);
+ return ac->a->syntax->comparison_fn(ldb, ac, &el1->values[0], &el2->values[0]);
}
static int server_sort_results(struct sort_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_reply *ares;
int i, ret;
- ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName);
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ac->a = ldb_schema_attribute_by_name(ldb, ac->attributeName);
ac->sort_result = 0;
ldb_qsort(ac->msgs, ac->num_msgs,
@@ -179,9 +185,11 @@ static int server_sort_results(struct sort_context *ac)
static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct sort_context *ac;
+ struct ldb_context *ldb;
int ret;
ac = talloc_get_type(req->context, struct sort_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
@@ -197,7 +205,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply
ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2);
if (! ac->msgs) {
talloc_free(ares);
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -212,7 +220,7 @@ static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply
ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2);
if (! ac->referrals) {
talloc_free(ares);
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
@@ -242,8 +250,11 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
struct ldb_control **controls;
struct ldb_request *down_req;
struct sort_context *ac;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_SERVER_SORT_OID);
if (control == NULL) {
@@ -253,7 +264,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
ac = talloc_zero(req, struct sort_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -291,7 +302,7 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
ac->orderingRule = sort_ctrls[0]->orderingRule;
ac->reverse = sort_ctrls[0]->reverse;
- ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&down_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
@@ -316,11 +327,14 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
static int server_sort_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"server_sort:"
"Unable to register control with rootdse!\n");
}
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 9e98363c6f..f71ee23340 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -25,7 +25,7 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include <Python.h>
#include "pyldb.h"
diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c
index 1a9e72c907..bbe4419b59 100644
--- a/source4/lib/ldb/tests/sample_module.c
+++ b/source4/lib/ldb/tests/sample_module.c
@@ -21,9 +21,7 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
-#include "ldb.h"
-#include "ldb_errors.h"
+#include "ldb_module.h"
int sample_add(struct ldb_module *mod, struct ldb_request *req)
{
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 765d8b9edf..3dce9b187b 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -21,7 +21,7 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
#if (_SAMBA_BUILD_ >= 4)
@@ -91,7 +91,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
ret = talloc_zero(ldb, struct ldb_cmdline);
if (ret == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
@@ -139,7 +139,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
options.options = talloc_realloc(ret, options.options,
const char *, num_options+3);
if (options.options == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
options.options[num_options] = poptGetOptArg(pc);
@@ -156,7 +156,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
options.controls = talloc_array(ret, char *, cc + 1);
if (options.controls == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
for (p = cs, cc = 0; p != NULL; cc++) {
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index f32a4fa9bc..be02334797 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int failures;
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 22d4aa6976..232f51681a 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn)
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 1a684c5c2d..3a915f8bea 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static struct ldb_cmdline *options;
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 6e355a10cf..c3f55c6096 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int failures;
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index a5feb7a091..01ed3d9835 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -33,7 +33,7 @@
* Author: Stefan Metzmacher
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static void usage(void)
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index ceabd5cd78..35d4ac7002 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static void usage(void)
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index f3d6d621a9..edaa9fb85c 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -31,7 +31,7 @@
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static struct timeval tp1,tp2;
diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk
index 11157c5b63..2708c66b68 100644
--- a/source4/libcli/ldap/config.mk
+++ b/source4/libcli/ldap/config.mk
@@ -13,6 +13,6 @@ PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h $(libclisrcdir)/ldap/ldap_ndr.h
$(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c)))
[SUBSYSTEM::LDAP_ENCODE]
-# FIXME PRIVATE_DEPENDENCIES = LIBLDB
+PRIVATE_DEPENDENCIES = LIBLDB
LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index 5538c9dc06..abb4617c48 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -21,6 +21,7 @@
#ifndef _SMB_LDAP_H_
#define _SMB_LDAP_H_
+#include "libcli/ldap/ldap_errors.h"
#include "lib/ldb/include/ldb.h"
#include "librpc/gen_ndr/misc.h"
@@ -52,48 +53,6 @@ enum ldap_auth_mechanism {
LDAP_AUTH_MECH_SASL = 3
};
-enum ldap_result_code {
- LDAP_SUCCESS = 0,
- LDAP_OPERATIONS_ERROR = 1,
- LDAP_PROTOCOL_ERROR = 2,
- LDAP_TIME_LIMIT_EXCEEDED = 3,
- LDAP_SIZE_LIMIT_EXCEEDED = 4,
- LDAP_COMPARE_FALSE = 5,
- LDAP_COMPARE_TRUE = 6,
- LDAP_AUTH_METHOD_NOT_SUPPORTED = 7,
- LDAP_STRONG_AUTH_REQUIRED = 8,
- LDAP_REFERRAL = 10,
- LDAP_ADMIN_LIMIT_EXCEEDED = 11,
- LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12,
- LDAP_CONFIDENTIALITY_REQUIRED = 13,
- LDAP_SASL_BIND_IN_PROGRESS = 14,
- LDAP_NO_SUCH_ATTRIBUTE = 16,
- LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17,
- LDAP_INAPPROPRIATE_MATCHING = 18,
- LDAP_CONSTRAINT_VIOLATION = 19,
- LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20,
- LDAP_INVALID_ATTRIBUTE_SYNTAX = 21,
- LDAP_NO_SUCH_OBJECT = 32,
- LDAP_ALIAS_PROBLEM = 33,
- LDAP_INVALID_DN_SYNTAX = 34,
- LDAP_ALIAS_DEREFERENCING_PROBLEM = 36,
- LDAP_INAPPROPRIATE_AUTHENTICATION = 48,
- LDAP_INVALID_CREDENTIALS = 49,
- LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50,
- LDAP_BUSY = 51,
- LDAP_UNAVAILABLE = 52,
- LDAP_UNWILLING_TO_PERFORM = 53,
- LDAP_LOOP_DETECT = 54,
- LDAP_NAMING_VIOLATION = 64,
- LDAP_OBJECT_CLASS_VIOLATION = 65,
- LDAP_NOT_ALLOWED_ON_NON_LEAF = 66,
- LDAP_NOT_ALLOWED_ON_RDN = 67,
- LDAP_ENTRY_ALREADY_EXISTS = 68,
- LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69,
- LDAP_AFFECTS_MULTIPLE_DSAS = 71,
- LDAP_OTHER = 80
-};
-
struct ldap_Result {
int resultcode;
const char *dn;
diff --git a/source4/libcli/ldap/ldap_errors.h b/source4/libcli/ldap/ldap_errors.h
new file mode 100644
index 0000000000..17ac43814c
--- /dev/null
+++ b/source4/libcli/ldap/ldap_errors.h
@@ -0,0 +1,66 @@
+/*
+ Unix SMB/CIFS Implementation.
+ LDAP protocol helper functions for SAMBA
+ Copyright (C) Volker Lendecke 2004
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _SMB_LDAP_ERRORS_H_
+#define _SMB_LDAP_ERRORS_H_
+
+enum ldap_result_code {
+ LDAP_SUCCESS = 0,
+ LDAP_OPERATIONS_ERROR = 1,
+ LDAP_PROTOCOL_ERROR = 2,
+ LDAP_TIME_LIMIT_EXCEEDED = 3,
+ LDAP_SIZE_LIMIT_EXCEEDED = 4,
+ LDAP_COMPARE_FALSE = 5,
+ LDAP_COMPARE_TRUE = 6,
+ LDAP_AUTH_METHOD_NOT_SUPPORTED = 7,
+ LDAP_STRONG_AUTH_REQUIRED = 8,
+ LDAP_REFERRAL = 10,
+ LDAP_ADMIN_LIMIT_EXCEEDED = 11,
+ LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12,
+ LDAP_CONFIDENTIALITY_REQUIRED = 13,
+ LDAP_SASL_BIND_IN_PROGRESS = 14,
+ LDAP_NO_SUCH_ATTRIBUTE = 16,
+ LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17,
+ LDAP_INAPPROPRIATE_MATCHING = 18,
+ LDAP_CONSTRAINT_VIOLATION = 19,
+ LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20,
+ LDAP_INVALID_ATTRIBUTE_SYNTAX = 21,
+ LDAP_NO_SUCH_OBJECT = 32,
+ LDAP_ALIAS_PROBLEM = 33,
+ LDAP_INVALID_DN_SYNTAX = 34,
+ LDAP_ALIAS_DEREFERENCING_PROBLEM = 36,
+ LDAP_INAPPROPRIATE_AUTHENTICATION = 48,
+ LDAP_INVALID_CREDENTIALS = 49,
+ LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50,
+ LDAP_BUSY = 51,
+ LDAP_UNAVAILABLE = 52,
+ LDAP_UNWILLING_TO_PERFORM = 53,
+ LDAP_LOOP_DETECT = 54,
+ LDAP_NAMING_VIOLATION = 64,
+ LDAP_OBJECT_CLASS_VIOLATION = 65,
+ LDAP_NOT_ALLOWED_ON_NON_LEAF = 66,
+ LDAP_NOT_ALLOWED_ON_RDN = 67,
+ LDAP_ENTRY_ALREADY_EXISTS = 68,
+ LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69,
+ LDAP_AFFECTS_MULTIPLE_DSAS = 71,
+ LDAP_OTHER = 80
+};
+
+#endif /* _SMB_LDAP_ERRORS_H_ */
diff --git a/source4/libcli/security/security_token.c b/source4/libcli/security/security_token.c
index 0680c54258..e1349e06f8 100644
--- a/source4/libcli/security/security_token.c
+++ b/source4/libcli/security/security_token.c
@@ -21,7 +21,6 @@
*/
#include "includes.h"
-#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
#include "auth/session.h"
diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c
index e94ed36d39..8371837dcb 100644
--- a/source4/libcli/util/nterr.c
+++ b/source4/libcli/util/nterr.c
@@ -20,7 +20,7 @@
/* NT error codes. please read nterr.h */
#include "includes.h"
-#include "libcli/ldap/ldap.h"
+#include "libcli/ldap/ldap_errors.h"
#undef strcasecmp
typedef struct
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index b6db2090d2..afd9242188 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -18,7 +18,7 @@ $(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WI
SUBSYSTEM = LIBLDB
INIT_FUNCTION = LDB_MODULE(wins_ldb)
PRIVATE_DEPENDENCIES = \
- LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL
+ LIBLDB LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL
# End MODULE ldb_wins_ldb
#######################
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index 557c0f1dc6..7effb9b842 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -28,6 +28,7 @@
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsdb.h"
#include "lib/ldb/include/ldb.h"
diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c
index df065eb5e2..2bc07c3e7b 100644
--- a/source4/ntvfs/ipc/rap_server.c
+++ b/source4/ntvfs/ipc/rap_server.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "param/share.h"
#include "libcli/rap/rap.h"
+#include "libcli/raw/interfaces.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "rpc_server/common/common.h"
#include "param/param.h"
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index 601c876cfb..6b0f32e65a 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -28,7 +28,6 @@
#include "librpc/gen_ndr/security.h"
#include "../tdb/include/tdb.h"
#include "tdb_wrap.h"
-#include "../lib/util/util_ldb.h"
#include "libcli/security/security.h"
#include "lib/events/events.h"
#include "param/param.h"
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index 342d28325e..b032ab3f93 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -27,7 +27,7 @@
#include "ntvfs/ntvfs.h"
#include "ntvfs/common/ntvfs_common.h"
#include "libcli/wbclient/wbclient.h"
-#include "dsdb/samdb/samdb.h"
+#include "lib/events/events.h"
struct pvfs_wait;
struct pvfs_oplock;
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index f00c975cca..a7d03ca22d 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -3,6 +3,7 @@
################################################
# Start SUBSYSTEM DCERPC_COMMON
[SUBSYSTEM::DCERPC_COMMON]
+PRIVATE_DEPENDENCIES = LIBLDB
#
# End SUBSYSTEM DCERPC_COMMON
################################################
diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c
index c3675c1ba5..1c84392b0c 100644
--- a/source4/smb_server/smb_samba3.c
+++ b/source4/smb_server/smb_samba3.c
@@ -31,7 +31,6 @@
#include "system/network.h"
#include "lib/socket/netif.h"
#include "param/share.h"
-#include "dsdb/samdb/samdb.h"
#include "param/param.h"
#include "dynconfig/dynconfig.h"
#include "smbd/process_model.h"
diff --git a/source4/utils/ad2oLschema.c b/source4/utils/ad2oLschema.c
index 29fda09f3c..236b1fa350 100644
--- a/source4/utils/ad2oLschema.c
+++ b/source4/utils/ad2oLschema.c
@@ -32,7 +32,7 @@
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb.h"
#include "system/locale.h"
#include "lib/ldb/tools/cmdline.h"
#include "param/param.h"
diff --git a/source4/utils/net/net_machinepw.c b/source4/utils/net/net_machinepw.c
index 4e3165dbfd..390eb8df0b 100644
--- a/source4/utils/net/net_machinepw.c
+++ b/source4/utils/net/net_machinepw.c
@@ -19,12 +19,12 @@
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "utils/net/net.h"
#include "libnet/libnet.h"
#include "libcli/security/security.h"
#include "param/secrets.h"
#include "param/param.h"
-#include "lib/events/events.h"
#include "lib/util/util_ldb.h"
int net_machinepw_usage(struct net_context *ctx, int argc, const char **argv)
diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c
index 6c4e6a9c80..701d221046 100644
--- a/source4/utils/oLschema2ldif.c
+++ b/source4/utils/oLschema2ldif.c
@@ -32,7 +32,7 @@
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
#include "dsdb/samdb/samdb.h"