ipa_hbac_rules.c revision 4b37ee7d370003514916c793046577ea4b6e736b
6bdda696b3ea703c47e87fea61017ec655f91d92nd Stephen Gallagher <sgallagh@redhat.com>
6bdda696b3ea703c47e87fea61017ec655f91d92nd Copyright (C) 2011 Red Hat
6bdda696b3ea703c47e87fea61017ec655f91d92nd This program is free software; you can redistribute it and/or modify
6bdda696b3ea703c47e87fea61017ec655f91d92nd it under the terms of the GNU General Public License as published by
0662ed52e814f8f08ef0e09956413a792584eddffuankg the Free Software Foundation; either version 3 of the License, or
6bdda696b3ea703c47e87fea61017ec655f91d92nd (at your option) any later version.
6bdda696b3ea703c47e87fea61017ec655f91d92nd This program is distributed in the hope that it will be useful,
6bdda696b3ea703c47e87fea61017ec655f91d92nd but WITHOUT ANY WARRANTY; without even the implied warranty of
6bdda696b3ea703c47e87fea61017ec655f91d92nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6bdda696b3ea703c47e87fea61017ec655f91d92nd GNU General Public License for more details.
6bdda696b3ea703c47e87fea61017ec655f91d92nd You should have received a copy of the GNU General Public License
6bdda696b3ea703c47e87fea61017ec655f91d92nd along with this program. If not, see <http://www.gnu.org/licenses/>.
6bdda696b3ea703c47e87fea61017ec655f91d92nd const char **attrs;
6bdda696b3ea703c47e87fea61017ec655f91d92ndstatic void
6bdda696b3ea703c47e87fea61017ec655f91d92nd const char *host_dn;
6bdda696b3ea703c47e87fea61017ec655f91d92nd const char **memberof_list;
6bdda696b3ea703c47e87fea61017ec655f91d92nd req = tevent_req_create(mem_ctx, &state, struct ipa_hbac_rule_state);
6bdda696b3ea703c47e87fea61017ec655f91d92nd DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create failed.\n");
6bdda696b3ea703c47e87fea61017ec655f91d92nd ret = sysdb_attrs_get_string(ipa_host, SYSDB_ORIG_DN, &host_dn);
6bdda696b3ea703c47e87fea61017ec655f91d92nd DEBUG(SSSDBG_CRIT_FAILURE, "Could not identify IPA hostname\n");
6bdda696b3ea703c47e87fea61017ec655f91d92nd ret = sss_filter_sanitize(state, host_dn, &host_dn_clean);
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg state->attrs = talloc_zero_array(state, const char *, 15);
6bdda696b3ea703c47e87fea61017ec655f91d92nd "(&(objectclass=%s)"
6bdda696b3ea703c47e87fea61017ec655f91d92nd "(%s=%s)(%s=%s)"
6bdda696b3ea703c47e87fea61017ec655f91d92nd "(|(%s=%s)(%s=%s)",
6bdda696b3ea703c47e87fea61017ec655f91d92nd /* Add all parent groups of ipa_hostname to the filter */
6bdda696b3ea703c47e87fea61017ec655f91d92nd ret = sysdb_attrs_get_string_array(ipa_host, SYSDB_ORIG_MEMBEROF,
6bdda696b3ea703c47e87fea61017ec655f91d92nd /* This host is not a member of any hostgroups */
6bdda696b3ea703c47e87fea61017ec655f91d92nd for (i = 0; memberof_list[i]; i++) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd rule_filter = talloc_asprintf_append(rule_filter, "(%s=%s)",
6bdda696b3ea703c47e87fea61017ec655f91d92nd /* ipa_hbac_rule_info_next should always have a search base when
6bdda696b3ea703c47e87fea61017ec655f91d92nd * called for the first time.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * For the subsequent iterations, not finding any more search bases
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg * is fine though (thus the function returns EOK).
6bdda696b3ea703c47e87fea61017ec655f91d92nd * As, here, it's the first case happening, let's return EINVAL.
6bdda696b3ea703c47e87fea61017ec655f91d92nd state->cur_filter = sdap_combine_filters(state, state->rules_filter,
6bdda696b3ea703c47e87fea61017ec655f91d92nd DEBUG(SSSDBG_TRACE_FUNC, "Sending request for next search base: "
6bdda696b3ea703c47e87fea61017ec655f91d92nd subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
6bdda696b3ea703c47e87fea61017ec655f91d92nd DEBUG(SSSDBG_CRIT_FAILURE, "sdap_get_generic_send failed.\n");
6bdda696b3ea703c47e87fea61017ec655f91d92nd tevent_req_set_callback(subreq, ipa_hbac_rule_info_done, req);
&rules);
goto fail;
if (rule_count > 0) {
struct sysdb_attrs *,
goto fail;
goto fail;
fail:
return EOK;