summaryrefslogtreecommitdiffstats
path: root/src/responder/common
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2015-10-06 15:07:48 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-10-08 19:56:31 +0200
commit2fce47f2dadd10d2a2c8bf9f03ab7094bc6c6b3a (patch)
treebe357c2ebf3bf83bcd3f7e4bb08845d186f4a5c3 /src/responder/common
parent3688374991afb34bbaf2b7843683fc13dd77879d (diff)
downloadsssd-2fce47f2dadd10d2a2c8bf9f03ab7094bc6c6b3a.tar.gz
sssd-2fce47f2dadd10d2a2c8bf9f03ab7094bc6c6b3a.tar.xz
sssd-2fce47f2dadd10d2a2c8bf9f03ab7094bc6c6b3a.zip
cache_req: remove raw_name and do not touch orig_name
Parsed name or UPN is now stored in input->name instead of touching orig_name and storing the original name in raw_name. Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src/responder/common')
-rw-r--r--src/responder/common/responder_cache_req.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/responder/common/responder_cache_req.c b/src/responder/common/responder_cache_req.c
index 70a3010eb..be7fe5f29 100644
--- a/src/responder/common/responder_cache_req.c
+++ b/src/responder/common/responder_cache_req.c
@@ -70,11 +70,13 @@ struct cache_req_input {
enum cache_req_type type;
/* Provided input. */
- const char *raw_name;
const char *orig_name;
uint32_t id;
const char *cert;
+ /* Parsed name or UPN. */
+ const char *name;
+
/* Data Provider request type resolved from @type.
* FIXME: This is currently needed for data provider calls. We should
* refactor responder_dp.c to get rid of this member. */
@@ -125,11 +127,6 @@ cache_req_input_create(TALLOC_CTX *mem_ctx,
goto fail;
}
- input->raw_name = talloc_strdup(input, name);
- if (input->raw_name == NULL) {
- goto fail;
- }
-
input->orig_name = talloc_strdup(input, name);
if (input->orig_name == NULL) {
goto fail;
@@ -196,8 +193,8 @@ fail:
}
static errno_t
-cache_req_input_set_orig_name(struct cache_req_input *input,
- const char *name)
+cache_req_input_set_name(struct cache_req_input *input,
+ const char *name)
{
const char *dup;
@@ -206,8 +203,8 @@ cache_req_input_set_orig_name(struct cache_req_input *input,
return ENOMEM;
}
- talloc_zfree(input->orig_name);
- input->orig_name = dup;
+ talloc_zfree(input->name);
+ input->name = dup;
return EOK;
}
@@ -238,8 +235,13 @@ cache_req_input_set_domain(struct cache_req_input *input,
case CACHE_REQ_GROUP_BY_FILTER:
case CACHE_REQ_INITGROUPS:
case CACHE_REQ_INITGROUPS_BY_UPN:
- name = sss_get_cased_name(tmp_ctx, input->orig_name,
- domain->case_sensitive);
+ if (input->name == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "Bug: input->name is NULL?\n");
+ ret = ERR_INTERNAL;
+ goto done;
+ }
+
+ name = sss_get_cased_name(tmp_ctx, input->name, domain->case_sensitive);
if (name == NULL) {
ret = ENOMEM;
goto done;
@@ -316,7 +318,7 @@ cache_req_input_assume_upn(struct cache_req_input *input)
errno_t ret;
bool bret;
- if (input->raw_name == NULL || strchr(input->raw_name, '@') == NULL) {
+ if (input->orig_name == NULL || strchr(input->orig_name, '@') == NULL) {
return false;
}
@@ -335,14 +337,14 @@ cache_req_input_assume_upn(struct cache_req_input *input)
}
if (bret == true) {
- ret = cache_req_input_set_orig_name(input, input->raw_name);
+ ret = cache_req_input_set_name(input, input->orig_name);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"cache_req_input_set_orig_name() failed\n");
return false;
}
- DEBUG(SSSDBG_TRACE_FUNC, "Assuming UPN %s\n", input->raw_name);
+ DEBUG(SSSDBG_TRACE_FUNC, "Assuming UPN %s\n", input->orig_name);
}
return bret;
@@ -875,6 +877,13 @@ struct tevent_req *cache_req_send(TALLOC_CTX *mem_ctx,
tevent_req_set_callback(subreq, cache_req_input_parsed, req);
} else {
+ if (input->orig_name != NULL) {
+ ret = cache_req_input_set_name(input, input->orig_name);
+ if (ret != EOK) {
+ goto immediately;
+ }
+ }
+
ret = cache_req_select_domains(req, domain);
if (ret != EAGAIN) {
goto immediately;
@@ -909,13 +918,10 @@ static void cache_req_input_parsed(struct tevent_req *subreq)
ret = sss_parse_inp_recv(subreq, state, &name, &domain);
switch (ret) {
case EOK:
- if (strcmp(name, state->input->orig_name) != 0) {
- /* The name has changed during input parse phase. */
- ret = cache_req_input_set_orig_name(state->input, name);
- if (ret != EOK) {
- tevent_req_error(req, ret);
- return;
- }
+ ret = cache_req_input_set_name(state->input, name);
+ if (ret != EOK) {
+ tevent_req_error(req, ret);
+ return;
}
break;
case ERR_DOMAIN_NOT_FOUND:
@@ -1070,7 +1076,7 @@ errno_t cache_req_recv(TALLOC_CTX *mem_ctx,
if (state->input->dom_objname == NULL) {
*_name = NULL;
} else {
- name = talloc_strdup(mem_ctx, state->input->orig_name);
+ name = talloc_strdup(mem_ctx, state->input->name);
if (name == NULL) {
return ENOMEM;
}