summaryrefslogtreecommitdiff
path: root/src/responder
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-12-05 16:00:44 +0100
committerStephen Gallagher <sgallagh@redhat.com>2011-12-16 14:46:16 -0500
commit247a7056af42fc50bbc896cddb66a60154ca12e9 (patch)
treebd19e4874f9ebd1f441f414851ba71aa72f550c5 /src/responder
parentdbea04f585a30d001b574317c068cd03a4fa332b (diff)
downloadsssd-247a7056af42fc50bbc896cddb66a60154ca12e9.tar.gz
sssd-247a7056af42fc50bbc896cddb66a60154ca12e9.tar.bz2
sssd-247a7056af42fc50bbc896cddb66a60154ca12e9.zip
Responders: Split getting domain by name into separate function
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/common/responder.h2
-rw-r--r--src/responder/common/responder_common.c13
-rw-r--r--src/responder/nss/nsssrv_cmd.c19
-rw-r--r--src/responder/nss/nsssrv_netgroup.c2
-rw-r--r--src/responder/pam/pamsrv_cmd.c7
5 files changed, 21 insertions, 22 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 3b5ab8a4..f6784e91 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 1b28a92e..99b1a23a 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 720813fd..f0270acd 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 189f8524..09b7fa63 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 40df755d..5f77697f 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) {