ipa_sudo_async.c revision 60a715a0dd79873d2d2607eab8fdfaf0ffd2e7d3
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2015 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 <talloc.h>
#include <tevent.h>
#include <dhash.h>
#include "providers/ldap/sdap_ops.h"
#include "providers/ldap/sdap_sudo_shared.h"
#include "providers/ipa/ipa_common.h"
#include "providers/ipa/ipa_hosts.h"
#include "providers/ipa/ipa_sudo.h"
#include "db/sysdb_sudo.h"
struct ipa_hostinfo {
struct sysdb_attrs **hosts;
struct sysdb_attrs **hostgroups;
};
static char *
struct sysdb_attrs *attrs,
const char *attr_name)
{
const char *origdn;
char *sanitizeddn;
return NULL;
}
return NULL;
}
}
return filter;
}
/**
* (|(hostCategory=ALL)(memberHost=$DN(fqdn))(memberHost=$DN(hostgroup))...)
*/
static char *
struct ipa_hostinfo *host,
struct sdap_attr_map *map)
{
char *filter;
size_t i;
/* If realloc fails we will free all data through tmp_ctx. */
return NULL;
}
goto fail;
}
/* Append hostCategory=ALL */
goto fail;
}
/* Append client machine */
goto fail;
}
}
/* Append hostgroups */
for (i = 0; i < host->num_hostgroups; i++) {
goto fail;
}
}
/* OR filters */
goto fail;
}
return filter;
fail:
return NULL;
}
static errno_t
struct sysdb_attrs **attrs,
char **current_usn)
{
char *usn;
return ret;
}
*current_usn = usn;
return EOK;
}
return EOK;
}
static errno_t
struct sysdb_attrs **cmdgroups,
char **_filter)
{
const char *origdn;
char *sanitized;
char *filter;
size_t i;
if (num_cmdgroups == 0) {
return ENOENT;
}
return ENOMEM;
}
goto done;
}
for (i = 0; i < num_cmdgroups; i++) {
ret = ERR_INTERNAL;
goto done;
}
goto done;
}
goto done;
}
}
goto done;
}
done:
return ret;
}
static errno_t
struct sss_domain_info *domain,
struct sysdb_attrs **cmdgroups,
struct sysdb_attrs ***_rules,
{
struct sysdb_attrs **rules;
struct ldb_message **msgs;
char *filter;
return ENOMEM;
}
num_cmdgroups, &filter);
goto done;
}
*_num_rules = 0;
goto done;
goto done;
}
goto done;
}
*_num_rules = num_rules;
done:
return ret;
}
static errno_t
struct sss_domain_info *domain,
struct sysdb_attrs **cmdgroups,
struct sdap_attr_map *map_rule,
char **_filter)
{
struct sysdb_attrs **rules;
const char *name;
char *sanitized;
char *filter;
size_t i;
if (num_cmdgroups == 0) {
return EOK;
}
return ENOMEM;
}
goto done;
}
if (num_rules == 0) {
goto done;
}
goto done;
}
for (i = 0; i < num_rules; i++) {
goto done;
}
goto done;
}
goto done;
}
}
goto done;
}
done:
return ret;
}
struct ipa_sudo_fetch_state {
struct tevent_context *ev;
struct sss_domain_info *domain;
struct ipa_sudo_ctx *sudo_ctx;
struct sdap_options *sdap_opts;
struct ipa_hostinfo *host;
struct sdap_handle *sh;
const char *search_filter;
const char *cmdgroups_filter;
struct sdap_attr_map *map_cmdgroup;
struct sdap_attr_map *map_rule;
struct sdap_attr_map *map_cmd;
struct sdap_search_base **sudo_sb;
struct ipa_sudo_conv *conv;
struct sysdb_attrs **rules;
int cmd_threshold;
char *usn;
};
static struct tevent_req *
struct tevent_context *ev,
struct sss_domain_info *domain,
struct ipa_sudo_ctx *sudo_ctx,
struct ipa_hostinfo *host,
struct sdap_attr_map *map_user,
struct sdap_attr_map *map_group,
struct sdap_attr_map *map_host,
struct sdap_attr_map *map_hostgroup,
struct sdap_handle *sh,
const char *cmdgroups_filter,
const char *search_filter)
{
struct ipa_sudo_fetch_state);
return NULL;
}
goto immediately;
}
/* We need to fetch additional cmdgroups that may not be revealed
* during normal search. Such as when using entryUSN filter in smart
* refresh, some command groups may have change but none rule was
* modified but we need to fetch associated rules anyway. */
} else {
}
goto immediately;
}
return req;
} else {
}
return req;
}
static errno_t
{
struct ipa_sudo_fetch_state *state;
struct tevent_req *subreq;
struct sdap_attr_map *map;
char *filter;
return ENOMEM;
}
return ENOMEM;
}
return EAGAIN;
}
static void
{
struct sysdb_attrs **attrs;
char *filter;
goto done;
}
&filter);
goto done;
}
goto done;
}
done:
}
return;
}
static errno_t
{
struct ipa_sudo_fetch_state *state;
struct tevent_req *subreq;
struct sdap_attr_map *map;
char *host_filter;
char *filter;
if (host_filter == NULL) {
return ENOMEM;
}
return ENOMEM;
}
return ENOMEM;
}
return EAGAIN;
}
static void
{
struct sysdb_attrs **attrs;
goto done;
}
goto done;
}
goto done;
}
done:
}
return;
}
static errno_t
{
struct ipa_sudo_fetch_state *state;
struct tevent_req *subreq;
char *filter;
return ipa_sudo_fetch_cmds(req);
}
return ENOMEM;
}
state->map_cmdgroup, true, 0,
return ENOMEM;
}
return EAGAIN;
}
static void
{
struct sysdb_attrs **attrs;
goto done;
}
goto done;
}
goto done;
}
done:
}
return;
}
static errno_t
{
struct ipa_sudo_fetch_state *state;
struct tevent_req *subreq;
char *filter;
return EOK;
}
return ENOMEM;
}
return ENOMEM;
}
return EAGAIN;
}
static void
{
struct sysdb_attrs **attrs;
goto done;
}
goto done;
}
done:
}
return;
}
static void
{
goto done;
}
done:
return;
}
}
static errno_t
struct tevent_req *req,
struct sysdb_attrs ***_rules,
char **_usn)
{
return EOK;
}
struct ipa_sudo_refresh_state {
struct tevent_context *ev;
struct sss_domain_info *domain;
struct ipa_sudo_ctx *sudo_ctx;
struct ipa_options *ipa_opts;
struct sdap_options *sdap_opts;
const char *cmdgroups_filter;
const char *search_filter;
const char *delete_filter;
struct sdap_id_op *sdap_op;
struct sdap_handle *sh;
int dp_error;
struct sysdb_attrs **rules;
};
struct tevent_req *
struct tevent_context *ev,
struct ipa_sudo_ctx *sudo_ctx,
const char *cmdgroups_filter,
const char *search_filter,
const char *delete_filter)
{
struct ipa_sudo_refresh_state *state;
struct tevent_req *req;
return NULL;
}
goto immediately;
}
goto immediately;
}
goto immediately;
}
goto immediately;
}
/* asynchronous processing */
return req;
}
} else {
}
return req;
}
static errno_t
{
struct ipa_sudo_refresh_state *state;
struct tevent_req *subreq;
int ret;
return ret;
}
return EAGAIN;
}
static void
{
struct ipa_sudo_refresh_state *state;
const char *hostname;
struct tevent_req *req;
int dp_error;
int ret;
return;
}
/* Obtain host information. */
return;
}
}
static void
{
struct ipa_sudo_refresh_state *state;
struct ipa_hostinfo *host;
struct tevent_req *req;
int ret;
return;
}
return;
}
return;
}
}
static void
{
struct ipa_sudo_refresh_state *state;
struct tevent_req *req;
bool in_transaction = false;
int ret;
/* retry */
}
return;
return;
}
goto done;
}
in_transaction = true;
goto done;
}
goto done;
}
goto done;
}
in_transaction = false;
}
done:
if (in_transaction) {
}
}
return;
}
}
int *dp_error,
{
if (_num_rules != NULL) {
}
return EOK;
}