summaryrefslogtreecommitdiff
path: root/src/responder/sudo
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-01-15 22:03:08 -0500
committerJakub Hrozek <jhrozek@redhat.com>2013-02-10 22:08:47 +0100
commitbfba0655bc129ebcffc20b1204e0f87549e0a74e (patch)
tree794d66607b465dc1e41a465968f848033ac6359d /src/responder/sudo
parentbba1a5fd62cffcae076d1351df5a83fbc4a6ec17 (diff)
downloadsssd-bfba0655bc129ebcffc20b1204e0f87549e0a74e.tar.gz
sssd-bfba0655bc129ebcffc20b1204e0f87549e0a74e.tar.bz2
sssd-bfba0655bc129ebcffc20b1204e0f87549e0a74e.zip
Parent and subdomains use the same sysdb
Remove code that tries to get the 'right' sysdb, as it is always going to get the same answer anyway since the recent patches to rework the domains/sysdb relationship.
Diffstat (limited to 'src/responder/sudo')
-rw-r--r--src/responder/sudo/sudosrv_get_sudorules.c73
1 files changed, 7 insertions, 66 deletions
diff --git a/src/responder/sudo/sudosrv_get_sudorules.c b/src/responder/sudo/sudosrv_get_sudorules.c
index 90481ed9..76eae222 100644
--- a/src/responder/sudo/sudosrv_get_sudorules.c
+++ b/src/responder/sudo/sudosrv_get_sudorules.c
@@ -29,22 +29,6 @@
#include "db/sysdb_sudo.h"
#include "responder/sudo/sudosrv_private.h"
-static struct sysdb_ctx* sudosrv_get_user_sysdb(struct sss_domain_info *domain)
-{
- return domain->sysdb;
-}
-
-static struct sysdb_ctx* sudosrv_get_rules_sysdb(struct sss_domain_info *domain)
-{
- if (domain->parent == NULL) {
- return domain->sysdb;
- } else {
- /* sudo rules are stored under parent domain basedn, so we will return
- * parent's sysdb context */
- return domain->parent->sysdb;
- }
-}
-
static errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx);
errno_t sudosrv_get_sudorules(struct sudo_dom_ctx *dctx)
@@ -88,7 +72,6 @@ static errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx)
struct sss_domain_info *dom = dctx->domain;
struct sudo_cmd_ctx *cmd_ctx = dctx->cmd_ctx;
struct cli_ctx *cli_ctx = dctx->cmd_ctx->cli_ctx;
- struct sysdb_ctx *sysdb;
struct ldb_result *user;
time_t cache_expire = 0;
struct tevent_req *dpreq;
@@ -128,15 +111,8 @@ static errno_t sudosrv_get_user(struct sudo_dom_ctx *dctx)
DEBUG(SSSDBG_FUNC_DATA, ("Requesting info about [%s@%s]\n",
name, dom->name));
- sysdb = sudosrv_get_user_sysdb(dctx->domain);
- if (sysdb == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("sysdb context not found for this domain!\n"));
- ret = EIO;
- goto done;
- }
-
- ret = sysdb_getpwnam(dctx, sysdb, dctx->domain, name, &user);
+ ret = sysdb_getpwnam(dctx, dctx->domain->sysdb,
+ dctx->domain, name, &user);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
("Failed to make request to our cache!\n"));
@@ -344,8 +320,6 @@ errno_t sudosrv_get_rules(struct sudo_cmd_ctx *cmd_ctx)
TALLOC_CTX *tmp_ctx = NULL;
struct tevent_req *dpreq = NULL;
struct dp_callback_ctx *cb_ctx = NULL;
- struct sysdb_ctx *user_sysdb = NULL;
- struct sysdb_ctx *rules_sysdb = NULL;
char **groupnames = NULL;
uint32_t expired_rules_num = 0;
struct sysdb_attrs **expired_rules = NULL;
@@ -359,22 +333,6 @@ errno_t sudosrv_get_rules(struct sudo_cmd_ctx *cmd_ctx)
return EFAULT;
}
- user_sysdb = sudosrv_get_user_sysdb(cmd_ctx->domain);
- if (user_sysdb == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("user sysdb context not found for this domain!\n"));
- ret = EIO;
- goto done;
- }
-
- rules_sysdb = sudosrv_get_rules_sysdb(cmd_ctx->domain);
- if (rules_sysdb == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("rules sysdb context not found for this domain!\n"));
- ret = EIO;
- goto done;
- }
-
tmp_ctx = talloc_new(NULL);
if (tmp_ctx == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_new() failed\n"));
@@ -399,7 +357,7 @@ errno_t sudosrv_get_rules(struct sudo_cmd_ctx *cmd_ctx)
* expired rules for this user and defaults at once we will save one
* provider call
*/
- ret = sysdb_get_sudo_user_info(tmp_ctx, user_sysdb, cmd_ctx->domain,
+ ret = sysdb_get_sudo_user_info(tmp_ctx, cmd_ctx->domain->sysdb, cmd_ctx->domain,
cmd_ctx->orig_username, NULL, &groupnames);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
@@ -411,7 +369,7 @@ errno_t sudosrv_get_rules(struct sudo_cmd_ctx *cmd_ctx)
| SYSDB_SUDO_FILTER_INCLUDE_DFL
| SYSDB_SUDO_FILTER_ONLY_EXPIRED
| SYSDB_SUDO_FILTER_USERINFO;
- ret = sudosrv_get_sudorules_query_cache(tmp_ctx, rules_sysdb,
+ ret = sudosrv_get_sudorules_query_cache(tmp_ctx, cmd_ctx->domain->sysdb,
cmd_ctx->domain, cmd_ctx->type,
attrs, flags, cmd_ctx->orig_username,
cmd_ctx->uid, groupnames,
@@ -569,8 +527,6 @@ static errno_t sudosrv_get_sudorules_from_cache(TALLOC_CTX *mem_ctx,
{
TALLOC_CTX *tmp_ctx;
errno_t ret;
- struct sysdb_ctx *user_sysdb = NULL;
- struct sysdb_ctx *rules_sysdb = NULL;
char **groupnames = NULL;
const char *debug_name = NULL;
unsigned int flags = SYSDB_SUDO_FILTER_NONE;
@@ -600,26 +556,11 @@ static errno_t sudosrv_get_sudorules_from_cache(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- user_sysdb = sudosrv_get_user_sysdb(cmd_ctx->domain);
- if (user_sysdb == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("user sysdb context not found for this domain!\n"));
- ret = EIO;
- goto done;
- }
-
- rules_sysdb = sudosrv_get_rules_sysdb(cmd_ctx->domain);
- if (rules_sysdb == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE,
- ("rules sysdb context not found for this domain!\n"));
- ret = EIO;
- goto done;
- }
-
switch (cmd_ctx->type) {
case SSS_SUDO_USER:
debug_name = cmd_ctx->cased_username;
- ret = sysdb_get_sudo_user_info(tmp_ctx, user_sysdb, cmd_ctx->domain,
+ ret = sysdb_get_sudo_user_info(tmp_ctx, cmd_ctx->domain->sysdb,
+ cmd_ctx->domain,
cmd_ctx->orig_username,
NULL, &groupnames);
if (ret != EOK) {
@@ -635,7 +576,7 @@ static errno_t sudosrv_get_sudorules_from_cache(TALLOC_CTX *mem_ctx,
break;
}
- ret = sudosrv_get_sudorules_query_cache(tmp_ctx, rules_sysdb,
+ ret = sudosrv_get_sudorules_query_cache(tmp_ctx, cmd_ctx->domain->sysdb,
cmd_ctx->domain, cmd_ctx->type,
attrs, flags, cmd_ctx->orig_username,
cmd_ctx->uid, groupnames,