"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "source4/dsdb/samdb/ldb_modules/paged_results.c" between
samba-4.12.3.tar.gz and samba-4.12.5.tar.gz

About: Samba is the standard Windows interoperability suite of programs for Linux and Unix providing secure, stable and fast file and print services for all clients using the SMB/CIFS protocol. 4.12 series.

paged_results.c  (samba-4.12.3):paged_results.c  (samba-4.12.5)
skipping to change at line 240 skipping to change at line 240
talloc_free(req); talloc_free(req);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
talloc_free(res); talloc_free(res);
return ret; return ret;
} }
*result = res; *result = res;
return ret; return ret;
} }
static int paged_results(struct paged_context *ac) static int paged_results(struct paged_context *ac, struct ldb_reply *ares)
{ {
struct ldb_paged_control *paged; struct ldb_paged_control *paged;
unsigned int i, num_ctrls; unsigned int i, num_ctrls;
int ret; int ret;
if (ac->store == NULL) { if (ac->store == NULL) {
return LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
while (ac->store->last_i < ac->store->num_entries && ac->size > 0) { while (ac->store->last_i < ac->store->num_entries && ac->size > 0) {
struct GUID *guid = &ac->store->results[ac->store->last_i++]; struct GUID *guid = &ac->store->results[ac->store->last_i++];
struct ldb_result *result = NULL; struct ldb_result *result = NULL;
ac->size--; ac->size--;
/* /*
* Note: In the case that an object has been moved to a * Note: In the case that an object has been moved to a
skipping to change at line 276 skipping to change at line 278
ret = paged_search_by_dn_guid(ac->module, ac, &result, guid, ret = paged_search_by_dn_guid(ac->module, ac, &result, guid,
ac->req->op.search.attrs, ac->req->op.search.attrs,
ac->store->expr); ac->store->expr);
if (ret == LDAP_NO_SUCH_OBJECT || if (ret == LDAP_NO_SUCH_OBJECT ||
(ret == LDB_SUCCESS && result->count == 0)) { (ret == LDB_SUCCESS && result->count == 0)) {
/* The thing isn't there TODO, which we quietly /* The thing isn't there TODO, which we quietly
ignore and go on to send an extra one ignore and go on to send an extra one
instead. */ instead. */
continue; continue;
} else if (ret != LDB_SUCCESS) { } else if (ret != LDB_SUCCESS) {
return ret; return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
ret = ldb_module_send_entry(ac->req, result->msgs[0], ret = ldb_module_send_entry(ac->req, result->msgs[0],
NULL); NULL);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
/*
* ldb_module_send_entry will have called
* ldb_module_done if an error occurred.
*/
return ret; return ret;
} }
} }
if (ac->store->first_ref) { if (ac->store->first_ref) {
/* There is no right place to put references in the sorted /* There is no right place to put references in the sorted
results, so we send them as soon as possible. results, so we send them as soon as possible.
*/ */
ret = send_referrals(ac->store, ac->req); ret = send_referrals(ac->store, ac->req);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
/*
* send_referrals will have called ldb_module_done
* if an error occurred.
*/
return ret; return ret;
} }
} }
/* return result done */ /* return result done */
num_ctrls = 1; num_ctrls = 1;
i = 0; i = 0;
if (ac->store->controls != NULL) { if (ac->store->controls != NULL) {
while (ac->store->controls[i]) i++; /* counting */ while (ac->store->controls[i]) i++; /* counting */
num_ctrls += i; num_ctrls += i;
} }
ac->controls = talloc_array(ac, struct ldb_control *, num_ctrls +1); ac->controls = talloc_array(ac, struct ldb_control *, num_ctrls +1);
if (ac->controls == NULL) { if (ac->controls == NULL) {
return LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
ac->controls[num_ctrls] = NULL; ac->controls[num_ctrls] = NULL;
for (i = 0; i < (num_ctrls -1); i++) { for (i = 0; i < (num_ctrls -1); i++) {
ac->controls[i] = talloc_reference(ac->controls, ac->controls[i] = talloc_reference(ac->controls,
ac->store->controls[i]); ac->store->controls[i]);
} }
ac->controls[i] = talloc(ac->controls, struct ldb_control); ac->controls[i] = talloc(ac->controls, struct ldb_control);
if (ac->controls[i] == NULL) { if (ac->controls[i] == NULL) {
return LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
ac->controls[i]->oid = talloc_strdup(ac->controls[i], ac->controls[i]->oid = talloc_strdup(ac->controls[i],
LDB_CONTROL_PAGED_RESULTS_OID); LDB_CONTROL_PAGED_RESULTS_OID);
if (ac->controls[i]->oid == NULL) { if (ac->controls[i]->oid == NULL) {
return LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
ac->controls[i]->critical = 0; ac->controls[i]->critical = 0;
paged = talloc(ac->controls[i], struct ldb_paged_control); paged = talloc(ac->controls[i], struct ldb_paged_control);
if (paged == NULL) { if (paged == NULL) {
return LDB_ERR_OPERATIONS_ERROR; ret = LDB_ERR_OPERATIONS_ERROR;
return ldb_module_done(
ac->req, ac->controls, ares->response, ret);
} }
ac->controls[i]->data = paged; ac->controls[i]->data = paged;
if (ac->size > 0) { if (ac->size > 0) {
paged->size = 0; paged->size = 0;
paged->cookie = NULL; paged->cookie = NULL;
paged->cookie_len = 0; paged->cookie_len = 0;
} else { } else {
paged->size = ac->store->num_entries; paged->size = ac->store->num_entries;
skipping to change at line 419 skipping to change at line 438
struct GUID, struct GUID,
store->result_array_size); store->result_array_size);
if (store->results == NULL) { if (store->results == NULL) {
return ldb_module_done(ac->req, NULL, NULL, return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR); LDB_ERR_OPERATIONS_ERROR);
} }
} }
guid_blob = ldb_dn_get_extended_component(ares->message->dn, guid_blob = ldb_dn_get_extended_component(ares->message->dn,
"GUID"); "GUID");
if (guid_blob == NULL) {
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
status = GUID_from_ndr_blob(guid_blob, &guid); status = GUID_from_ndr_blob(guid_blob, &guid);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
return ldb_module_done(ac->req, NULL, NULL, return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR); LDB_ERR_OPERATIONS_ERROR);
} }
/* Redundant paranoid check */ /* Redundant paranoid check */
if (store->num_entries > store->result_array_size) { if (store->num_entries > store->result_array_size) {
return ldb_module_done(ac->req, NULL, NULL, return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR); LDB_ERR_OPERATIONS_ERROR);
skipping to change at line 455 skipping to change at line 478
struct GUID, struct GUID,
store->num_entries); store->num_entries);
if (store->results == NULL) { if (store->results == NULL) {
return ldb_module_done(ac->req, NULL, NULL, return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR); LDB_ERR_OPERATIONS_ERROR);
} }
} }
store->result_array_size = store->num_entries; store->result_array_size = store->num_entries;
ac->store->controls = talloc_move(ac->store, &ares->controls); ac->store->controls = talloc_move(ac->store, &ares->controls);
ret = paged_results(ac); ret = paged_results(ac, ares);
if (ret != LDB_SUCCESS) {
/* paged_results will have called ldb_module_done
* if an error occurred
*/
return ret;
}
return ldb_module_done(ac->req, ac->controls, return ldb_module_done(ac->req, ac->controls,
ares->response, ret); ares->response, ret);
} }
return LDB_SUCCESS; return LDB_SUCCESS;
} }
static struct ldb_control ** static struct ldb_control **
paged_results_copy_down_controls(TALLOC_CTX *mem_ctx, paged_results_copy_down_controls(TALLOC_CTX *mem_ctx,
struct ldb_control **controls) struct ldb_control **controls)
skipping to change at line 497 skipping to change at line 526
continue; continue;
} }
/* /*
* ASQ changes everything, do not copy it down for the * ASQ changes everything, do not copy it down for the
* per-GUID search * per-GUID search
*/ */
if (strcmp(control->oid, LDB_CONTROL_ASQ_OID) == 0) { if (strcmp(control->oid, LDB_CONTROL_ASQ_OID) == 0) {
continue; continue;
} }
new_controls[j] = talloc_steal(new_controls, control); new_controls[j] = talloc_steal(new_controls, control);
/*
* Sadly the caller is not obliged to make this a
* proper talloc tree, so we do so here.
*/
if (control->data) {
talloc_steal(control, control->data);
}
j++; j++;
} }
new_controls[j] = NULL; new_controls[j] = NULL;
return new_controls; return new_controls;
} }
static const char * const *paged_copy_attrs(TALLOC_CTX *mem_ctx, static const char * const *paged_copy_attrs(TALLOC_CTX *mem_ctx,
const char * const *attrs) { const char * const *attrs) {
int i; int i;
const char **new_attrs; const char **new_attrs;
skipping to change at line 588 skipping to change at line 625
return false; return false;
} }
} }
return true; return true;
} }
static int paged_search(struct ldb_module *module, struct ldb_request *req) static int paged_search(struct ldb_module *module, struct ldb_request *req)
{ {
struct ldb_context *ldb; struct ldb_context *ldb;
struct ldb_control *control; struct ldb_control *control;
struct ldb_control *vlv_control;
struct private_data *private_data; struct private_data *private_data;
struct ldb_paged_control *paged_ctrl; struct ldb_paged_control *paged_ctrl;
struct ldb_request *search_req; struct ldb_request *search_req;
struct paged_context *ac; struct paged_context *ac;
int ret; int ret;
ldb = ldb_module_get_ctx(module); ldb = ldb_module_get_ctx(module);
/* check if there's a paged request control */ /* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID); control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID);
skipping to change at line 611 skipping to change at line 649
} }
paged_ctrl = talloc_get_type(control->data, struct ldb_paged_control); paged_ctrl = talloc_get_type(control->data, struct ldb_paged_control);
if (!paged_ctrl) { if (!paged_ctrl) {
return LDB_ERR_PROTOCOL_ERROR; return LDB_ERR_PROTOCOL_ERROR;
} }
private_data = talloc_get_type(ldb_module_get_private(module), private_data = talloc_get_type(ldb_module_get_private(module),
struct private_data); struct private_data);
vlv_control = ldb_request_get_control(req, LDB_CONTROL_VLV_REQ_OID);
if (vlv_control != NULL) {
/*
* VLV and paged_results are not allowed at the same
* time
*/
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
ac = talloc_zero(req, struct paged_context); ac = talloc_zero(req, struct paged_context);
if (ac == NULL) { if (ac == NULL) {
ldb_set_errstring(ldb, "Out of Memory"); ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
ac->module = module; ac->module = module;
ac->req = req; ac->req = req;
ac->size = paged_ctrl->size; ac->size = paged_ctrl->size;
if (ac->size < 0) { if (ac->size < 0) {
skipping to change at line 757 skipping to change at line 804
DLIST_PROMOTE(private_data->store, current); DLIST_PROMOTE(private_data->store, current);
ac->store = current; ac->store = current;
/* check if it is an abandon */ /* check if it is an abandon */
if (ac->size == 0) { if (ac->size == 0) {
return ldb_module_done(req, NULL, NULL, return ldb_module_done(req, NULL, NULL,
LDB_SUCCESS); LDB_SUCCESS);
} }
ret = paged_results(ac); ret = paged_results(ac, NULL);
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
return ldb_module_done(req, NULL, NULL, ret); return ldb_module_done(req, NULL, NULL, ret);
} }
return ldb_module_done(req, ac->controls, NULL, LDB_SUCCESS); return ldb_module_done(req, ac->controls, NULL, LDB_SUCCESS);
} }
} }
static int paged_request_init(struct ldb_module *module) static int paged_request_init(struct ldb_module *module)
{ {
struct ldb_context *ldb; struct ldb_context *ldb;
 End of changes. 15 change blocks. 
9 lines changed or deleted 56 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)