summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-02-03 13:57:00 +0100
committerStephen Gallagher <sgallagh@redhat.com>2012-02-29 12:53:47 -0500
commitb7b50b21d2254a079b1b1c299909483d23db1512 (patch)
treec2c9b2bff77dfadb9d70d348ad6ffb06c60e8d2b
parentd2d2d6ae0c436461bcc8f881df059eb036314c44 (diff)
downloadsssd-b7b50b21d2254a079b1b1c299909483d23db1512.tar.gz
sssd-b7b50b21d2254a079b1b1c299909483d23db1512.tar.xz
sssd-b7b50b21d2254a079b1b1c299909483d23db1512.zip
Remove sysdb_get_ctx_from_list()
-rw-r--r--src/db/sysdb.c29
-rw-r--r--src/db/sysdb.h4
-rw-r--r--src/responder/autofs/autofssrv_cmd.c4
-rw-r--r--src/responder/nss/nsssrv_cmd.c28
-rw-r--r--src/responder/nss/nsssrv_netgroup.c4
-rw-r--r--src/responder/nss/nsssrv_services.c19
-rw-r--r--src/responder/pam/pam_LOCAL_domain.c7
-rw-r--r--src/responder/pam/pamsrv_cmd.c24
-rw-r--r--src/responder/ssh/sshsrv_cmd.c14
-rw-r--r--src/responder/sudo/sudosrv_get_sudorules.c11
10 files changed, 53 insertions, 91 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index d3a20cf1e..bec250570 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1310,35 +1310,6 @@ fail:
return ret;
}
-int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list,
- struct sss_domain_info *domain,
- struct sysdb_ctx **sysdb)
-{
- int i;
-
- if (domain->sysdb != NULL) {
- *sysdb = domain->sysdb;
- return EOK;
- }
-
- DEBUG(SSSDBG_TRACE_FUNC, ("sysdb context not stored in domain, "
- "trying to find by name.\n"));
-
- for (i = 0; i < ctx_list->num_dbs; i++) {
- if (ctx_list->dbs[i]->domain == domain) {
- *sysdb = ctx_list->dbs[i];
- return EOK;
- }
- if (strcasecmp(ctx_list->dbs[i]->domain->name, domain->name) == 0) {
- *sysdb = ctx_list->dbs[i];
- return EOK;
- }
- }
- /* definitely not found */
- return ENOENT;
-}
-
-
int compare_ldb_dn_comp_num(const void *m1, const void *m2)
{
struct ldb_message *msg1 = talloc_get_type(*(void **) discard_const(m1),
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 1da61f2c1..5cec84844 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -340,10 +340,6 @@ int sysdb_list_init(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
struct sysdb_ctx_list **_list);
-int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list,
- struct sss_domain_info *domain,
- struct sysdb_ctx **_ctx);
-
errno_t sysdb_add_to_domain(struct sss_domain_info *domain,
struct sysdb_ctx *ctx);
/* functions to retrieve information from sysdb
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c
index 8123db2a4..7497a18fc 100644
--- a/src/responder/autofs/autofssrv_cmd.c
+++ b/src/responder/autofs/autofssrv_cmd.c
@@ -559,8 +559,8 @@ lookup_automntmap_step(struct setautomntent_lookup_ctx *lookup_ctx)
DEBUG(SSSDBG_TRACE_FUNC, ("Requesting info for [%s@%s]\n",
lookup_ctx->mapname, dom->name));
- ret = sysdb_get_ctx_from_list(lookup_ctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 2a2a16b8b..1e9927c17 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -715,8 +715,8 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx)
DEBUG(4, ("Requesting info for [%s@%s]\n", name, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -944,8 +944,8 @@ static int nss_cmd_getpwuid_search(struct nss_dom_ctx *dctx)
DEBUG(4, ("Requesting info for [%d@%s]\n", cmdctx->id, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -1314,8 +1314,8 @@ static errno_t nss_cmd_setpwent_step(struct setent_step_ctx *step_ctx)
DEBUG(6, ("Requesting info for domain [%s]\n", dom->name));
- ret = sysdb_get_ctx_from_list(rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -2020,8 +2020,8 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx)
DEBUG(4, ("Requesting info for [%s@%s]\n", name, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -2249,8 +2249,8 @@ static int nss_cmd_getgrgid_search(struct nss_dom_ctx *dctx)
DEBUG(4, ("Requesting info for [%d@%s]\n", cmdctx->id, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -2612,8 +2612,8 @@ static errno_t nss_cmd_setgrent_step(struct setent_step_ctx *step_ctx)
DEBUG(6, ("Requesting info for domain [%s]\n", dom->name));
- ret = sysdb_get_ctx_from_list(rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
@@ -3081,8 +3081,8 @@ static int nss_cmd_initgroups_search(struct nss_dom_ctx *dctx)
DEBUG(4, ("Requesting info for [%s@%s]\n", name, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index 5c79342c9..9cb3422f2 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -412,8 +412,8 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
DEBUG(4, ("Requesting info for [%s@%s]\n",
name, dom->name));
- ret = sysdb_get_ctx_from_list(step_ctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
return EIO;
}
diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c
index 872b0701f..a3ac85760 100644
--- a/src/responder/nss/nsssrv_services.c
+++ b/src/responder/nss/nsssrv_services.c
@@ -164,8 +164,8 @@ getserv_send(TALLOC_CTX *mem_ctx,
}
if (!dom) break;
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
("Critical: Sysdb CTX not found for [%s]!\n", dom->name));
ret = EINVAL;
@@ -479,9 +479,8 @@ static void lookup_service_done(struct tevent_req *subreq)
* be returned, if it exists. Otherwise, move to the
* next provider.
*/
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list,
- dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
("Critical: Sysdb CTX not found for [%s]!\n",
dom->name));
@@ -1370,10 +1369,11 @@ lookup_servent_send(TALLOC_CTX *mem_ctx,
/* No provider check required. Just ask the
* sysdb.
*/
- ret = sysdb_get_ctx_from_list(rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Sysdb CTX not found for [%s]!\n", dom->name));
+ ret = EINVAL;
goto immediate;
}
@@ -1431,10 +1431,11 @@ lookup_servent_done(struct tevent_req *subreq)
}
/* Check the cache now */
- ret = sysdb_get_ctx_from_list(state->rctx->db_list, state->dom, &sysdb);
- if (ret != EOK) {
+ sysdb = state->dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Sysdb CTX not found for [%s]!\n", state->dom->name));
+ ret = EINVAL;
goto done;
}
diff --git a/src/responder/pam/pam_LOCAL_domain.c b/src/responder/pam/pam_LOCAL_domain.c
index baf8cc663..71446b4f8 100644
--- a/src/responder/pam/pam_LOCAL_domain.c
+++ b/src/responder/pam/pam_LOCAL_domain.c
@@ -236,12 +236,11 @@ int LOCAL_pam_handler(struct pam_auth_req *preq)
return ENOMEM;
}
- ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list,
- preq->domain, &lreq->dbctx);
- if (ret != EOK) {
+ lreq->dbctx = preq->domain->sysdb;
+ if (lreq->dbctx == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
talloc_free(lreq);
- return ret;
+ return ENOENT;
}
lreq->ev = preq->cctx->ev;
lreq->preq = preq;
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index 841bbf439..3efa696ac 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -331,10 +331,10 @@ static errno_t set_last_login(struct pam_auth_req *preq)
goto fail;
}
- ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list, preq->domain,
- &dbctx);
- if (ret != EOK) {
+ dbctx = preq->domain->sysdb;
+ if (dbctx == NULL) {
DEBUG(0, ("Fatal: Sysdb context not found for this domain!\n"));
+ ret = EINVAL;
goto fail;
}
@@ -377,9 +377,11 @@ static errno_t get_selinux_string(struct pam_auth_req *preq)
goto done;
}
- ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list,
- preq->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = preq->domain->sysdb;
+ if (sysdb == NULL) {
+ DEBUG(SSSDBG_FATAL_FAILURE, ("Fatal: Sysdb CTX not found for "
+ "domain [%s]!\n", preq->domain->name));
+ ret = EINVAL;
goto done;
}
@@ -655,9 +657,8 @@ static void pam_reply(struct pam_auth_req *preq)
/* do auth with offline credentials */
pd->offline_auth = true;
- ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list,
- preq->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = preq->domain->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for "
"domain [%s]!\n", preq->domain->name));
goto done;
@@ -994,7 +995,6 @@ static void pam_dp_send_acct_req_done(struct tevent_req *req);
static int pam_check_user_search(struct pam_auth_req *preq)
{
struct sss_domain_info *dom = preq->domain;
- struct cli_ctx *cctx = preq->cctx;
char *name = NULL;
struct sysdb_ctx *sysdb;
time_t cacheExpire;
@@ -1049,8 +1049,8 @@ static int pam_check_user_search(struct pam_auth_req *preq)
DEBUG(4, ("Requesting info for [%s@%s]\n", name, dom->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
preq->pd->pam_status = PAM_SYSTEM_ERR;
return EFAULT;
diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c
index be79f0c9c..77ffd80c1 100644
--- a/src/responder/ssh/sshsrv_cmd.c
+++ b/src/responder/ssh/sshsrv_cmd.c
@@ -258,7 +258,6 @@ static errno_t
ssh_user_pubkeys_search_next(struct ssh_cmd_ctx *cmd_ctx)
{
errno_t ret;
- struct cli_ctx *cctx = cmd_ctx->cctx;
struct sysdb_ctx *sysdb;
const char *attrs[] = { SYSDB_NAME, SYSDB_SSH_PUBKEY, NULL };
struct ldb_result *res;
@@ -267,8 +266,8 @@ ssh_user_pubkeys_search_next(struct ssh_cmd_ctx *cmd_ctx)
("Requesting SSH user public keys for [%s@%s]\n",
cmd_ctx->name, cmd_ctx->domain->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, cmd_ctx->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = cmd_ctx->domain->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Fatal: Sysdb CTX not found for this domain!\n"));
return EFAULT;
@@ -393,7 +392,6 @@ static errno_t
ssh_host_pubkeys_search_next(struct ssh_cmd_ctx *cmd_ctx)
{
errno_t ret;
- struct cli_ctx *cctx = cmd_ctx->cctx;
struct sysdb_ctx *sysdb;
const char *attrs[] = { SYSDB_NAME, SYSDB_SSH_PUBKEY, NULL };
@@ -401,8 +399,8 @@ ssh_host_pubkeys_search_next(struct ssh_cmd_ctx *cmd_ctx)
("Requesting SSH host public keys for [%s@%s]\n",
cmd_ctx->name, cmd_ctx->domain->name));
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, cmd_ctx->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = cmd_ctx->domain->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Fatal: Sysdb CTX not found for this domain!\n"));
return EFAULT;
@@ -504,8 +502,8 @@ ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
}
while (dom) {
- ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, dom, &sysdb);
- if (ret != EOK) {
+ sysdb = dom->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
("Fatal: Sysdb CTX not found for this domain!\n"));
ret = EFAULT;
diff --git a/src/responder/sudo/sudosrv_get_sudorules.c b/src/responder/sudo/sudosrv_get_sudorules.c
index 2988b5199..abdf3e76f 100644
--- a/src/responder/sudo/sudosrv_get_sudorules.c
+++ b/src/responder/sudo/sudosrv_get_sudorules.c
@@ -111,9 +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));
- ret = sysdb_get_ctx_from_list(cli_ctx->rctx->db_list,
- dctx->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = dctx->domain->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
("sysdb context not found for this domain!\n"));
ret = EIO;
@@ -400,7 +399,6 @@ static errno_t sudosrv_get_sudorules_from_cache(struct sudo_dom_ctx *dctx)
TALLOC_CTX *tmp_ctx;
errno_t ret;
struct sysdb_ctx *sysdb;
- struct cli_ctx *cli_ctx = dctx->cmd_ctx->cli_ctx;
struct sudo_ctx *sudo_ctx = dctx->cmd_ctx->sudo_ctx;
uid_t uid;
char **groupnames;
@@ -410,9 +408,8 @@ static errno_t sudosrv_get_sudorules_from_cache(struct sudo_dom_ctx *dctx)
tmp_ctx = talloc_new(NULL);
if (tmp_ctx == NULL) return ENOMEM;
- ret = sysdb_get_ctx_from_list(cli_ctx->rctx->db_list,
- dctx->domain, &sysdb);
- if (ret != EOK) {
+ sysdb = dctx->domain->sysdb;
+ if (sysdb == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE,
("sysdb context not found for this domain!\n"));
ret = EIO;