The branch, master has been updated via 7259661 dsdb: Use ldb_handle_use_global_event_context for rootdse modifies via e7c36a7 schema: Use ldb_schema_set_override_indexlist for faster index selection via 13e09c7 ldb: Version 1.1.30 via e001ac9 ldb: Add Doxygen documentation for ldb_handle_use_global_event_context() via 850732e ldb: Add Doxygen docs for ldb_set_require_private_event_context() via ba3eff9 ldb: Add Doxygen docs for ldb_handle_get_event_context() via d73d926 ldb: Add Doxygen docs for ldb_schema_set_override_indexlist() via bcd891d ldb: Add Doxygen docs for ldb_schema_attribute_set_override_handler via cb03b12 ldb: Add Doxygen comments for ldb_req_*trusted() functions via 02a4915 ldb: Add test for ldb_build_search_req() via 6777770 ldb: Add tests for new ldb handle and event context behaviour via c29201d ldb: Add ldb_handle_use_global_event_context() via e67d356 ldb: Use the private event context in ldb_tdb and ldb_wait() via 25795c3 ldb: Force use of a private event context in ldb_tdb via cd97f45 ldb: Create private event contexts in top level requests, chain to children via 0f13243 ldb: Add ldb_set_require_private_event_context() via a83df55 ldb: Add ldb_handle_get_event_context() via 1ba6b9a ldb: Add ldb_build_req_common() helper function via aa54ed0 ldb: Add tests for the schema and index override hooks via e903e08 ldb: Move test_ldb_attrs_case_insensitive closer to setup/teardown functions via 2335e57 ldb_tdb: Avoid reading the index list from the DB if we are already set to override it via e584fe8 ldb: Allow a caller (in particular Samba) to handle the list of attributes with an index via 29dc932 ldb_tdb: consistently use ltdb->cache->attribute_indexes to determine if we have indexes via e1bc43d ldb_tdb: change the arguments to ldb_is_indexed() to provide the ltdb_private via 05e8dcb ldb_tdb: Split index load out into a sub-funciton: ltdb_index_load from e530e43 s3:smbd: Set up local and remote address for fake connection
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 7259661467776a76c4fa3aabaf1ae8a3d531e506 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 12 01:55:45 2017 +0200 dsdb: Use ldb_handle_use_global_event_context for rootdse modifies The modify operations on the rootDSE turn into IRPC messages, and these need to be handled on the global event context, not the per-operation context Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Wed May 31 10:47:46 CEST 2017 on sn-devel-144 commit e7c36a7142198c9a8efb769627af4488e0bb5dc0 Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:25:35 2017 +1300 schema: Use ldb_schema_set_override_indexlist for faster index selection This allows Samba to provide a binary tree lookup for the existance of an index on the attribute rather than the O(n) lookup that was being done for each attribute during a search or modify Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 13e09c72cd41cd5cd44bd9e4e27df8e0e1d47379 Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:54:58 2017 +1300 ldb: Version 1.1.30 * let ldbdump parse the -i option * don't allow the reveal_internals control for ldbedit * only allow --show-binary for ldbsearch * don't let ldbsearch create non-existing files * fix ldb_tdb search inconsistencies * add cmocka based tests * provide an interface for improved indexing for callers like Samba, which will allow much better performance. * Makes ldb access to tdb:// databases use a private event context rather than the global event context passed in by the caller. This is because running other operations while locks are held or a search is being conducted is not safe. Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit e001ac9ef56205ad8e7fdcfb1bff771f989939f1 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 21:12:33 2017 +1200 ldb: Add Doxygen documentation for ldb_handle_use_global_event_context() Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 850732ebbb73f3affedd4233a782e680253b4990 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 21:17:57 2017 +1200 ldb: Add Doxygen docs for ldb_set_require_private_event_context() Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit ba3eff930f9edd51f6e6cfd7f6f927e4aae6da1b Author: Andrew Bartlett <abart...@samba.org> Date: Thu May 4 11:39:21 2017 +0200 ldb: Add Doxygen docs for ldb_handle_get_event_context() Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit d73d926458fd92f15287fa6bc0246b79d06c94d4 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 21:04:02 2017 +1200 ldb: Add Doxygen docs for ldb_schema_set_override_indexlist() Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit bcd891dc3f77aa54e73a3fe23b6d1feab80a4c86 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 21:00:34 2017 +1200 ldb: Add Doxygen docs for ldb_schema_attribute_set_override_handler Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit cb03b12ac2c283187a63921ea5e45f8fe8ea31a5 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 20:57:23 2017 +1200 ldb: Add Doxygen comments for ldb_req_*trusted() functions Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> commit 02a4915b91277cfb2f9502119b35f2e07bbf625b Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 14:59:16 2017 +1200 ldb: Add test for ldb_build_search_req() Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 6777770d35547053f51becd932bb489c80899ba2 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 14:39:49 2017 +1200 ldb: Add tests for new ldb handle and event context behaviour Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit c29201d6d3fa0594cd561a1dda581aff7569b170 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 5 08:25:40 2017 +0200 ldb: Add ldb_handle_use_global_event_context() This will allow the IRPC to be processed in the main event loop of the server, not the private event context for this request Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit e67d3568e5853387d0675ed13d51df21e6274770 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 12 02:30:01 2017 +0200 ldb: Use the private event context in ldb_tdb and ldb_wait() This enables the previous commits, and ensures that ldb_tdb is safe from operations while locks are held Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 25795c3da920adba845367bf3394b5ba5912c1d5 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 12 02:28:02 2017 +0200 ldb: Force use of a private event context in ldb_tdb ldb_tdb holds locks while making callbacks, so force the use of a per-request event context Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit cd97f4597603c0aa6ad91883a036a206e48df092 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 12 02:26:04 2017 +0200 ldb: Create private event contexts in top level requests, chain to children We must ensure that the ldb_request we call ldb_wait() will share an event context with all the eventual request that the ldb backend creates events on Pair-Programmed-With: Stefan Metzmacher <me...@samba.org> Signed-off-by: Andrew Bartlett <abart...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 0f13243f5edc1332fb5842dbfc05a498ba01d406 Author: Andrew Bartlett <abart...@samba.org> Date: Fri May 12 02:21:28 2017 +0200 ldb: Add ldb_set_require_private_event_context() This will allow us to force use of the global event context for use when Samba must make an IRPC call from within the ldb stack, to another part of the same process Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit a83df55693bf04fb65d776af2591c8c82f211d6c Author: Andrew Bartlett <abart...@samba.org> Date: Thu May 4 11:39:21 2017 +0200 ldb: Add ldb_handle_get_event_context() This will allow us to obtain a private event context for use while we hold locks in ldb_tdb, that is not shared with the global state of the application. This will ensure we do not perform other operations while we hold the lock Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 1ba6b9aae88f369c58f250aa53223d98aad8564c Author: Andrew Bartlett <abart...@samba.org> Date: Thu May 4 22:27:24 2017 +0200 ldb: Add ldb_build_req_common() helper function Pair-Programmed-With: Stefan Metzmacher <me...@samba.org> Signed-off-by: Andrew Bartlett <abart...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit aa54ed036535a30f9b1cfe5d44022264daedfc17 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 13:53:01 2017 +1200 ldb: Add tests for the schema and index override hooks Because this uses ldb_private.h we no longer build the test binary if we are building against a system ldb Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit e903e08027b84ab434941f7e3ffb141d76720a24 Author: Andrew Bartlett <abart...@samba.org> Date: Tue May 30 12:47:58 2017 +1200 ldb: Move test_ldb_attrs_case_insensitive closer to setup/teardown functions Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 2335e57a898bfe0d0c842b8d5e0b4cbb4589c1a3 Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:10:22 2017 +1300 ldb_tdb: Avoid reading the index list from the DB if we are already set to override it Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit e584fe85a51ec8a81274dc65e689cc0e0ddb4a50 Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:23:44 2017 +1300 ldb: Allow a caller (in particular Samba) to handle the list of attributes with an index By doing that, Samba will use a binary search to locate the attributes rather than an O(n) search, during every search or modify of the database. Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 29dc93298a61e3e344fef5606b59e4cae94e8c2f Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:21:34 2017 +1300 ldb_tdb: consistently use ltdb->cache->attribute_indexes to determine if we have indexes This is instead of checking the number of elements via ltdb->cache->indexlist->num_elements In turn, this allows us to avoid fetching ltdb->cache->indexlist in the future Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit e1bc43dca19a9a6078bd10c0c91986287f58fd9a Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:07:16 2017 +1300 ldb_tdb: change the arguments to ldb_is_indexed() to provide the ltdb_private By doing this, we can be more efficient in locating if we have an index in the future. Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 05e8dcb2f9ef540f814712be422bdef50f6d560d Author: Andrew Bartlett <abart...@samba.org> Date: Thu Mar 30 13:10:08 2017 +1300 ldb_tdb: Split index load out into a sub-funciton: ltdb_index_load Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> ----------------------------------------------------------------------- Summary of changes: lib/ldb/ABI/{ldb-1.1.29.sigs => ldb-1.1.30.sigs} | 4 + ...ldb-util-1.1.10.sigs => pyldb-util-1.1.30.sigs} | 0 ...util-1.1.10.sigs => pyldb-util.py3-1.1.30.sigs} | 0 lib/ldb/common/ldb.c | 262 ++++++++-------- lib/ldb/common/ldb_attributes.c | 12 + lib/ldb/common/ldb_modules.c | 20 -- lib/ldb/include/ldb.h | 5 + lib/ldb/include/ldb_module.h | 82 ++++- lib/ldb/include/ldb_private.h | 17 + lib/ldb/ldb_tdb/ldb_cache.c | 83 +++-- lib/ldb/ldb_tdb/ldb_index.c | 73 +++-- lib/ldb/ldb_tdb/ldb_tdb.c | 9 +- lib/ldb/tests/ldb_mod_op_test.c | 349 +++++++++++++++++++-- lib/ldb/wscript | 12 +- source4/dsdb/samdb/ldb_modules/rootdse.c | 6 + source4/dsdb/schema/schema_init.c | 4 + source4/dsdb/schema/schema_set.c | 1 + 17 files changed, 704 insertions(+), 235 deletions(-) copy lib/ldb/ABI/{ldb-1.1.29.sigs => ldb-1.1.30.sigs} (98%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-1.1.30.sigs} (100%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util.py3-1.1.30.sigs} (100%) Changeset truncated at 500 lines: diff --git a/lib/ldb/ABI/ldb-1.1.29.sigs b/lib/ldb/ABI/ldb-1.1.30.sigs similarity index 98% copy from lib/ldb/ABI/ldb-1.1.29.sigs copy to lib/ldb/ABI/ldb-1.1.30.sigs index 0ea968d..ef9c53e 100644 --- a/lib/ldb/ABI/ldb-1.1.29.sigs +++ b/lib/ldb/ABI/ldb-1.1.30.sigs @@ -94,7 +94,9 @@ ldb_get_opaque: void *(struct ldb_context *, const char *) ldb_get_root_basedn: struct ldb_dn *(struct ldb_context *) ldb_get_schema_basedn: struct ldb_dn *(struct ldb_context *) ldb_global_init: int (void) +ldb_handle_get_event_context: struct tevent_context *(struct ldb_handle *) ldb_handle_new: struct ldb_handle *(TALLOC_CTX *, struct ldb_context *) +ldb_handle_use_global_event_context: void (struct ldb_handle *) ldb_handler_copy: int (struct ldb_context *, void *, const struct ldb_val *, struct ldb_val *) ldb_handler_fold: int (struct ldb_context *, void *, const struct ldb_val *, struct ldb_val *) ldb_init: struct ldb_context *(TALLOC_CTX *, struct tevent_context *) @@ -225,6 +227,7 @@ ldb_schema_attribute_fill_with_syntax: int (struct ldb_context *, TALLOC_CTX *, ldb_schema_attribute_remove: void (struct ldb_context *, const char *) ldb_schema_attribute_remove_flagged: void (struct ldb_context *, unsigned int) ldb_schema_attribute_set_override_handler: void (struct ldb_context *, ldb_attribute_handler_override_fn_t, void *) +ldb_schema_set_override_indexlist: void (struct ldb_context *, bool) ldb_search: int (struct ldb_context *, TALLOC_CTX *, struct ldb_result **, struct ldb_dn *, enum ldb_scope, const char * const *, const char *, ...) ldb_search_default_callback: int (struct ldb_request *, struct ldb_reply *) ldb_sequence_number: int (struct ldb_context *, enum ldb_sequence_type, uint64_t *) @@ -237,6 +240,7 @@ ldb_set_event_context: void (struct ldb_context *, struct tevent_context *) ldb_set_flags: void (struct ldb_context *, unsigned int) ldb_set_modules_dir: void (struct ldb_context *, const char *) ldb_set_opaque: int (struct ldb_context *, const char *, void *) +ldb_set_require_private_event_context: void (struct ldb_context *) ldb_set_timeout: int (struct ldb_context *, struct ldb_request *, int) ldb_set_timeout_from_prev_req: int (struct ldb_context *, struct ldb_request *, struct ldb_request *) ldb_set_utf8_default: void (struct ldb_context *) diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-1.1.30.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util-1.1.30.sigs diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util.py3-1.1.30.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util.py3-1.1.30.sigs diff --git a/lib/ldb/common/ldb.c b/lib/ldb/common/ldb.c index 6067256..a3a0002 100644 --- a/lib/ldb/common/ldb.c +++ b/lib/ldb/common/ldb.c @@ -605,7 +605,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type) return handle->status; } - ev = ldb_get_event_context(handle->ldb); + ev = ldb_handle_get_event_context(handle); if (NULL == ev) { return ldb_oom(handle->ldb); } @@ -711,6 +711,62 @@ int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, } +struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb) +{ + struct ldb_handle *h; + + h = talloc_zero(mem_ctx, struct ldb_handle); + if (h == NULL) { + ldb_set_errstring(ldb, "Out of Memory"); + return NULL; + } + + h->status = LDB_SUCCESS; + h->state = LDB_ASYNC_INIT; + h->ldb = ldb; + h->flags = 0; + h->location = NULL; + h->parent = NULL; + + if (h->ldb->require_private_event_context == true) { + h->event_context = tevent_context_init(h); + if (h->event_context == NULL) { + ldb_set_errstring(ldb, + "Out of Memory allocating " + "event context for new handle"); + return NULL; + } + tevent_set_debug(h->event_context, ldb_tevent_debug, ldb); + tevent_loop_allow_nesting(h->event_context); + } + + return h; +} + +static struct ldb_handle *ldb_handle_new_child(TALLOC_CTX *mem_ctx, + struct ldb_request *parent_req) +{ + struct ldb_handle *h; + + h = talloc_zero(mem_ctx, struct ldb_handle); + if (h == NULL) { + ldb_set_errstring(parent_req->handle->ldb, + "Out of Memory"); + return NULL; + } + + h->status = LDB_SUCCESS; + h->state = LDB_ASYNC_INIT; + h->ldb = parent_req->handle->ldb; + h->parent = parent_req; + h->nesting = parent_req->handle->nesting + 1; + h->flags = parent_req->handle->flags; + h->custom_flags = parent_req->handle->custom_flags; + h->event_context = parent_req->handle->event_context; + + return h; +} + /* set the permissions for new files to be passed to open() in backends that use local files @@ -745,6 +801,38 @@ int ldb_request_get_status(struct ldb_request *req) return req->handle->status; } +/* + * This function obtains the private event context for the handle, + * which may have been created to avoid nested event loops during + * ldb_tdb with the locks held + */ +struct tevent_context *ldb_handle_get_event_context(struct ldb_handle *handle) +{ + if (handle->event_context != NULL) { + return handle->event_context; + } + return ldb_get_event_context(handle->ldb); +} + +/* + * This function forces a specific ldb handle to use the global event + * context. This allows a nested event loop to operate, so any open + * transaction also needs to be aborted. + * + * Any events on this event context will be lost + * + * This is used in Samba when sending an IRPC to another part of the + * same process instead of making a local DB modification. + */ +void ldb_handle_use_global_event_context(struct ldb_handle *handle) +{ + TALLOC_FREE(handle->event_context); +} + +void ldb_set_require_private_event_context(struct ldb_context *ldb) +{ + ldb->require_private_event_context = true; +} /* trace a ldb request @@ -1146,6 +1234,42 @@ int ldb_op_default_callback(struct ldb_request *req, struct ldb_reply *ares) return ldb_request_done(req, LDB_SUCCESS); } +static struct ldb_request *ldb_build_req_common(TALLOC_CTX *mem_ctx, + struct ldb_context *ldb, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback, + struct ldb_request *parent) +{ + struct ldb_request *req = NULL; + + req = talloc_zero(mem_ctx, struct ldb_request); + if (req == NULL) { + return NULL; + } + req->controls = controls; + req->context = context; + req->callback = callback; + + ldb_set_timeout_from_prev_req(ldb, parent, req); + + if (parent != NULL) { + req->handle = ldb_handle_new_child(req, parent); + if (req->handle == NULL) { + TALLOC_FREE(req); + return NULL; + } + } else { + req->handle = ldb_handle_new(req, ldb); + if (req->handle == NULL) { + TALLOC_FREE(req); + return NULL; + } + } + + return req; +} + int ldb_build_search_req_ex(struct ldb_request **ret_req, struct ldb_context *ldb, TALLOC_CTX *mem_ctx, @@ -1162,7 +1286,8 @@ int ldb_build_search_req_ex(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR; @@ -1184,25 +1309,6 @@ int ldb_build_search_req_ex(struct ldb_request **ret_req, } req->op.search.attrs = attrs; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } - *ret_req = req; return LDB_SUCCESS; } @@ -1250,7 +1356,8 @@ int ldb_build_add_req(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; @@ -1258,27 +1365,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, req->operation = LDB_ADD; req->op.add.message = message; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } - *ret_req = req; - return LDB_SUCCESS; } @@ -1295,7 +1382,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; @@ -1303,27 +1391,8 @@ int ldb_build_mod_req(struct ldb_request **ret_req, req->operation = LDB_MODIFY; req->op.mod.message = message; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } *ret_req = req; - return LDB_SUCCESS; } @@ -1340,7 +1409,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; @@ -1348,27 +1418,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, req->operation = LDB_DELETE; req->op.del.dn = dn; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } - *ret_req = req; - return LDB_SUCCESS; } @@ -1386,7 +1436,8 @@ int ldb_build_rename_req(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; @@ -1395,27 +1446,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req, req->operation = LDB_RENAME; req->op.rename.olddn = olddn; req->op.rename.newdn = newdn; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } - *ret_req = req; - return LDB_SUCCESS; } @@ -1462,7 +1493,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req, *ret_req = NULL; - req = talloc(mem_ctx, struct ldb_request); + req = ldb_build_req_common(mem_ctx, ldb, controls, + context, callback, parent); if (req == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; @@ -1471,27 +1503,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req, req->operation = LDB_EXTENDED; req->op.extended.oid = oid; req->op.extended.data = data; - req->controls = controls; - req->context = context; - req->callback = callback; - - ldb_set_timeout_from_prev_req(ldb, parent, req); - - req->handle = ldb_handle_new(req, ldb); - if (req->handle == NULL) { - ldb_oom(ldb); - return LDB_ERR_OPERATIONS_ERROR; - } - - if (parent) { - req->handle->nesting++; - req->handle->parent = parent; - req->handle->flags = parent->handle->flags; - req->handle->custom_flags = parent->handle->custom_flags; - } - *ret_req = req; - return LDB_SUCCESS; } diff --git a/lib/ldb/common/ldb_attributes.c b/lib/ldb/common/ldb_attributes.c index 2021a0b..98ec5a4 100644 --- a/lib/ldb/common/ldb_attributes.c +++ b/lib/ldb/common/ldb_attributes.c @@ -383,3 +383,15 @@ void ldb_schema_attribute_set_override_handler(struct ldb_context *ldb, ldb->schema.attribute_handler_override_private = private_data; ldb->schema.attribute_handler_override = override; } + +/* + set that the attribute handler override function - used to delegate + schema handling to external code, is handling setting + LDB_ATTR_FLAG_INDEXED + */ +void ldb_schema_set_override_indexlist(struct ldb_context *ldb, + bool one_level_indexes) +{ + ldb->schema.index_handler_override = true; + ldb->schema.one_level_indexes = one_level_indexes; +} diff --git a/lib/ldb/common/ldb_modules.c b/lib/ldb/common/ldb_modules.c index 62f20af..ca93299 100644 --- a/lib/ldb/common/ldb_modules.c +++ b/lib/ldb/common/ldb_modules.c @@ -684,26 +684,6 @@ int ldb_next_del_trans(struct ldb_module *module) return ret; } -struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb) -{ - struct ldb_handle *h; - - h = talloc_zero(mem_ctx, struct ldb_handle); - if (h == NULL) { - ldb_set_errstring(ldb, "Out of Memory"); - return NULL; - } - - h->status = LDB_SUCCESS; - h->state = LDB_ASYNC_INIT; - h->ldb = ldb; - h->flags = 0; - h->location = NULL; - h->parent = NULL; - - return h; -} - /* calls the request callback to send an entry * * params: diff --git a/lib/ldb/include/ldb.h b/lib/ldb/include/ldb.h index 1160a48..3fab929 100644 --- a/lib/ldb/include/ldb.h +++ b/lib/ldb/include/ldb.h @@ -441,6 +441,11 @@ const struct ldb_dn_extended_syntax *ldb_dn_extended_syntax_by_name(struct ldb_c */ #define LDB_ATTR_FLAG_FROM_DB (1<<6) +/* + * The attribute was loaded from a DB, rather than via the C API + */ +#define LDB_ATTR_FLAG_INDEXED (1<<7) + /** LDAP attribute syntax for a DN diff --git a/lib/ldb/include/ldb_module.h b/lib/ldb/include/ldb_module.h index 833d5a8..3d56e68 100644 --- a/lib/ldb/include/ldb_module.h +++ b/lib/ldb/include/ldb_module.h @@ -122,10 +122,30 @@ void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name); /* we allow external code to override the name -> schema_attribute function */ typedef const struct ldb_schema_attribute *(*ldb_attribute_handler_override_fn_t)(struct ldb_context *, void *, const char *); -- Samba Shared Repository