sdap_async_sudo.c revision cad751beaa12e34e15565bc413442b1e80ac0c29
e1e8390280254f7f0580d701e583f670643d4f3fnilgun Async LDAP Helper routines for sudo
e1e8390280254f7f0580d701e583f670643d4f3fnilgun Pavel Březina <pbrezina@redhat.com>
e1e8390280254f7f0580d701e583f670643d4f3fnilgun Copyright (C) 2012 Red Hat
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen This program is free software; you can redistribute it and/or modify
2e545ce2450a9953665f701bb05350f0d3f26275nd it under the terms of the GNU General Public License as published by
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen the Free Software Foundation; either version 3 of the License, or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen (at your option) any later version.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun This program is distributed in the hope that it will be useful,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun but WITHOUT ANY WARRANTY; without even the implied warranty of
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3f08db06526d6901aa08c110b5bc7dde6bc39905nd GNU General Public License for more details.
e1e8390280254f7f0580d701e583f670643d4f3fnilgun You should have received a copy of the GNU General Public License
e1e8390280254f7f0580d701e583f670643d4f3fnilgun along with this program. If not, see <http://www.gnu.org/licenses/>.
e1e8390280254f7f0580d701e583f670643d4f3fnilgunstatic void sdap_sudo_load_sudoers_done(struct tevent_req *subreq);
e1e8390280254f7f0580d701e583f670643d4f3fnilgunstatic struct tevent_req *
e1e8390280254f7f0580d701e583f670643d4f3fnilgun "SUDOERS lookup request without a search base\n");
e1e8390280254f7f0580d701e583f670643d4f3fnilgun DEBUG(SSSDBG_TRACE_FUNC, "About to fetch sudo rules\n");
e1e8390280254f7f0580d701e583f670643d4f3fnilgun subreq = sdap_search_bases_send(state, ev, opts, sh, sb,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun tevent_req_set_callback(subreq, sdap_sudo_load_sudoers_done, req);
e1e8390280254f7f0580d701e583f670643d4f3fnilgunstatic void sdap_sudo_load_sudoers_done(struct tevent_req *subreq)
e1e8390280254f7f0580d701e583f670643d4f3fnilgun req = tevent_req_callback_data(subreq, struct tevent_req);
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun state = tevent_req_data(req, struct sdap_sudo_load_sudoers_state);
e1e8390280254f7f0580d701e583f670643d4f3fnilgun ret = sdap_search_bases_recv(subreq, state, &state->num_rules,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun DEBUG(SSSDBG_IMPORTANT_INFO, "Received %zu sudo rules\n",
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgunstatic int sdap_sudo_load_sudoers_recv(struct tevent_req *req,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun state = tevent_req_data(req, struct sdap_sudo_load_sudoers_state);
e1e8390280254f7f0580d701e583f670643d4f3fnilgunstatic char *sdap_sudo_build_host_filter(TALLOC_CTX *mem_ctx,
e1e8390280254f7f0580d701e583f670643d4f3fnilgun /* sudoHost is not specified */
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun filter = talloc_asprintf_append_buffer(filter, "(!(%s=*))",
e0cfea1f5d38eeaa8fdf7c197c3c1eb31148e191nilgun filter = talloc_asprintf_append_buffer(filter, "(%s=ALL)",
e1e8390280254f7f0580d701e583f670643d4f3fnilgun /* hostnames */
0d0ba3a410038e179b695446bb149cce6264e0abnd filter = talloc_asprintf_append_buffer(filter, "(%s=%s)",
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh /* ip addresses and networks */
0d0ba3a410038e179b695446bb149cce6264e0abnd filter = talloc_asprintf_append_buffer(filter, "(%s=%s)",
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd /* sudoHost contains netgroup - will be filtered more by sudo */
e1e8390280254f7f0580d701e583f670643d4f3fnilgun filter = talloc_asprintf_append_buffer(filter, SDAP_SUDO_FILTER_NETGROUP,
goto done;
/* from sudo match.c :
if (regexp) {
goto done;
goto done;
done:
return filter;
const char *rule_filter)
return NULL;
goto done;
goto done;
done:
return filter;
struct sdap_sudo_refresh_state {
const char *search_filter;
const char *delete_filter;
int dp_error;
const char *search_filter,
const char *delete_filter)
int ret;
if (!req) {
return NULL;
goto immediately;
goto immediately;
goto immediately;
goto immediately;
return req;
return req;
int ret;
return ret;
return EAGAIN;
int dp_error;
int ret;
char *filter;
return ENOMEM;
filter);
return ENOMEM;
return EAGAIN;
int dp_error;
int ret;
bool in_transaction = false;
goto done;
in_transaction = true;
goto done;
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
int *dp_error,
return EOK;