7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina Pavel Březina <pbrezina@redhat.com>
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina Copyright (C) 2016 Red Hat
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina This program is free software; you can redistribute it and/or modify
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina it under the terms of the GNU General Public License as published by
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina the Free Software Foundation; either version 3 of the License, or
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina (at your option) any later version.
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina This program is distributed in the hope that it will be useful,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina GNU General Public License for more details.
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina You should have received a copy of the GNU General Public License
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina#include "responder/common/cache_req/cache_req_private.h"
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina struct cache_req_result **results = *_results;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina /* Make space for new results. */
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina results = talloc_realloc(mem_ctx, results, struct cache_req_result *,
39e300314cb43e534179a6950274e1e9c9a48465Lukas Slebodnik results[idx] = talloc_steal(results, new_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result = talloc_zero(mem_ctx, struct cache_req_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result->ldb_result = talloc_steal(result, ldb_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result->count = ldb_result != NULL ? ldb_result->count : 0;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result->msgs = ldb_result != NULL ? ldb_result->msgs : NULL;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result->lookup_name = talloc_strdup(result, lookup_name);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result->well_known_domain = talloc_strdup(result, well_known_domain);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březinacache_req_create_and_add_result(TALLOC_CTX *mem_ctx,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina "Found %u entries in domain %s\n",
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina item = cache_req_create_result(mem_ctx, domain, ldb_result, name, NULL);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ret = cache_req_add_result(mem_ctx, item, _results, _num_results);
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidênciocache_req_create_ldb_result_from_msg_list(TALLOC_CTX *mem_ctx,
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio if (ldb_msgs == NULL || ldb_msgs[0] == NULL) {
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio DEBUG(SSSDBG_CRIT_FAILURE, "No message set!\n");
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio ldb_result = talloc_zero(NULL, struct ldb_result);
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio ldb_result->msgs = talloc_zero_array(ldb_result, struct ldb_message *,
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio for (size_t i = 0; i < ldb_msg_count; i++) {
180e0b282be6aeb047c4b24b46e0b56afba1fdc8Fabiano Fidêncio ldb_result->msgs[i] = talloc_steal(ldb_result->msgs, ldb_msgs[i]);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březinacache_req_create_ldb_result_from_msg(TALLOC_CTX *mem_ctx,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "No message set!\n");
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result = talloc_zero(NULL, struct ldb_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->msgs = talloc_zero_array(ldb_result, struct ldb_message *, 2);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->msgs[0] = talloc_steal(ldb_result->msgs, ldb_msg);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březinacache_req_create_result_from_msg(TALLOC_CTX *mem_ctx,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "No message set!\n");
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result = cache_req_create_ldb_result_from_msg(mem_ctx, ldb_msg);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina result = cache_req_create_result(mem_ctx, domain, ldb_result,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březinacache_req_copy_limited_result(TALLOC_CTX *mem_ctx,
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina out = talloc_zero(mem_ctx, struct cache_req_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result = talloc_zero(out, struct ldb_result);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->extended = result->ldb_result->extended;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->controls = result->ldb_result->controls;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->msgs = &(result->ldb_result->msgs[start]);
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina ldb_result->count = left < limit ? left : limit;
7cd226414c7bcdd32f05416df64ebda3ac869bd7Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create cache request result "