On Wed, Feb 08, 2012 at 10:25:51AM +0100, Sumit Bose wrote: > On Tue, Jan 31, 2012 at 07:18:10AM -0500, Stephen Gallagher wrote: > > On Tue, 2012-01-31 at 09:36 +0100, Sumit Bose wrote: > > > On Mon, Jan 30, 2012 at 09:31:14PM -0500, Stephen Gallagher wrote: > > > > On Wed, 2012-01-25 at 18:12 +0100, Sumit Bose wrote: > > > > > Hi, > > > > > > > > > > a few days ago I send a draft patch where the sysdb context is stored > > > > > in the domain info struct. I created a patch which is a bot more > > > > > conservative than the last one and included the comments by Simo > > > > > (added > > > > > a destructor and don't unconditionally add the context all the time). > > > > > > > > > > This patch will make the handling of sub-domains much easier, because > > > > > now only the domain info struct for the sub-domains needs to be > > > > > up-to-date. > > > > > > > > > > > > Nack. > > > > > > > > To save ourselves some cycles, if we go through the search in > > > > sysdb_get_ctx_from_list(), it would be best to assign the sysdb context > > > > to the domain once it's discovered. That said, I'm confused why we would > > > > ever hit that code. I'm somewhat inclined to remove it and just always > > > > return the domain->sysdb value and see if anything blows up and fix that > > > > instead. > > > > > > ok, this was my first idea as well, but then I thought it might be > > > better to be conservative here and look for the debug message from some > > > time to see if this path is ever taken. > > > > > > Would you prefer to keep sysdb_get_ctx_from_list() and let it just > > > return domain->sysdb or shall I remove it completely and let the caller > > > just take domain->sysdb and check for NULL? > > > > Actually, let's eliminate the sysdb_get_ctx_from_list() and just take > > domain->sysdb. If it's NULL, throw a level 0 DEBUG message so we will > > see it and fix it immediately. > > Please find new patches attached. The first one is basically unchanged > only rebased on top of to current master. The second patch removes > sysdb_get_ctx_from_list() and changes the callers accordingly.
Please find a rebased version of the patches attached. bye, Sumit
From 4300644c3eada6f5770c78c6be4f20abea3ff7c6 Mon Sep 17 00:00:00 2001 From: Sumit Bose <sb...@redhat.com> Date: Mon, 23 Jan 2012 12:57:33 +0100 Subject: [PATCH 1/2] Keep sysdb context in domain info struct --- src/confdb/confdb.h | 2 + src/db/sysdb.c | 80 ++++++++++++++++++++++++++++++++++++++ src/db/sysdb.h | 9 ++++ src/providers/data_provider_be.c | 10 +---- src/python/pysss.c | 11 +---- src/tests/auth-tests.c | 12 +---- src/tests/sysdb-tests.c | 12 +---- src/tools/sss_cache.c | 10 +---- src/tools/tools_util.c | 10 +---- 9 files changed, 105 insertions(+), 51 deletions(-) diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h index 18484f0..aebf5d8 100644 --- a/src/confdb/confdb.h +++ b/src/confdb/confdb.h @@ -188,6 +188,8 @@ struct sss_domain_info { uint32_t service_timeout; uint32_t autofsmap_timeout; + struct sysdb_ctx *sysdb; + struct sss_domain_info *next; }; diff --git a/src/db/sysdb.c b/src/db/sysdb.c index a7f65a3..d3a20cf 100644 --- a/src/db/sysdb.c +++ b/src/db/sysdb.c @@ -822,6 +822,37 @@ int sysdb_get_db_file(TALLOC_CTX *mem_ctx, return EOK; } +static int remove_sysdb_from_domain(void *mem) +{ + struct sysdb_ctx *ctx = talloc_get_type(mem, struct sysdb_ctx); + + if (ctx->domain != NULL && ctx->domain->sysdb == ctx) { + ctx->domain->sysdb = NULL; + } + + return 0; +} + +errno_t sysdb_add_to_domain(struct sss_domain_info *domain, + struct sysdb_ctx *ctx) +{ + if (domain == NULL || ctx == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("Missing domain or sysdb context.\n")); + return EINVAL; + } + + if (domain->sysdb != NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("Sysdb context already set.\n")); + return EINVAL; + } + + domain->sysdb = ctx; + + talloc_set_destructor((TALLOC_CTX *) ctx, remove_sysdb_from_domain); + + return EOK; +} + int sysdb_domain_init_internal(TALLOC_CTX *mem_ctx, struct sss_domain_info *domain, const char *db_path, @@ -1174,6 +1205,12 @@ int sysdb_init(TALLOC_CTX *mem_ctx, return ret; } + ret = sysdb_add_to_domain(dom, sysdb); + if (ret != EOK) { + talloc_zfree(ctx_list); + return ret; + } + ctx_list->dbs[ctx_list->num_dbs] = sysdb; ctx_list->num_dbs++; } @@ -1197,6 +1234,41 @@ int sysdb_domain_init(TALLOC_CTX *mem_ctx, db_path, false, _ctx); } +errno_t sysdb_init_domain_and_sysdb(TALLOC_CTX *mem_ctx, + struct confdb_ctx *cdb, + const char *domain_name, + const char *db_path, + struct sss_domain_info **_domain, + struct sysdb_ctx **_ctx) +{ + int ret; + struct sss_domain_info *dom; + struct sysdb_ctx *ctx; + + ret = confdb_get_domain(cdb, domain_name, &dom); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("Error retrieving domain configuration.\n")); + return ret; + } + + ret = sysdb_domain_init(mem_ctx, dom, db_path, &ctx); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("Error opening cache database.\n")); + return ret; + } + + ret = sysdb_add_to_domain(dom, ctx); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("Error storing cache database context.\n")); + return ret; + } + + *_domain = dom; + *_ctx = ctx; + + return EOK; +} + int sysdb_list_init(TALLOC_CTX *mem_ctx, const char *path, struct sysdb_ctx *sysdb, @@ -1244,6 +1316,14 @@ int sysdb_get_ctx_from_list(struct sysdb_ctx_list *ctx_list, { 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]; diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 5f264c2..1da61f2 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -328,6 +328,13 @@ int sysdb_domain_init(TALLOC_CTX *mem_ctx, const char *db_path, struct sysdb_ctx **_ctx); +errno_t sysdb_init_domain_and_sysdb(TALLOC_CTX *mem_ctx, + struct confdb_ctx *cdb, + const char *domain_name, + const char *db_path, + struct sss_domain_info **_domain, + struct sysdb_ctx **_ctx); + int sysdb_list_init(TALLOC_CTX *mem_ctx, const char *path, struct sysdb_ctx *sysdb, @@ -337,6 +344,8 @@ 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 * These functions automatically starts an operation * therefore they cannot be called within a transaction */ diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 7e27cea..5b96b15 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -1754,14 +1754,8 @@ int be_process_init(TALLOC_CTX *mem_ctx, return ret; } - ret = confdb_get_domain(cdb, be_domain, &ctx->domain); - if (ret != EOK) { - DEBUG(SSSDBG_FATAL_FAILURE, - ("fatal error retrieving domain configuration\n")); - return ret; - } - - ret = sysdb_domain_init(ctx, ctx->domain, DB_PATH, &ctx->sysdb); + ret = sysdb_init_domain_and_sysdb(ctx, cdb, be_domain, DB_PATH, + &ctx->domain, &ctx->sysdb); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, ("fatal error opening cache database\n")); return ret; diff --git a/src/python/pysss.c b/src/python/pysss.c index 948fd16..45725c0 100644 --- a/src/python/pysss.c +++ b/src/python/pysss.c @@ -772,15 +772,8 @@ static PyObject *PySssLocalObject_new(PyTypeObject *type, return NULL; } - ret = confdb_get_domain(self->confdb, "local", &self->local); - if (ret != EOK) { - talloc_free(mem_ctx); - PyErr_SetSssErrorWithMessage(ret, "Cannot get local domain"); - return NULL; - } - - /* open 'local' sysdb at default path */ - ret = sysdb_domain_init(self->mem_ctx, self->local, DB_PATH, &self->sysdb); + ret = sysdb_init_domain_and_sysdb(self->mem_ctx, self->confdb, "local", + DB_PATH, &self->local, &self->sysdb); if (ret != EOK) { talloc_free(mem_ctx); PyErr_SetSssErrorWithMessage(ret, diff --git a/src/tests/auth-tests.c b/src/tests/auth-tests.c index 96bae98..4d25e2e 100644 --- a/src/tests/auth-tests.c +++ b/src/tests/auth-tests.c @@ -134,15 +134,9 @@ static int setup_sysdb_tests(struct sysdb_test_ctx **ctx) return ret; } - ret = confdb_get_domain(test_ctx->confdb, "local", &test_ctx->domain); - if (ret != EOK) { - fail("Could not retrieve LOCAL domain"); - talloc_free(test_ctx); - return ret; - } - - ret = sysdb_domain_init(test_ctx, - test_ctx->domain, TESTS_PATH, &test_ctx->sysdb); + ret = sysdb_init_domain_and_sysdb(test_ctx, test_ctx->confdb, "local", + TESTS_PATH, + &test_ctx->domain, &test_ctx->sysdb); if (ret != EOK) { fail("Could not initialize connection to the sysdb (%d)", ret); talloc_free(test_ctx); diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c index b3aaa26..765b59d 100644 --- a/src/tests/sysdb-tests.c +++ b/src/tests/sysdb-tests.c @@ -141,15 +141,9 @@ static int setup_sysdb_tests(struct sysdb_test_ctx **ctx) return ret; } - ret = confdb_get_domain(test_ctx->confdb, "local", &test_ctx->domain); - if (ret != EOK) { - fail("Could not retrieve LOCAL domain"); - talloc_free(test_ctx); - return ret; - } - - ret = sysdb_domain_init(test_ctx, - test_ctx->domain, TESTS_PATH, &test_ctx->sysdb); + ret = sysdb_init_domain_and_sysdb(test_ctx, test_ctx->confdb, "local", + TESTS_PATH, + &test_ctx->domain, &test_ctx->sysdb); if (ret != EOK) { fail("Could not initialize connection to the sysdb (%d)", ret); talloc_free(test_ctx); diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index e8b1926..a9885b0 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -204,14 +204,8 @@ errno_t init_domains(struct cache_tool_ctx *ctx, const char *domain) { } if (domain) { - ret = confdb_get_domain(ctx->confdb, domain, &ctx->domains); - if (ret != EOK) { - DEBUG(1, ("Could not get '%s' domain: [%d] [%s]\n", - domain, ret, strerror(ret))); - goto fail; - } - - ret = sysdb_domain_init(ctx, ctx->domains, DB_PATH, &db_ctx); + ret = sysdb_init_domain_and_sysdb(ctx, ctx->confdb, domain, DB_PATH, + &ctx->domains, &db_ctx); if (ret != EOK) { DEBUG(1, ("Could not initialize connection to the sysdb\n")); goto fail; diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c index 0044895..871ba2b 100644 --- a/src/tools/tools_util.c +++ b/src/tools/tools_util.c @@ -53,14 +53,8 @@ static int setup_db(struct tools_ctx *ctx) return ret; } - ret = confdb_get_domain(ctx->confdb, "local", &ctx->local); - if (ret != EOK) { - DEBUG(1, ("Could not get 'local' domain: [%d] [%s]\n", ret, strerror(ret))); - return ret; - } - - /* open 'local' sysdb at default path */ - ret = sysdb_domain_init(ctx, ctx->local, DB_PATH, &ctx->sysdb); + ret = sysdb_init_domain_and_sysdb(ctx, ctx->confdb, "local", DB_PATH, + &ctx->local, &ctx->sysdb); if (ret != EOK) { DEBUG(1, ("Could not initialize connection to the sysdb\n")); return ret; -- 1.7.7.6
From 80f12de3f7ab5e87920864ace393f34f5fc6ee46 Mon Sep 17 00:00:00 2001 From: Sumit Bose <sb...@redhat.com> Date: Fri, 3 Feb 2012 13:57:00 +0100 Subject: [PATCH 2/2] Remove sysdb_get_ctx_from_list() --- src/db/sysdb.c | 29 ---------------------------- src/db/sysdb.h | 4 --- src/responder/autofs/autofssrv_cmd.c | 4 +- src/responder/nss/nsssrv_cmd.c | 28 +++++++++++++------------- src/responder/nss/nsssrv_netgroup.c | 4 +- src/responder/nss/nsssrv_services.c | 19 +++++++++-------- src/responder/pam/pam_LOCAL_domain.c | 7 ++--- src/responder/pam/pamsrv_cmd.c | 24 +++++++++++----------- src/responder/ssh/sshsrv_cmd.c | 14 +++++------- src/responder/sudo/sudosrv_get_sudorules.c | 11 +++------ 10 files changed, 53 insertions(+), 91 deletions(-) diff --git a/src/db/sysdb.c b/src/db/sysdb.c index d3a20cf..bec2505 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 1da61f2..5cec848 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 8123db2..7497a18 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 2a2a16b..1e9927c 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 5c79342..9cb3422 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 872b070..a3ac857 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 baf8cc6..71446b4 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 841bbf4..3efa696 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 2b281e7..17cc2a6 100644 --- a/src/responder/ssh/sshsrv_cmd.c +++ b/src/responder/ssh/sshsrv_cmd.c @@ -236,7 +236,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; @@ -245,8 +244,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; @@ -371,7 +370,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 }; @@ -379,8 +377,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; @@ -481,8 +479,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 2988b51..abdf3e7 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; -- 1.7.7.6
_______________________________________________ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel