sudosrv_get_sudorules.c revision e3bb7b3fda4697fa9c6f80107cd01dd04a20c85f
/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Jakub Hrozek <jhrozek@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 "config.h"
#include <stdint.h>
#include <string.h>
#include <talloc.h>
#include <tevent.h>
#include "db/sysdb_sudo.h"
#include "responder/common/responder_cache_req.h"
#include "responder/sudo/sudosrv_private.h"
#include "providers/data_provider.h"
static int
sudo_order_cmp(const void *a, const void *b, bool lower_wins)
{
int ret;
r1 = * (struct sysdb_attrs * const *) a;
r2 = * (struct sysdb_attrs * const *) b;
return 0;
}
/* man sudoers-ldap: If the sudoOrder attribute is not present,
* a value of 0 is assumed */
o1 = 0;
return 0;
}
/* man sudoers-ldap: If the sudoOrder attribute is not present,
* a value of 0 is assumed */
o2 = 0;
return 0;
}
if (lower_wins) {
/* The lowest value takes priority. Original wrong SSSD behaviour. */
return 1;
return -1;
}
} else {
/* The higher value takes priority. Standard LDAP behaviour. */
return 1;
return -1;
}
}
return 0;
}
static int
sudo_order_low_cmp_fn(const void *a, const void *b)
{
return sudo_order_cmp(a, b, true);
}
static int
sudo_order_high_cmp_fn(const void *a, const void *b)
{
return sudo_order_cmp(a, b, false);
}
static errno_t
{
if (lower_wins) {
} else {
}
return EOK;
}
struct sss_domain_info *domain,
const char **attrs,
unsigned int flags,
const char *username,
char **groupnames,
bool inverse_order,
struct sysdb_attrs ***_rules,
{
char *filter;
struct sysdb_attrs **rules;
struct ldb_message **msgs;
return ENOMEM;
}
goto done;
}
if (IS_SUBDOMAIN(domain)) {
/* rules are stored inside parent domain tree */
}
*_count = 0;
goto done;
goto done;
}
"Could not convert ldb message to sysdb_attrs\n");
goto done;
}
goto done;
}
done:
return ret;
}
struct sss_domain_info *domain,
const char *username,
char **groups,
struct sysdb_attrs ***_rules,
{
unsigned int flags = SYSDB_SUDO_FILTER_NONE;
_rules, _num_rules);
return ret;
}
enum sss_sudo_type type,
struct sss_domain_info *domain,
const char *username,
char **groups,
bool inverse_order,
struct sysdb_attrs ***_rules,
{
unsigned int flags = SYSDB_SUDO_FILTER_NONE;
struct sysdb_attrs **rules;
const char *debug_name = "unknown";
const char *attrs[] = { SYSDB_OBJECTCLASS,
NULL };
switch (type) {
case SSS_SUDO_USER:
debug_name = "rules";
break;
case SSS_SUDO_DEFAULTS:
debug_name = "default options";
break;
}
return ret;
}
*_num_rules = num_rules;
return EOK;
}
static void
{
}
struct sudosrv_refresh_rules_state {
struct sss_domain_info *domain;
const char *username;
};
static struct tevent_req *
struct tevent_context *ev,
struct sss_domain_info *domain,
const char *username,
char **groups)
{
struct sudosrv_refresh_rules_state *state;
struct tevent_req *req;
struct tevent_req *subreq;
struct sysdb_attrs **rules;
struct sudosrv_refresh_rules_state);
return NULL;
}
"Unable to retrieve expired sudo rules [%d]: %s\n",
goto immediately;
}
if (num_rules == 0) {
goto immediately;
}
goto immediately;
}
return req;
} else {
}
return req;
}
{
struct sudosrv_refresh_rules_state *state;
struct tevent_req *req;
char *err_msg;
"Unable to get information from Data Provider, "
"Error: %u, %u, %s\n",
goto done;
}
"Some expired rules were removed from the server, scheduling "
"full refresh out of band\n");
goto done;
}
}
done:
return;
}
}
{
return EOK;
}
struct sudosrv_get_rules_state {
struct tevent_context *ev;
enum sss_sudo_type type;
char *username;
struct sss_domain_info *domain;
char **groups;
bool inverse_order;
struct sysdb_attrs **rules;
};
struct tevent_context *ev,
enum sss_sudo_type type,
const char *username)
{
struct sudosrv_get_rules_state *state;
struct tevent_req *req;
struct tevent_req *subreq;
return NULL;
}
username);
goto immediately;
}
return req;
} else {
}
return req;
}
{
struct sudosrv_get_rules_state *state;
struct tevent_req *req;
goto done;
}
goto done;
}
goto done;
}
done:
return;
}
}
{
"Unable to refresh expired rules, we will return what is "
"in cache.\n");
}
return;
}
}
struct tevent_req *req,
struct sysdb_attrs ***_rules,
{
return EOK;
}