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