sdap_async_sudo.c revision 21d485184df986e1a123f70c689517386e51a5ce
/*
SSSD
Async LDAP Helper routines for sudo
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2012 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 <errno.h>
#include <talloc.h>
#include <tevent.h>
#include "providers/dp_backend.h"
#include "providers/ldap/ldap_common.h"
#include "providers/ldap/sdap_async.h"
#include "providers/ldap/sdap_sudo.h"
#include "providers/ldap/sdap_sudo_cache.h"
#include "db/sysdb_sudo.h"
struct sdap_sudo_refresh_state {
struct sdap_options *opts;
struct sdap_id_op *sdap_op;
struct sdap_id_conn_cache *sdap_conn_cache;
struct sss_domain_info *domain;
const char *ldap_filter; /* search */
const char *sysdb_filter; /* delete */
int dp_error;
int error;
char *highest_usn;
};
struct sdap_sudo_load_sudoers_state {
struct tevent_context *ev;
struct sdap_options *opts;
struct sdap_handle *sh;
const char **attrs;
const char *filter;
struct sdap_search_base **search_bases;
int timeout;
};
struct tevent_context *ev,
struct sdap_options *opts,
struct sdap_handle *sh,
const char *ldap_filter);
struct sysdb_attrs ***rules);
const char *filter,
struct sdap_attr_map *map,
struct sysdb_attrs **rules);
struct sdap_options *opts,
struct sysdb_attrs **rules,
int cache_timeout,
char **_usn);
struct sdap_options *opts,
struct sdap_id_conn_cache *conn_cache,
const char *ldap_filter,
const char *sysdb_filter)
{
int ret;
if (!req) {
return NULL;
}
/* if we don't have a search filter, this request is meaningless */
if (ldap_filter == NULL) {
goto immediately;
}
goto immediately;
}
goto immediately;
}
/* asynchronous processing */
return req;
}
} else {
}
return req;
}
struct tevent_req *req,
int *dp_error,
int *error,
char **usn,
{
}
}
return EOK;
}
{
int ret;
return EOK;
}
return EIO;
}
}
return ret;
}
return EAGAIN;
}
{
int dp_error;
int ret;
if (dp_error == DP_ERR_OFFLINE) {
return;
goto fail;
}
state->ldap_filter);
goto fail;
}
return;
fail:
}
struct tevent_context *ev,
struct sdap_options *opts,
struct sdap_handle *sh,
const char *ldap_filter)
{
int ret;
if (!req) {
return NULL;
}
state->ldap_rules_count = 0;
if (!state->search_bases) {
("SUDOERS lookup request without a search base\n"));
goto done;
}
/* create attrs from map */
goto fail;
}
/* begin search */
done:
}
return req;
fail:
return NULL;
}
{
if (search_base == NULL) {
/* should not happen */
return EFAULT;
}
/* create filter */
return ENOMEM;
}
/* send request */
("Searching for sudo rules with base [%s]\n",
search_base->basedn));
true);
return ENOMEM;
}
return EOK;
}
{
int ret;
int i;
("Receiving sudo rules with base [%s]\n",
search_base->basedn));
if (ret) {
return;
}
/* add rules to result */
if (count > 0) {
struct sysdb_attrs *,
return;
}
for (i = 0; i < count; i++) {
}
}
/* go to next base */
}
return;
}
/* we are done */
}
struct sysdb_attrs ***rules)
{
return EOK;
}
{
size_t rules_count = 0;
int ret;
bool in_transaction = false;
goto done;
}
/* start transaction */
goto done;
}
in_transaction = true;
/* purge cache */
goto done;
}
/* store rules */
&state->highest_usn);
goto done;
}
/* commit transaction */
goto done;
}
in_transaction = false;
done:
if (in_transaction) {
}
}
} else {
}
}
const char *filter,
struct sdap_attr_map *map,
struct sysdb_attrs **rules)
{
const char *name;
int i;
/* removes downloaded rules from the cache */
return EOK;
}
for (i = 0; i < rules_count; i++) {
&name);
continue;
}
("Failed to delete rule %s: [%s]\n",
continue;
}
}
} else {
/* purge cache by provided filter */
goto done;
}
}
done:
}
return ret;
}
struct sdap_options *opts,
struct sysdb_attrs **rules,
int cache_timeout,
char **_usn)
{
/* Empty sudoers? Done. */
return EOK;
}
_usn);
return ret;
}
return EOK;
}