diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-09-03 19:29:41 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-09-08 15:10:50 -0400 |
commit | 28d9dcbeabdf919506fe59e9d1cbed84fbd6e649 (patch) | |
tree | 3d5d878b1adc0ec8af94a52359d219689c763bd8 /server/responder | |
parent | aef967dc115c64f0288b8ecc3ff1d927aa42af70 (diff) | |
download | sssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.tar.gz sssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.tar.bz2 sssd-28d9dcbeabdf919506fe59e9d1cbed84fbd6e649.zip |
Split database in multiple files
The special persistent local database retains the original name.
All other backends now have their own cache-NAME.ldb file.
Diffstat (limited to 'server/responder')
-rw-r--r-- | server/responder/common/responder.h | 2 | ||||
-rw-r--r-- | server/responder/common/responder_common.c | 4 | ||||
-rw-r--r-- | server/responder/nss/nsssrv_cmd.c | 205 | ||||
-rw-r--r-- | server/responder/pam/pam_LOCAL_domain.c | 8 | ||||
-rw-r--r-- | server/responder/pam/pamsrv_cache.c | 9 | ||||
-rw-r--r-- | server/responder/pam/pamsrv_cmd.c | 29 |
6 files changed, 227 insertions, 30 deletions
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h index 59a58a5c..ddf8b893 100644 --- a/server/responder/common/responder.h +++ b/server/responder/common/responder.h @@ -62,7 +62,6 @@ struct resp_ctx { int lfd; struct tevent_fd *priv_lfde; int priv_lfd; - struct sysdb_ctx *sysdb; struct confdb_ctx *cdb; const char *sock_name; const char *priv_sock_name; @@ -71,6 +70,7 @@ struct resp_ctx { struct sbus_connection *dp_conn; struct sss_domain_info *domains; + struct sysdb_ctx_list *db_list; struct sss_cmd_table *sss_cmds; const char *sss_pipe_name; diff --git a/server/responder/common/responder_common.c b/server/responder/common/responder_common.c index f1030c04..57c8678b 100644 --- a/server/responder/common/responder_common.c +++ b/server/responder/common/responder_common.c @@ -510,7 +510,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, rctx->priv_sock_name = sss_priv_pipe_name; rctx->confdb_service_path = confdb_service_path; - ret = confdb_get_domains(rctx->cdb, rctx, &rctx->domains); + ret = confdb_get_domains(rctx->cdb, &rctx->domains); if (ret != EOK) { DEBUG(0, ("fatal error setting up domain map\n")); return ret; @@ -534,7 +534,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, return EIO; } - ret = sysdb_init(rctx, ev, cdb, NULL, &rctx->sysdb); + ret = sysdb_init(rctx, ev, cdb, NULL, false, &rctx->db_list); if (ret != EOK) { DEBUG(0, ("fatal error initializing resp_ctx\n")); return ret; diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index abd20a1b..405dae81 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -271,6 +271,7 @@ static void nss_cmd_getpwnam_callback(void *ptr, int status, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; struct sss_domain_info *dom; struct nss_ctx *nctx; int timeout; @@ -388,7 +389,13 @@ static void nss_cmd_getpwnam_callback(void *ptr, int status, DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getpwnam_callback, dctx); if (ret != EOK) { @@ -458,6 +465,7 @@ static void nss_cmd_getpwnam_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -479,7 +487,13 @@ static void nss_cmd_getpwnam_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getpwnam_callback, dctx); @@ -501,6 +515,7 @@ static int nss_cmd_getpwnam(struct cli_ctx *cctx) struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; const char *rawname; char *domname; @@ -602,7 +617,14 @@ static int nss_cmd_getpwnam(struct cli_ctx *cctx) DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getpwnam_callback, dctx); if (ret != EOK) { @@ -644,6 +666,7 @@ static void nss_cmd_getpwuid_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int timeout; uint64_t lastUpdate; @@ -748,7 +771,13 @@ static void nss_cmd_getpwuid_callback(void *ptr, int status, DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getpwuid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwuid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getpwuid_callback, dctx); if (ret != EOK) { @@ -818,6 +847,7 @@ static void nss_cmd_getpwuid_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -839,7 +869,13 @@ static void nss_cmd_getpwuid_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getpwuid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwuid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getpwuid_callback, dctx); @@ -860,6 +896,7 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx) struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; uint8_t *body; size_t blen; @@ -920,7 +957,14 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx) DEBUG(4, ("Requesting info for [%lu@%s]\n", cmdctx->id, dctx->domain->name)); - ret = sysdb_getpwuid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_getpwuid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getpwuid_callback, dctx); if (ret != EOK) { @@ -978,6 +1022,7 @@ static void nss_cmd_setpwent_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct getent_ctx *pctx; struct nss_ctx *nctx; int timeout; @@ -1040,7 +1085,13 @@ static void nss_cmd_setpwent_callback(void *ptr, int status, timeout, dom->name, SSS_DP_USER, NULL, 0); } else { - ret = sysdb_enumpwent(dctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_enumpwent(dctx, sysdb, dctx->domain, NULL, nss_cmd_setpwent_callback, dctx); } @@ -1085,6 +1136,7 @@ static void nss_cmd_setpw_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -1094,7 +1146,13 @@ static void nss_cmd_setpw_dp_callback(uint16_t err_maj, uint32_t err_min, (unsigned int)err_maj, (unsigned int)err_min, err_msg)); } - ret = sysdb_enumpwent(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_enumpwent(cmdctx, sysdb, dctx->domain, NULL, nss_cmd_setpwent_callback, dctx); if (ret != EOK) { @@ -1111,6 +1169,7 @@ static void nss_cmd_setpw_dp_callback(uint16_t err_maj, uint32_t err_min, static int nss_cmd_setpwent_ext(struct cli_ctx *cctx, bool immediate) { struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct nss_ctx *nctx; @@ -1173,7 +1232,14 @@ static int nss_cmd_setpwent_ext(struct cli_ctx *cctx, bool immediate) timeout, dom->name, SSS_DP_USER, NULL, 0); } else { - ret = sysdb_enumpwent(dctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_enumpwent(dctx, sysdb, dctx->domain, NULL, nss_cmd_setpwent_callback, dctx); } @@ -1634,6 +1700,7 @@ static void nss_cmd_getgrnam_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int timeout; uint64_t lastUpdate; @@ -1740,7 +1807,13 @@ static void nss_cmd_getgrnam_callback(void *ptr, int status, DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getgrnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getgrnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getgrnam_callback, dctx); if (ret != EOK) { @@ -1806,6 +1879,7 @@ static void nss_cmd_getgrnam_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -1827,7 +1901,13 @@ static void nss_cmd_getgrnam_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getgrnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getgrnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getgrnam_callback, dctx); @@ -1849,6 +1929,7 @@ static int nss_cmd_getgrnam(struct cli_ctx *cctx) struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; const char *rawname; char *domname; @@ -1950,7 +2031,14 @@ static int nss_cmd_getgrnam(struct cli_ctx *cctx) DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getgrnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_getgrnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getgrnam_callback, dctx); if (ret != EOK) { @@ -1992,6 +2080,7 @@ static void nss_cmd_getgrgid_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int timeout; uint64_t lastUpdate; @@ -2087,7 +2176,13 @@ static void nss_cmd_getgrgid_callback(void *ptr, int status, DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getgrgid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getgrgid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getgrgid_callback, dctx); if (ret != EOK) { @@ -2151,6 +2246,7 @@ static void nss_cmd_getgrgid_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -2172,7 +2268,13 @@ static void nss_cmd_getgrgid_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getgrgid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getgrgid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getgrgid_callback, dctx); @@ -2193,6 +2295,7 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx) struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; uint8_t *body; size_t blen; @@ -2253,7 +2356,14 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx) DEBUG(4, ("Requesting info for [%lu@%s]\n", cmdctx->id, dctx->domain->name)); - ret = sysdb_getgrgid(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_getgrgid(cmdctx, sysdb, dctx->domain, cmdctx->id, nss_cmd_getgrgid_callback, dctx); if (ret != EOK) { @@ -2311,6 +2421,7 @@ static void nss_cmd_setgrent_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct getent_ctx *gctx; struct nss_ctx *nctx; int timeout; @@ -2369,7 +2480,13 @@ static void nss_cmd_setgrent_callback(void *ptr, int status, timeout, dom->name, SSS_DP_GROUP, NULL, 0); } else { - ret = sysdb_enumgrent(dctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_enumgrent(dctx, sysdb, dctx->domain, nss_cmd_setgrent_callback, dctx); } @@ -2414,6 +2531,7 @@ static void nss_cmd_setgr_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -2423,7 +2541,13 @@ static void nss_cmd_setgr_dp_callback(uint16_t err_maj, uint32_t err_min, (unsigned int)err_maj, (unsigned int)err_min, err_msg)); } - ret = sysdb_enumgrent(dctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_enumgrent(dctx, sysdb, dctx->domain, nss_cmd_setgrent_callback, dctx); if (ret != EOK) { @@ -2440,6 +2564,7 @@ static void nss_cmd_setgr_dp_callback(uint16_t err_maj, uint32_t err_min, static int nss_cmd_setgrent_ext(struct cli_ctx *cctx, bool immediate) { struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct nss_ctx *nctx; @@ -2502,7 +2627,14 @@ static int nss_cmd_setgrent_ext(struct cli_ctx *cctx, bool immediate) timeout, dom->name, SSS_DP_GROUP, NULL, 0); } else { - ret = sysdb_enumgrent(dctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_enumgrent(dctx, sysdb, dctx->domain, nss_cmd_setgrent_callback, dctx); } @@ -2728,6 +2860,7 @@ static void nss_cmd_getinitgr_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -2737,7 +2870,13 @@ static void nss_cmd_getinitgr_callback(uint16_t err_maj, uint32_t err_min, (unsigned int)err_maj, (unsigned int)err_min, err_msg)); } - ret = sysdb_initgroups(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_initgroups(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_initgr_callback, cmdctx); if (ret != EOK) { @@ -2760,6 +2899,7 @@ static void nss_cmd_getinitnam_dp_callback(uint16_t err_maj, uint32_t err_min, struct nss_dom_ctx *dctx = talloc_get_type(ptr, struct nss_dom_ctx); struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; + struct sysdb_ctx *sysdb; int ret; if (err_maj) { @@ -2781,7 +2921,13 @@ static void nss_cmd_getinitnam_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getinit_callback, dctx); @@ -2804,6 +2950,7 @@ static void nss_cmd_getinit_callback(void *ptr, int status, struct nss_cmd_ctx *cmdctx = dctx->cmdctx; struct cli_ctx *cctx = cmdctx->cctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; int timeout; uint64_t lastUpdate; @@ -2920,7 +3067,13 @@ static void nss_cmd_getinit_callback(void *ptr, int status, DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + NSS_CMD_FATAL_ERROR(cctx); + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getinit_callback, dctx); if (ret != EOK) { @@ -2991,6 +3144,7 @@ static int nss_cmd_initgroups(struct cli_ctx *cctx) struct nss_cmd_ctx *cmdctx; struct nss_dom_ctx *dctx; struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct nss_ctx *nctx; const char *rawname; char *domname; @@ -3092,7 +3246,14 @@ static int nss_cmd_initgroups(struct cli_ctx *cctx) DEBUG(4, ("Requesting info for [%s@%s]\n", cmdctx->name, dctx->domain->name)); - ret = sysdb_getpwnam(cmdctx, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + dctx->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + ret = EFAULT; + goto done; + } + ret = sysdb_getpwnam(cmdctx, sysdb, dctx->domain, cmdctx->name, nss_cmd_getinit_callback, dctx); if (ret != EOK) { diff --git a/server/responder/pam/pam_LOCAL_domain.c b/server/responder/pam/pam_LOCAL_domain.c index 5d76891f..41d64b3e 100644 --- a/server/responder/pam/pam_LOCAL_domain.c +++ b/server/responder/pam/pam_LOCAL_domain.c @@ -459,7 +459,13 @@ int LOCAL_pam_handler(struct pam_auth_req *preq) return ENOMEM; } - lreq->dbctx = preq->cctx->rctx->sysdb; + ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list, + preq->domain, &lreq->dbctx); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + talloc_free(lreq); + return ret; + } lreq->ev = preq->cctx->ev; lreq->preq = preq; diff --git a/server/responder/pam/pamsrv_cache.c b/server/responder/pam/pamsrv_cache.c index 7cfd97b1..9c5c209f 100644 --- a/server/responder/pam/pamsrv_cache.c +++ b/server/responder/pam/pamsrv_cache.c @@ -132,6 +132,7 @@ done: int pam_cache_auth(struct pam_auth_req *preq) { + struct sysdb_ctx *sysdb; int ret; static const char *attrs[] = {SYSDB_NAME, @@ -144,7 +145,13 @@ int pam_cache_auth(struct pam_auth_req *preq) "lastFailedLogin", NULL}; - ret = sysdb_get_user_attr(preq, preq->cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list, + preq->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + return ret; + } + ret = sysdb_get_user_attr(preq, sysdb, preq->domain, preq->pd->user, attrs, pam_cache_auth_callback, preq); diff --git a/server/responder/pam/pamsrv_cmd.c b/server/responder/pam/pamsrv_cmd.c index 12625509..1204e325 100644 --- a/server/responder/pam/pamsrv_cmd.c +++ b/server/responder/pam/pamsrv_cmd.c @@ -382,6 +382,7 @@ static void pam_dom_forwarder(struct pam_auth_req *preq); static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd) { struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; struct pam_auth_req *preq; struct pam_data *pd; uint8_t *body; @@ -486,7 +487,13 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd) else { preq->check_provider = NEED_CHECK_PROVIDER(preq->domain->provider); - ret = sysdb_getpwnam(preq, cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(cctx->rctx->db_list, + preq->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + goto done; + } + ret = sysdb_getpwnam(preq, sysdb, preq->domain, preq->pd->user, pam_check_user_callback, preq); } @@ -509,6 +516,7 @@ static void pam_check_user_dp_callback(uint16_t err_maj, uint32_t err_min, { struct pam_auth_req *preq = talloc_get_type(ptr, struct pam_auth_req); struct ldb_result *res = NULL; + struct sysdb_ctx *sysdb; int ret; if ((err_maj != DP_ERR_OK) && (err_maj != DP_ERR_OFFLINE)) { @@ -531,7 +539,13 @@ static void pam_check_user_dp_callback(uint16_t err_maj, uint32_t err_min, return; } - ret = sysdb_getpwnam(preq, preq->cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list, + preq->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + goto done; + } + ret = sysdb_getpwnam(preq, sysdb, preq->domain, preq->pd->user, pam_check_user_callback, preq); @@ -547,6 +561,7 @@ static void pam_check_user_callback(void *ptr, int status, { struct pam_auth_req *preq = talloc_get_type(ptr, struct pam_auth_req); struct sss_domain_info *dom; + struct sysdb_ctx *sysdb; uint64_t lastUpdate; bool call_provider = false; time_t timeout; @@ -673,7 +688,15 @@ static void pam_check_user_callback(void *ptr, int status, else { preq->check_provider = NEED_CHECK_PROVIDER(preq->domain->provider); - ret = sysdb_getpwnam(preq, preq->cctx->rctx->sysdb, + ret = sysdb_get_ctx_from_list(preq->cctx->rctx->db_list, + preq->domain, &sysdb); + if (ret != EOK) { + DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n")); + preq->pd->pam_status = PAM_SYSTEM_ERR; + pam_reply(preq); + return; + } + ret = sysdb_getpwnam(preq, sysdb, preq->domain, preq->pd->user, pam_check_user_callback, preq); } |