From 071aa999ab63d8589f50d74b9b23d198c233cc20 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 19 Aug 2006 20:53:43 +0000 Subject: r17614: Our first "client side' ldb module. This module has been created with the purpose of being used for searches against ldap servers without the need to handle the control manually You can test it by passing -o modules:paged_searches to ldbsearch The page search size is set to 500 objects. Simo. (This used to be commit 07d377f3c27966b40465bb5dc4f55746ba8489af) --- source4/lib/ldb/modules/paged_searches.c | 438 +++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+) create mode 100644 source4/lib/ldb/modules/paged_searches.c (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c new file mode 100644 index 0000000000..a867aab01c --- /dev/null +++ b/source4/lib/ldb/modules/paged_searches.c @@ -0,0 +1,438 @@ +/* + ldb database library + + Copyright (C) Simo Sorce 2005-2006 + + ** 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: paged_searches + * + * Component: ldb paged searches module + * + * Description: this module detects if the remote ldap server supports + * paged results and use them to transparently access all objects + * + * Author: Simo Sorce + */ + +#include "includes.h" +#include "ldb/include/includes.h" + +#define PS_DEFAULT_PAGE_SIZE 500 +/* 500 objects per query seem to be a decent compromise + * the default AD limit per request is 1000 entries */ + +struct private_data { + + bool paged_supported; +}; + +struct ps_context { + struct ldb_module *module; + void *up_context; + int (*up_callback)(struct ldb_context *, void *, struct ldb_reply *); + + struct ldb_request *orig_req; + + struct ldb_request *new_req; + + bool pending; + + char **saved_referrals; + int num_referrals; +}; + +static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, + void *context, + int (*callback)(struct ldb_context *, void *, struct ldb_reply *)) +{ + struct ps_context *ac; + struct ldb_handle *h; + + h = talloc_zero(mem_ctx, struct ldb_handle); + if (h == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return NULL; + } + + h->module = module; + + ac = talloc_zero(h, struct ps_context); + if (ac == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + talloc_free(h); + return NULL; + } + + h->private_data = (void *)ac; + + h->state = LDB_ASYNC_INIT; + h->status = LDB_SUCCESS; + + ac->module = module; + ac->up_context = context; + ac->up_callback = callback; + + ac->pending = False; + ac->saved_referrals = NULL; + ac->num_referrals = 0; + + return h; +} + +static bool check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) +{ + struct ldb_paged_control *rep_control, *req_control; + + /* look up our paged control */ + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) { + /* something wrong here */ + return False; + } + + rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control); + if (rep_control->cookie_len == 0) { + /* we are done */ + ac->pending = False; + return True; + } + + /* more processing required */ + /* let's fill in the request control with the new cookie */ + /* if there's a reply control we must find a request + * control matching it */ + + if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ac->new_req->controls[0]->oid) != 0) { + /* something wrong here */ + return False; + } + + req_control = talloc_get_type(ac->new_req->controls[0]->data, struct ldb_paged_control); + + if (req_control->cookie) { + talloc_free(req_control->cookie); + } + + req_control->cookie = talloc_memdup(req_control, + rep_control->cookie, + rep_control->cookie_len); + req_control->cookie_len = rep_control->cookie_len; + + ac->pending = True; + return True; +} + +static int store_referral(char *referral, struct ps_context *ac) +{ + ac->saved_referrals = talloc_realloc(ac, ac->saved_referrals, char *, ac->num_referrals + 2); + if (!ac->saved_referrals) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->saved_referrals[ac->num_referrals] = talloc_strdup(ac->saved_referrals, referral); + if (!ac->saved_referrals[ac->num_referrals]) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac->num_referrals++; + ac->saved_referrals[ac->num_referrals] = NULL; + + return LDB_SUCCESS; +} + +static int send_referrals(struct ldb_context *ldb, struct ps_context *ac) +{ + struct ldb_reply *ares; + int i; + + for (i = 0; i < ac->num_referrals; i++) { + ares = talloc_zero(ac, struct ldb_reply); + if (!ares) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ares->type = LDB_REPLY_REFERRAL; + ares->referral = ac->saved_referrals[i]; + + ac->up_callback(ldb, ac->up_context, ares); + } + + return LDB_SUCCESS; +} + +static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) +{ + struct ps_context *ac = NULL; + int ret; + + if (!context || !ares) { + ldb_set_errstring(ldb, "NULL Context or Result in callback"); + goto error; + } + + ac = talloc_get_type(context, struct ps_context); + + switch (ares->type) { + case LDB_REPLY_ENTRY: + ac->up_callback(ldb, ac->up_context, ares); + break; + + case LDB_REPLY_REFERRAL: + ret = store_referral(ares->referral, ac); + if (ret != LDB_SUCCESS) { + goto error; + } + break; + + case LDB_REPLY_DONE: + if (!check_ps_continuation(ares, ac)) { + goto error; + } + if (!ac->pending) { + /* send referrals */ + ret = send_referrals(ldb, ac); + if (ret != LDB_SUCCESS) { + goto error; + } + + /* send REPLY_DONE */ + ac->up_callback(ldb, ac->up_context, ares); + } + break; + default: + goto error; + } + + return LDB_SUCCESS; + +error: + talloc_free(ares); + return LDB_ERR_OPERATIONS_ERROR; +} + +static int ps_search(struct ldb_module *module, struct ldb_request *req) +{ + struct private_data *private_data; + struct ldb_paged_control *control; + struct ps_context *ac; + struct ldb_handle *h; + + private_data = talloc_get_type(module->private_data, struct private_data); + + /* check if paging is supported and if there is a any control */ + if (!private_data->paged_supported || req->controls) { + /* do not touch this request + * oaged controls not supported or + * explicit controls have been set */ + return ldb_next_request(module, req); + } + + if (!req->callback || !req->context) { + ldb_set_errstring(module->ldb, + "Async interface called with NULL callback function or NULL context"); + return LDB_ERR_OPERATIONS_ERROR; + } + + h = init_handle(req, module, req->context, req->callback); + if (!h) { + return LDB_ERR_OPERATIONS_ERROR; + } + ac = talloc_get_type(h->private_data, struct ps_context); + + ac->new_req = talloc(ac, struct ldb_request); + if (!ac->new_req) return LDB_ERR_OPERATIONS_ERROR; + + ac->new_req->controls = talloc_array(ac->new_req, struct ldb_control *, 2); + if (!ac->new_req->controls) return LDB_ERR_OPERATIONS_ERROR; + + ac->new_req->controls[0] = talloc(ac->new_req->controls, struct ldb_control); + if (!ac->new_req->controls[0]) return LDB_ERR_OPERATIONS_ERROR; + + control = talloc(ac->new_req->controls[0], struct ldb_paged_control); + if (!control) return LDB_ERR_OPERATIONS_ERROR; + + control->size = PS_DEFAULT_PAGE_SIZE; + control->cookie = NULL; + control->cookie_len = 0; + + ac->new_req->controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID; + ac->new_req->controls[0]->critical = 1; + ac->new_req->controls[0]->data = control; + + ac->new_req->controls[1] = NULL; + + ac->new_req->operation = req->operation; + ac->new_req->op.search.base = req->op.search.base; + ac->new_req->op.search.scope = req->op.search.scope; + ac->new_req->op.search.tree = req->op.search.tree; + ac->new_req->op.search.attrs = req->op.search.attrs; + ac->new_req->context = ac; + ac->new_req->callback = ps_callback; + ldb_set_timeout_from_prev_req(module->ldb, req, ac->new_req); + + req->handle = h; + + return ldb_next_request(module, ac->new_req); +} + +static int ps_continuation(struct ldb_handle *handle) +{ + struct ps_context *ac; + + if (!handle || !handle->private_data) { + return LDB_ERR_OPERATIONS_ERROR; + } + + ac = talloc_get_type(handle->private_data, struct ps_context); + + /* reset the requests handle */ + ac->new_req->handle = NULL; + + return ldb_next_request(handle->module, ac->new_req); +} + +static int ps_wait_none(struct ldb_handle *handle) +{ + struct ps_context *ac; + int ret; + + if (!handle || !handle->private_data) { + return LDB_ERR_OPERATIONS_ERROR; + } + + if (handle->state == LDB_ASYNC_DONE) { + return handle->status; + } + + handle->state = LDB_ASYNC_PENDING; + handle->status = LDB_SUCCESS; + + ac = talloc_get_type(handle->private_data, struct ps_context); + + ret = ldb_wait(ac->new_req->handle, LDB_WAIT_NONE); + + if (ret != LDB_SUCCESS) { + handle->status = ret; + goto done; + } + + if (ac->new_req->handle->status != LDB_SUCCESS) { + handle->status = ac->new_req->handle->status; + goto done; + } + + if (ac->new_req->handle->state != LDB_ASYNC_DONE) { + return LDB_SUCCESS; + } + + /* see if we need to send another request for the next batch */ + if (ac->pending) { + ret = ps_continuation(handle); + if (ret != LDB_SUCCESS) { + handle->status = ret; + goto done; + } + + /* continue the search with the next request */ + return LDB_SUCCESS; + } + + ret = LDB_SUCCESS; + +done: + handle->state = LDB_ASYNC_DONE; + return ret; +} + +static int ps_wait_all(struct ldb_handle *handle) +{ + int ret; + + while (handle->state != LDB_ASYNC_DONE) { + ret = ps_wait_none(handle); + if (ret != LDB_SUCCESS) { + return ret; + } + } + + return handle->status; +} + +static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type) +{ + if (type == LDB_WAIT_ALL) { + return ps_wait_all(handle); + } else { + return ps_wait_none(handle); + } +} + +static int ps_init(struct ldb_module *module) +{ + static const char *attrs[] = { "supportedControl", NULL }; + struct private_data *data; + struct ldb_result *res = NULL; + int ret; + + data = talloc(module, struct private_data); + if (data == NULL) { + return LDB_ERR_OTHER; + } + module->private_data = data; + data->paged_supported = False; + + /* find the supported controls */ + ret = ldb_search(module->ldb, + ldb_dn_new(module), + LDB_SCOPE_BASE, + "(objectClass=*)", + attrs, + &res); + + if (ret != LDB_SUCCESS || res->count != 1) { + if (res) talloc_free(res); + return ldb_next_init(module); + } + + if (ldb_msg_check_string_attribute(res->msgs[0], + "supportedControl", + LDB_CONTROL_PAGED_RESULTS_OID)) { + + data->paged_supported = True; + } + + talloc_free(res); + + return ldb_next_init(module); +} + +static const struct ldb_module_ops ps_ops = { + .name = "paged_searches", + .search = ps_search, + .wait = ps_wait, + .init_context = ps_init +}; + +int ldb_paged_searches_init(void) +{ + return ldb_register_module(&ps_ops); +} + -- cgit From 3d33bc10ed5dc827a7cabb74d229efea293e1bbf Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Aug 2006 06:18:07 +0000 Subject: r17700: Despite our best hopes, the way module initialisation tends to happen, we make searches before things are initialised. Cope with this. Andrew Bartlett (This used to be commit daa1a61891ede404bcce72affb7094e5c452c689) --- source4/lib/ldb/modules/paged_searches.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index a867aab01c..809a59dce2 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -238,10 +238,10 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req) private_data = talloc_get_type(module->private_data, struct private_data); /* check if paging is supported and if there is a any control */ - if (!private_data->paged_supported || req->controls) { - /* do not touch this request - * oaged controls not supported or - * explicit controls have been set */ + if (!private_data || !private_data->paged_supported || req->controls) { + /* do not touch this request paged controls not + * supported or explicit controls have been set or we + * are just not setup yet */ return ldb_next_request(module, req); } -- cgit From df98ee6558e0bd936f85ce016b2eff18d1faf031 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Sep 2006 04:52:49 +0000 Subject: r18770: Avoid crashes and fix up other issues in the client-side paged_searches module. In particular, we must query the remote server to find out if paged searches are supported, not the local ldb. This patch also removes the ue of bool, and returns it to LDB error codes. Andrew Bartlett (This used to be commit d36d05858bb9b87802f5ffb83285ef12b9646741) --- source4/lib/ldb/modules/paged_searches.c | 84 ++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 27 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 809a59dce2..c7d163307d 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -98,21 +98,21 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, return h; } -static bool check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) +static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) { struct ldb_paged_control *rep_control, *req_control; /* look up our paged control */ - if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) { + if (!ares->controls || strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) { /* something wrong here */ - return False; + return LDB_ERR_OPERATIONS_ERROR; } rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control); if (rep_control->cookie_len == 0) { /* we are done */ ac->pending = False; - return True; + return LDB_SUCCESS; } /* more processing required */ @@ -122,7 +122,7 @@ static bool check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ac->new_req->controls[0]->oid) != 0) { /* something wrong here */ - return False; + return LDB_ERR_OPERATIONS_ERROR; } req_control = talloc_get_type(ac->new_req->controls[0]->data, struct ldb_paged_control); @@ -137,7 +137,7 @@ static bool check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) req_control->cookie_len = rep_control->cookie_len; ac->pending = True; - return True; + return LDB_SUCCESS; } static int store_referral(char *referral, struct ps_context *ac) @@ -181,7 +181,7 @@ static int send_referrals(struct ldb_context *ldb, struct ps_context *ac) static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) { struct ps_context *ac = NULL; - int ret; + int ret = LDB_ERR_OPERATIONS_ERROR; if (!context || !ares) { ldb_set_errstring(ldb, "NULL Context or Result in callback"); @@ -203,7 +203,8 @@ static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply break; case LDB_REPLY_DONE: - if (!check_ps_continuation(ares, ac)) { + ret = check_ps_continuation(ares, ac); + if (ret != LDB_SUCCESS) { goto error; } if (!ac->pending) { @@ -225,7 +226,7 @@ static int ps_callback(struct ldb_context *ldb, void *context, struct ldb_reply error: talloc_free(ares); - return LDB_ERR_OPERATIONS_ERROR; + return ret; } static int ps_search(struct ldb_module *module, struct ldb_request *req) @@ -385,12 +386,29 @@ static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type) } } +static int check_supported_paged(struct ldb_context *ldb, void *context, + struct ldb_reply *ares) +{ + struct private_data *data; + data = talloc_get_type(context, + struct private_data); + if (ares->type == LDB_REPLY_ENTRY) { + if (ldb_msg_check_string_attribute(ares->message, + "supportedControl", + LDB_CONTROL_PAGED_RESULTS_OID)) { + data->paged_supported = True; + } + } + return LDB_SUCCESS; +} + + static int ps_init(struct ldb_module *module) { static const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; - struct ldb_result *res = NULL; int ret; + struct ldb_request *req; data = talloc(module, struct private_data); if (data == NULL) { @@ -398,28 +416,40 @@ static int ps_init(struct ldb_module *module) } module->private_data = data; data->paged_supported = False; - - /* find the supported controls */ - ret = ldb_search(module->ldb, - ldb_dn_new(module), - LDB_SCOPE_BASE, - "(objectClass=*)", - attrs, - &res); - - if (ret != LDB_SUCCESS || res->count != 1) { - if (res) talloc_free(res); - return ldb_next_init(module); + + req = talloc(module, struct ldb_request); + if (req == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); + return LDB_ERR_OPERATIONS_ERROR; } - if (ldb_msg_check_string_attribute(res->msgs[0], - "supportedControl", - LDB_CONTROL_PAGED_RESULTS_OID)) { + req->operation = LDB_SEARCH; + req->op.search.base = ldb_dn_new(req); + req->op.search.scope = LDB_SCOPE_BASE; - data->paged_supported = True; + req->op.search.tree = ldb_parse_tree(req, "objectClass=*"); + if (req->op.search.tree == NULL) { + ldb_set_errstring(module->ldb, "Unable to parse search expression"); + talloc_free(req); + return LDB_ERR_OPERATIONS_ERROR; } - talloc_free(res); + req->op.search.attrs = attrs; + req->controls = NULL; + req->context = data; + req->callback = check_supported_paged; + ldb_set_timeout(module->ldb, req, 0); /* use default timeout */ + + ret = ldb_next_request(module, req); + + if (ret == LDB_SUCCESS) { + ret = ldb_wait(req->handle, LDB_WAIT_ALL); + } + + talloc_free(req); + if (ret != LDB_SUCCESS) { + return ret; + } return ldb_next_init(module); } -- cgit From 4889eb9f7aae9349e426d0f6d2217adff67eaebd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 00:59:34 +0000 Subject: r19831: Big ldb_dn optimization and interfaces enhancement patch This patch changes a lot of the code in ldb_dn.c, and also removes and add a number of manipulation functions around. The aim is to avoid validating a dn if not necessary as the validation code is necessarily slow. This is mainly to speed up internal operations where input is not user generated and so we can assume the DNs need no validation. The code is designed to keep the data as a string if possible. The code is not yet 100% perfect, but pass all the tests so far. A memleak is certainly present, I'll work on that next. Simo. (This used to be commit a580c871d3784602a9cce32d33419e63c8236e63) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index c7d163307d..02d85e4c23 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -424,7 +424,7 @@ static int ps_init(struct ldb_module *module) } req->operation = LDB_SEARCH; - req->op.search.base = ldb_dn_new(req); + req->op.search.base = ldb_dn_new(req, module->ldb, NULL); req->op.search.scope = LDB_SCOPE_BASE; req->op.search.tree = ldb_parse_tree(req, "objectClass=*"); -- cgit From 52fb06edc25e8538c413df1aaabba18c859a00cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 5 May 2007 18:50:56 +0000 Subject: r22681: Fix standalone ldb build when parent directory name != ldb. (This used to be commit 1093875d59f1ea9b8bd82277d4f9d8366e584952) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 02d85e4c23..f4a06e841f 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -34,7 +34,7 @@ */ #include "includes.h" -#include "ldb/include/includes.h" +#include "ldb_includes.h" #define PS_DEFAULT_PAGE_SIZE 500 /* 500 objects per query seem to be a decent compromise -- cgit From 3a78f7323a986703c9b7100f551b1c907a9e104b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 4 Jul 2007 11:06:32 +0000 Subject: r23703: Start to get Samba4 to again work with LDAP backends, after I turned on metze's schema work. Andrew Bartlett (This used to be commit 3111bbdf64f57bf8d2638fd9829c071dcfeb4af1) --- source4/lib/ldb/modules/paged_searches.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index f4a06e841f..2022c39286 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -412,6 +412,7 @@ static int ps_init(struct ldb_module *module) data = talloc(module, struct private_data); if (data == NULL) { + ldb_set_errstring(module->ldb, "Out of Memory"); return LDB_ERR_OTHER; } module->private_data = data; @@ -424,7 +425,7 @@ static int ps_init(struct ldb_module *module) } req->operation = LDB_SEARCH; - req->op.search.base = ldb_dn_new(req, module->ldb, NULL); + req->op.search.base = ldb_dn_new(req, module->ldb, ""); req->op.search.scope = LDB_SCOPE_BASE; req->op.search.tree = ldb_parse_tree(req, "objectClass=*"); -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 2022c39286..34be0e001d 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -10,7 +10,7 @@ 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 2 of the License, or (at your option) any later version. + 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 -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/ldb/modules/paged_searches.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 34be0e001d..3e0941357e 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -18,8 +18,7 @@ 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, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* -- cgit From 719a4ae0d32ab9ba817fd01f2b8f4cba220a8c60 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Oct 2007 18:03:01 +0000 Subject: r25522: Convert to standard bool types. (This used to be commit 5e814287ba475e12f8cc934fdd09b199dcdfdb86) --- source4/lib/ldb/modules/paged_searches.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 3e0941357e..749858b49b 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -90,7 +90,10 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, ac->up_context = context; ac->up_callback = callback; - ac->pending = False; + ac->pending = false; + + + ac->saved_referrals = NULL; ac->num_referrals = 0; @@ -110,7 +113,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control); if (rep_control->cookie_len == 0) { /* we are done */ - ac->pending = False; + ac->pending = false; return LDB_SUCCESS; } @@ -135,7 +138,7 @@ static int check_ps_continuation(struct ldb_reply *ares, struct ps_context *ac) rep_control->cookie_len); req_control->cookie_len = rep_control->cookie_len; - ac->pending = True; + ac->pending = true; return LDB_SUCCESS; } @@ -395,7 +398,7 @@ static int check_supported_paged(struct ldb_context *ldb, void *context, if (ldb_msg_check_string_attribute(ares->message, "supportedControl", LDB_CONTROL_PAGED_RESULTS_OID)) { - data->paged_supported = True; + data->paged_supported = true; } } return LDB_SUCCESS; @@ -415,7 +418,7 @@ static int ps_init(struct ldb_module *module) return LDB_ERR_OTHER; } module->private_data = data; - data->paged_supported = False; + data->paged_supported = false; req = talloc(module, struct ldb_request); if (req == NULL) { -- cgit From 3e75f222bcdf114238cc4f2bcc61332dc059135f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Dec 2007 23:27:42 +0100 Subject: r26539: Remove unnecessary statics. (This used to be commit e53e79eebef3ece6978f0a2b4a1ee0a0814bb5d2) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 749858b49b..69ce219362 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -407,7 +407,7 @@ static int check_supported_paged(struct ldb_context *ldb, void *context, static int ps_init(struct ldb_module *module) { - static const char *attrs[] = { "supportedControl", NULL }; + const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; int ret; struct ldb_request *req; -- cgit From 0500b87092540d300b4e021a0fb95ce16a44fbd2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Dec 2007 00:02:15 +0100 Subject: r26540: Revert my previous commit after concerns raised by Andrew. (This used to be commit 6ac86f8be7d9a8c5ab396a93e6d1e6819e11f173) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 69ce219362..749858b49b 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -407,7 +407,7 @@ static int check_supported_paged(struct ldb_context *ldb, void *context, static int ps_init(struct ldb_module *module) { - const char *attrs[] = { "supportedControl", NULL }; + static const char *attrs[] = { "supportedControl", NULL }; struct private_data *data; int ret; struct ldb_request *req; -- cgit From 5a1433cae7bafe01371663aed8520ce29175cac7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 24 Dec 2007 01:38:37 -0600 Subject: r26581: Make ldb_wait uniform, so that it is easy to remove it completely from modules later on. (This used to be commit f75ce8c20aa2b466e9ee86fdf1702b2ffda10ddf) --- source4/lib/ldb/modules/paged_searches.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 749858b49b..fd580a3c4a 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -312,7 +312,7 @@ static int ps_continuation(struct ldb_handle *handle) return ldb_next_request(handle->module, ac->new_req); } -static int ps_wait_none(struct ldb_handle *handle) +static int ps_wait_once(struct ldb_handle *handle) { struct ps_context *ac; int ret; @@ -365,27 +365,25 @@ done: return ret; } -static int ps_wait_all(struct ldb_handle *handle) +static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type) { int ret; - while (handle->state != LDB_ASYNC_DONE) { - ret = ps_wait_none(handle); - if (ret != LDB_SUCCESS) { - return ret; - } + if (!handle || !handle->private_data) { + return LDB_ERR_OPERATIONS_ERROR; } - return handle->status; -} - -static int ps_wait(struct ldb_handle *handle, enum ldb_wait_type type) -{ if (type == LDB_WAIT_ALL) { - return ps_wait_all(handle); - } else { - return ps_wait_none(handle); + while (handle->state != LDB_ASYNC_DONE) { + ret = ps_wait_once(handle); + if (ret != LDB_SUCCESS) { + return ret; + } + } + + return handle->status; } + return ps_wait_once(handle); } static int check_supported_paged(struct ldb_context *ldb, void *context, -- cgit From 16109a40c0abd8c30a5eb9bf9ef692bfae9dfc7d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 01:54:32 +0100 Subject: Use struct-based rather than function-based initialization for ldb modules everywhere. (This used to be commit 85c96a325867f7bcdb412ebc53f8a47dbf7cd89b) --- source4/lib/ldb/modules/paged_searches.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index fd580a3c4a..88ebd13921 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,15 +455,9 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -static const struct ldb_module_ops ps_ops = { +const struct ldb_module_ops ldb_pages_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, .init_context = ps_init }; - -int ldb_paged_searches_init(void) -{ - return ldb_register_module(&ps_ops); -} - -- cgit From 0020793515ade04f3ef5754717490e2eb2ca6bb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 03:40:44 +0100 Subject: Fix static module list generation for ldb. (This used to be commit 92c1c0e9137f0845cac6cc96bf78711b6aaffe21) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 88ebd13921..7406e91c9d 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,7 +455,7 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_pages_searches_module_ops = { +const struct ldb_module_ops ldb_paged_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, -- cgit From 39a817d310964f8e9a63cfb096b3ad24fa03bd5e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Feb 2008 04:33:43 +0100 Subject: Fix use of some modules (needed _PUBLIC_). (This used to be commit ce332130ea77159832da23bab760fa26921719e2) --- source4/lib/ldb/modules/paged_searches.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/modules/paged_searches.c') diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c index 7406e91c9d..40e87f70d6 100644 --- a/source4/lib/ldb/modules/paged_searches.c +++ b/source4/lib/ldb/modules/paged_searches.c @@ -455,7 +455,7 @@ static int ps_init(struct ldb_module *module) return ldb_next_init(module); } -const struct ldb_module_ops ldb_paged_searches_module_ops = { +_PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = { .name = "paged_searches", .search = ps_search, .wait = ps_wait, -- cgit