ipa_hbac_rules.c revision 83bf46f4066e3d5e838a32357c201de9bd6ecdfd
/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2011 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "providers/ipa/ipa_hbac_private.h"
#include "providers/ipa/ipa_hbac_rules.h"
#include "providers/ldap/sdap_async.h"
struct ipa_hbac_rule_state {
struct tevent_context *ev;
struct sdap_handle *sh;
struct sdap_options *opts;
int search_base_iter;
struct sdap_search_base **search_bases;
const char **attrs;
char *rules_filter;
char *cur_filter;
struct sysdb_attrs **rules;
};
static errno_t
struct ipa_hbac_rule_state *state);
static void
struct tevent_req *
bool get_deny_rules,
struct tevent_context *ev,
struct sdap_handle *sh,
struct sdap_options *opts,
struct sdap_search_base **search_bases,
struct sysdb_attrs *ipa_host)
{
size_t i;
struct ipa_hbac_rule_state *state;
const char *host_dn;
char *host_dn_clean;
char *host_group_clean;
char *rule_filter;
const char **memberof_list;
return NULL;
}
goto error;
}
return NULL;
}
state->search_base_iter = 0;
goto immediate;
}
if (get_deny_rules) {
"(&(objectclass=%s)"
"(%s=%s)(|(%s=%s)(%s=%s)",
IPA_HOST_CATEGORY, "all",
} else {
"(&(objectclass=%s)"
"(%s=%s)(%s=%s)"
"(|(%s=%s)(%s=%s)",
IPA_HOST_CATEGORY, "all",
}
if (rule_filter == NULL) {
goto immediate;
}
/* Add all parent groups of ipa_hostname to the filter */
tmp_ctx, &memberof_list);
/* This host is not a member of any hostgroups */
if (memberof_list == NULL) {
goto immediate;
}
memberof_list[0] = NULL;
}
for (i = 0; memberof_list[i]; i++) {
memberof_list[i],
if (rule_filter == NULL) {
goto immediate;
}
}
if (rule_filter == NULL) {
goto immediate;
}
}
goto immediate;
}
return req;
} else {
}
return req;
return NULL;
}
static errno_t
struct ipa_hbac_rule_state *state)
{
struct tevent_req *subreq;
struct sdap_search_base *base;
return EOK;
}
return ENOMEM;
}
state->cur_filter);
NULL, 0,
true);
return ENOMEM;
}
return EAGAIN;
}
static void
{
struct tevent_req *req =
struct ipa_hbac_rule_state *state =
int i;
struct sysdb_attrs **rules;
struct sysdb_attrs **target;
&rules);
goto fail;
}
if (rule_count > 0) {
struct sysdb_attrs *,
goto fail;
}
i = 0;
state->rule_count++;
i++;
}
}
return;
goto fail;
return;
}
/* We went through all search bases and we have some results */
return;
fail:
}
struct sysdb_attrs ***rules)
{
struct ipa_hbac_rule_state *state =
return EOK;
}