summaryrefslogtreecommitdiff
path: root/src/responder
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-05-29 00:56:18 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-06-07 00:14:13 +0200
commit02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28 (patch)
tree99eba160bfb608f08dc3f38e3524a3badff3ed67 /src/responder
parentc51f7a064b0d7ef86110bdeb6dc09fa6c08be7d3 (diff)
downloadsssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.tar.gz
sssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.tar.bz2
sssd-02d1cb8935d5c9b57cd05dfdbfe6ed38e0d61c28.zip
New utility function sss_get_domain_name
Instead of copying a block of code that checks whether domain is a subdomain and uses only name of FQDN as appropriate, wrap the logic into a function.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/pac/pacsrv_cmd.c23
-rw-r--r--src/responder/pac/pacsrv_utils.c6
2 files changed, 10 insertions, 19 deletions
diff --git a/src/responder/pac/pacsrv_cmd.c b/src/responder/pac/pacsrv_cmd.c
index c3f1115e..3edf0356 100644
--- a/src/responder/pac/pacsrv_cmd.c
+++ b/src/responder/pac/pacsrv_cmd.c
@@ -623,7 +623,7 @@ struct tevent_req *pac_save_memberships_send(struct pac_req_ctx *pr_ctx)
struct sss_domain_info *dom = pr_ctx->dom;
struct tevent_req *req;
errno_t ret;
- char *fq_name = NULL;
+ char *dom_name = NULL;
req = tevent_req_create(pr_ctx, &state, struct pac_save_memberships_state);
if (req == NULL) {
@@ -631,20 +631,15 @@ struct tevent_req *pac_save_memberships_send(struct pac_req_ctx *pr_ctx)
}
state->sid_iter = 0;
- if (IS_SUBDOMAIN(dom)) {
- fq_name = sss_tc_fqname(pr_ctx, pr_ctx->dom->names, pr_ctx->dom,
- pr_ctx->user_name);
- if (fq_name == NULL) {
- DEBUG(SSSDBG_OP_FAILURE, ("talloc_sprintf failed.\n"));
- ret = ENOMEM;
- goto done;
- }
- state->user_dn = sysdb_user_dn(dom->sysdb, state, dom, fq_name);
- } else {
- state->user_dn = sysdb_user_dn(dom->sysdb, state, dom,
- pr_ctx->user_name);
+ dom_name = sss_get_domain_name(state, pr_ctx->user_name, dom);
+ if (dom_name == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("talloc_sprintf failed.\n"));
+ ret = ENOMEM;
+ goto done;
}
+
+ state->user_dn = sysdb_user_dn(dom->sysdb, state, dom, dom_name);
if (state->user_dn == NULL) {
ret = ENOMEM;
goto done;
@@ -664,7 +659,7 @@ struct tevent_req *pac_save_memberships_send(struct pac_req_ctx *pr_ctx)
}
done:
- talloc_free(fq_name);
+ talloc_free(dom_name);
if (ret != EOK && ret != EAGAIN) {
tevent_req_error(req, ret);
tevent_req_post(req, pr_ctx->cctx->ev);
diff --git a/src/responder/pac/pacsrv_utils.c b/src/responder/pac/pacsrv_utils.c
index e7e15ac5..f70438b6 100644
--- a/src/responder/pac/pacsrv_utils.c
+++ b/src/responder/pac/pacsrv_utils.c
@@ -386,11 +386,7 @@ errno_t get_pwd_from_pac(TALLOC_CTX *mem_ctx,
}
/* Subdomain use fully qualified names */
- if (IS_SUBDOMAIN(dom)) {
- pwd->pw_name = sss_tc_fqname(pwd, dom->names, dom, lname);
- } else {
- pwd->pw_name = talloc_strdup(pwd, lname);
- }
+ pwd->pw_name = sss_get_domain_name(pwd, lname, dom);
if (!pwd->pw_name) {
DEBUG(SSSDBG_OP_FAILURE, ("talloc_sprintf failed.\n"));
ret = ENOMEM;