a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina Pavel Březina <pbrezina@redhat.com>
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina Copyright (C) 2015 Red Hat
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina This program is free software; you can redistribute it and/or modify
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina it under the terms of the GNU General Public License as published by
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina the Free Software Foundation; either version 3 of the License, or
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina (at your option) any later version.
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina This program is distributed in the hope that it will be useful,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina GNU General Public License for more details.
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina You should have received a copy of the GNU General Public License
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sysdb_attrs_get_string(attrs, SYSDB_ORIG_DN, &origdn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get original DN "
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sss_filter_sanitize(NULL, origdn, &sanitizeddn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to sanitize DN "
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = talloc_asprintf_append(filter, "(%s=%s)", attr_name, sanitizeddn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_asprintf_append() failed\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina * (|(hostCategory=ALL)(memberHost=$DN(fqdn))(memberHost=$DN(hostgroup))...)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* If realloc fails we will free all data through tmp_ctx. */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = talloc_asprintf(tmp_ctx, "(!(%s=*))",
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* Append hostCategory=ALL */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = talloc_asprintf_append(filter, "(%s=ALL)",
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* Append client machine */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = ipa_sudo_filter_append_origdn(filter, host->hosts[i],
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* Append hostgroups */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = ipa_sudo_filter_append_origdn(filter, host->hostgroups[i],
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* OR filters */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina filter = talloc_asprintf(tmp_ctx, "(|%s)", filter);
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina ret = sysdb_get_highest_usn(mem_ctx, attrs, num_attrs, &usn);
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina DEBUG(SSSDBG_MINOR_FAILURE, "Unable to get highest USN [%d]: %s\n",
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina if (sysdb_compare_usn(usn, *current_usn) > 0) {
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinaipa_sudo_assoc_rules_filter(TALLOC_CTX *mem_ctx,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina for (i = 0; i < num_cmdgroups; i++) {
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sysdb_attrs_get_string(cmdgroups[i], SYSDB_ORIG_DN, &origdn);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get original dn [%d]: %s\n",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sss_filter_sanitize(tmp_ctx, origdn, &sanitized);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina filter = talloc_asprintf_append(filter, "(%s=%s)",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina filter = talloc_asprintf(tmp_ctx, "(&(objectClass=%s)(|%s)))",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = ipa_sudo_assoc_rules_filter(tmp_ctx, cmdgroups,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sysdb_search_custom(tmp_ctx, domain, filter,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Error looking up sudo rules [%d]: %s\n",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sysdb_msg2attrs(tmp_ctx, num_rules, msgs, &rules);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Could not convert ldb message to "
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina "sysdb_attrs [%d]: %s\n", ret, sss_strerror(ret));
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinaipa_sudo_filter_rules_bycmdgroups(TALLOC_CTX *mem_ctx,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = ipa_sudo_assoc_rules(tmp_ctx, domain, cmdgroups, num_cmdgroups,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina for (i = 0; i < num_rules; i++) {
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sysdb_attrs_get_string(rules[i], SYSDB_NAME, &name);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get name [%d]: %s\n",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sss_filter_sanitize(tmp_ctx, name, &sanitized);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina filter = talloc_asprintf_append(filter, "(%s=%s)",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina map_rule[IPA_AT_SUDORULE_NAME].name, sanitized);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina filter = talloc_asprintf(tmp_ctx, "(|%s)", filter);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinastatic errno_t ipa_sudo_fetch_addtl_cmdgroups(struct tevent_req *req);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinastatic void ipa_sudo_fetch_addtl_cmdgroups_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic errno_t ipa_sudo_fetch_rules(struct tevent_req *req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_fetch_rules_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic errno_t ipa_sudo_fetch_cmdgroups(struct tevent_req *req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_fetch_cmdgroups_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic errno_t ipa_sudo_fetch_cmds(struct tevent_req *req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_fetch_cmds_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_fetch_done(struct tevent_req *req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic struct tevent_req *
c02b8482375837b57cb618ed56d4bede0e006d9dPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
9630a4614ba4d5f68e967d4e108893550a996f30Pavel Březina state->search_filter = search_filter == NULL ? "" : search_filter;
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state->map_cmdgroup = sudo_ctx->sudocmdgroup_map;
bc854800cc67271205d63136daaf68d7863cea6bJustin Stephenson state->cmd_threshold = sudo_ctx->sudocmd_threshold;
64497d479e92ebc34717c20c3d017f1823f9e630Jakub Hrozek state->conv = ipa_sudo_conv_init(state, domain, state->map_rule,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina /* We need to fetch additional cmdgroups that may not be revealed
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina * during normal search. Such as when using entryUSN filter in smart
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina * refresh, some command groups may have change but none rule was
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina * modified but we need to fetch associated rules anyway. */
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinaipa_sudo_fetch_addtl_cmdgroups(struct tevent_req *req)
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to fetch additional command groups\n");
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina filter = talloc_asprintf(state, "(&(objectClass=%s)%s)",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build filter\n");
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_fetch_addtl_cmdgroups_done, req);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březinaipa_sudo_fetch_addtl_cmdgroups_done(struct tevent_req *subreq)
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = sdap_search_bases_recv(subreq, state, &num_attrs, &attrs);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_IMPORTANT_INFO, "Received %zu additional command groups\n",
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina ret = ipa_sudo_filter_rules_bycmdgroups(state, state->domain, attrs,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to construct rules filter "
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina state->search_filter = sdap_or_filters(state, state->search_filter, filter);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to fetch sudo rules\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina host_filter = ipa_sudo_host_filter(state, state->host, map);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build host filter\n");
9630a4614ba4d5f68e967d4e108893550a996f30Pavel Březina filter = talloc_asprintf(state, "(&(objectClass=%s)(%s=TRUE)%s%s)",
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build filter\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_fetch_rules_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_fetch_rules_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sdap_search_bases_recv(subreq, state, &num_attrs, &attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_IMPORTANT_INFO, "Received %zu sudo rules\n", num_attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = ipa_sudo_conv_rules(state->conv, attrs, num_attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed when converting rules "
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina ret = ipa_sudo_highest_usn(state, attrs, num_attrs, &state->usn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_fetch_cmdgroups(struct tevent_req *req)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to fetch sudo command groups\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina if (ipa_sudo_conv_has_cmdgroups(state->conv)) {
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No command groups needs to be downloaded\n");
bc854800cc67271205d63136daaf68d7863cea6bJustin Stephenson filter = ipa_sudo_conv_cmdgroup_filter(state, state->conv,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build filter\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_fetch_cmdgroups_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_fetch_cmdgroups_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sdap_search_bases_recv(subreq, state, &num_attrs, &attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_IMPORTANT_INFO, "Received %zu sudo command groups\n",
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = ipa_sudo_conv_cmdgroups(state->conv, attrs, num_attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed when converting command groups "
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina ret = ipa_sudo_highest_usn(state, attrs, num_attrs, &state->usn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to fetch sudo commands\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No commands needs to be downloaded\n");
bc854800cc67271205d63136daaf68d7863cea6bJustin Stephenson filter = ipa_sudo_conv_cmd_filter(state, state->conv, state->cmd_threshold);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build filter\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_fetch_cmds_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_fetch_cmds_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sdap_search_bases_recv(subreq, state, &num_attrs, &attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_IMPORTANT_INFO, "Received %zu sudo commands\n", num_attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = ipa_sudo_conv_cmds(state->conv, attrs, num_attrs);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed when converting commands "
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to convert rules\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = ipa_sudo_conv_result(state, state->conv,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to convert rules [%d]: %s\n",
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_fetch_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina *_rules = talloc_steal(mem_ctx, state->rules);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic errno_t ipa_sudo_refresh_retry(struct tevent_req *req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_refresh_connect_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_refresh_host_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinastatic void ipa_sudo_refresh_done(struct tevent_req *subreq);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_create(mem_ctx, &state, struct ipa_sudo_refresh_state);
c02b8482375837b57cb618ed56d4bede0e006d9dPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state->sysdb = sudo_ctx->id_ctx->be->domain->sysdb;
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create() failed\n");
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina state->cmdgroups_filter = talloc_strdup(state, cmdgroups_filter);
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina if (cmdgroups_filter != NULL && state->cmdgroups_filter == NULL) {
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state->search_filter = talloc_strdup(state, search_filter);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina if (search_filter != NULL && state->search_filter == NULL) {
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state->delete_filter = talloc_strdup(state, delete_filter);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina if (delete_filter != NULL && state->delete_filter == NULL) {
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* asynchronous processing */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_refresh_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "sdap_id_op_connect_send() failed: "
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_refresh_connect_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_refresh_connect_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_refresh_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sdap_id_op_connect_recv(subreq, &dp_error);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "SUDO LDAP connection failed "
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state->sh = sdap_id_op_handle(state->sdap_op);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "SUDO LDAP connection successful\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "About to fetch host information\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina /* Obtain host information. */
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina hostname = dp_opt_get_string(state->ipa_opts->basic, IPA_HOSTNAME);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_refresh_host_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_refresh_host_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_refresh_state);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina host = talloc_zero(state, struct ipa_hostinfo);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = ipa_host_info_recv(subreq, host, &host->num_hosts, &host->hosts,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to retrieve host information "
64497d479e92ebc34717c20c3d017f1823f9e630Jakub Hrozek subreq = ipa_sudo_fetch_send(state, state->ev, state->domain,
cc7f9b639144183eb4f8bd86e5bed077da7d4e35Pavel Březina state->cmdgroups_filter, state->search_filter);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina tevent_req_set_callback(subreq, ipa_sudo_refresh_done, req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březinaipa_sudo_refresh_done(struct tevent_req *subreq)
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina state = tevent_req_data(req, struct ipa_sudo_refresh_state);
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina ret = ipa_sudo_fetch_recv(state, subreq, &state->rules,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sdap_id_op_done(state->sdap_op, ret, &state->dp_error);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina if (state->dp_error == DP_ERR_OK && ret != EOK) {
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed to start transaction\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sysdb_sudo_purge(state->domain, state->delete_filter,
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina ret = sysdb_sudo_store(state->domain, state->rules, state->num_rules);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Failed to commit transaction\n");
d06cc0974e59cd6cf1da45cc8c60d6e822b731c2Pavel Březina sdap_sudo_set_usn(state->sudo_ctx->id_ctx->srv_opts, usn);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Sudo rules are successfully stored in cache\n");
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina sret = sysdb_transaction_cancel(state->sysdb);
a641a13889d617aca6bd998025e9087e822ff7f0Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Could not cancel transaction\n");