diff options
-rw-r--r-- | src/responder/common/responder.h | 2 | ||||
-rw-r--r-- | src/responder/common/responder_common.c | 13 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_cmd.c | 19 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_netgroup.c | 2 | ||||
-rw-r--r-- | src/responder/pam/pamsrv_cmd.c | 7 |
5 files changed, 21 insertions, 22 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 3b5ab8a42..f6784e916 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -150,6 +150,8 @@ int sss_parse_name(TALLOC_CTX *memctx, int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain, struct be_conn **_conn); +struct sss_domain_info * +responder_get_domain(struct sss_domain_info *doms, const char *domain); /* responder_cmd.c */ int sss_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds); diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 1b28a92ef..99b1a23aa 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -624,6 +624,19 @@ int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain, return EOK; } +struct sss_domain_info * +responder_get_domain(struct sss_domain_info *doms, const char *domain) +{ + struct sss_domain_info *dom; + + for (dom = doms; dom; dom = dom->next) { + if (strcasecmp(dom->name, domain) == 0) break; + } + if (!dom) DEBUG(SSSDBG_CRIT_FAILURE, ("Unknown domain [%s]!\n", domain)); + + return dom; +} + int responder_logrotate(DBusMessage *message, struct sbus_connection *conn) { diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 720813fda..f0270acd2 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -45,19 +45,6 @@ static int nss_cmd_send_error(struct nss_cmd_ctx *cmdctx, int err) return EOK; } -struct sss_domain_info *nss_get_dom(struct sss_domain_info *doms, - const char *domain) -{ - struct sss_domain_info *dom; - - for (dom = doms; dom; dom = dom->next) { - if (strcasecmp(dom->name, domain) == 0) break; - } - if (!dom) DEBUG(2, ("Unknown domain [%s]!\n", domain)); - - return dom; -} - int fill_empty(struct sss_packet *packet) { uint8_t *body; @@ -932,7 +919,7 @@ static int nss_cmd_getpwnam(struct cli_ctx *cctx) cmdctx->name, domname?domname:"<ALL>")); if (domname) { - dctx->domain = nss_get_dom(cctx->rctx->domains, domname); + dctx->domain = responder_get_domain(cctx->rctx->domains, domname); if (!dctx->domain) { ret = ENOENT; goto done; @@ -2219,7 +2206,7 @@ static int nss_cmd_getgrnam(struct cli_ctx *cctx) cmdctx->name, domname?domname:"<ALL>")); if (domname) { - dctx->domain = nss_get_dom(cctx->rctx->domains, domname); + dctx->domain = responder_get_domain(cctx->rctx->domains, domname); if (!dctx->domain) { ret = ENOENT; goto done; @@ -3277,7 +3264,7 @@ static int nss_cmd_initgroups(struct cli_ctx *cctx) cmdctx->name, domname?domname:"<ALL>")); if (domname) { - dctx->domain = nss_get_dom(cctx->rctx->domains, domname); + dctx->domain = responder_get_domain(cctx->rctx->domains, domname); if (!dctx->domain) { ret = ENOENT; goto done; diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c index 189f85248..09b7fa635 100644 --- a/src/responder/nss/nsssrv_netgroup.c +++ b/src/responder/nss/nsssrv_netgroup.c @@ -204,7 +204,7 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx, state->netgr_shortname, domname?domname:"<ALL>")); if (domname) { - dctx->domain = nss_get_dom(client->rctx->domains, domname); + dctx->domain = responder_get_domain(client->rctx->domains, domname); if (!dctx->domain) { goto error; } diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index 40df755d6..5f77697fd 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -756,14 +756,11 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd) /* now check user is valid */ if (pd->domain) { - for (dom = cctx->rctx->domains; dom; dom = dom->next) { - if (strcasecmp(dom->name, pd->domain) == 0) break; - } - if (!dom) { + preq->domain = responder_get_domain(cctx->rctx->domains, pd->domain); + if (preq->domain) { ret = ENOENT; goto done; } - preq->domain = dom; } else { for (dom = preq->cctx->rctx->domains; dom; dom = dom->next) { |