diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-12-21 18:00:25 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-12-21 14:47:41 -0500 |
commit | c7d387aaaa3d3470dec55a5ca0612873e6354ba8 (patch) | |
tree | b78851a84b37efc43b994fa5c45a03fa654ddbed /src | |
parent | 6f52db9c8b1081565ffa0543f8c8b470b8375932 (diff) | |
download | sssd-c7d387aaaa3d3470dec55a5ca0612873e6354ba8.tar.gz sssd-c7d387aaaa3d3470dec55a5ca0612873e6354ba8.tar.xz sssd-c7d387aaaa3d3470dec55a5ca0612873e6354ba8.zip |
sss_get_cased_name utility function
Diffstat (limited to 'src')
-rw-r--r-- | src/responder/nss/nsssrv_cmd.c | 9 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_netgroup.c | 9 | ||||
-rw-r--r-- | src/responder/pam/pamsrv_cmd.c | 4 | ||||
-rw-r--r-- | src/util/usertools.c | 9 | ||||
-rw-r--r-- | src/util/util.h | 4 |
5 files changed, 24 insertions, 11 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 0bd2f75ee..71c949f1d 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -741,8 +741,7 @@ static int nss_cmd_getpwnam_search(struct nss_dom_ctx *dctx) dctx->domain = dom; talloc_free(name); - name = dom->case_sensitive ? talloc_strdup(dctx, cmdctx->name) : - sss_tc_utf8_str_tolower(dctx, cmdctx->name); + name = sss_get_cased_name(dctx, cmdctx->name, dom->case_sensitive); if (!name) return ENOMEM; /* verify this user has not yet been negatively cached, @@ -2033,8 +2032,7 @@ static int nss_cmd_getgrnam_search(struct nss_dom_ctx *dctx) dctx->domain = dom; talloc_free(name); - name = dom->case_sensitive ? talloc_strdup(dctx, cmdctx->name) : - sss_tc_utf8_str_tolower(dctx, cmdctx->name); + name = sss_get_cased_name(dctx, cmdctx->name, dom->case_sensitive); if (!name) return ENOMEM; /* verify this group has not yet been negatively cached, @@ -3104,8 +3102,7 @@ static int nss_cmd_initgroups_search(struct nss_dom_ctx *dctx) dctx->domain = dom; talloc_free(name); - name = dom->case_sensitive ? talloc_strdup(dctx, cmdctx->name) : - sss_tc_utf8_str_tolower(dctx, cmdctx->name); + name = sss_get_cased_name(dctx, cmdctx->name, dom->case_sensitive); if (!name) return ENOMEM; /* verify this user has not yet been negatively cached, diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c index 39ba4ff7a..1b089f719 100644 --- a/src/responder/nss/nsssrv_netgroup.c +++ b/src/responder/nss/nsssrv_netgroup.c @@ -402,9 +402,12 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx) step_ctx->dctx->domain = dom; talloc_free(name); - name = dom->case_sensitive ? \ - talloc_strdup(step_ctx, step_ctx->name) : - sss_tc_utf8_str_tolower(step_ctx, step_ctx->name); + name = sss_get_cased_name(step_ctx, step_ctx->name, + dom->case_sensitive); + if (!name) { + DEBUG(SSSDBG_CRIT_FAILURE, ("sss_get_cased_name failed\n")); + return ENOMEM; + } DEBUG(4, ("Requesting info for [%s@%s]\n", name, dom->name)); diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index ced9df063..3b2d509e2 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -859,8 +859,8 @@ static int pam_check_user_search(struct pam_auth_req *preq) preq->domain = dom; talloc_free(name); - name = dom->case_sensitive ? talloc_strdup(preq, preq->pd->user) : - sss_tc_utf8_str_tolower(preq, preq->pd->user); + name = sss_get_cased_name(preq, preq->pd->user, + dom->case_sensitive); if (!name) { return ENOMEM; } diff --git a/src/util/usertools.c b/src/util/usertools.c index 738ac62d7..64e8b1037 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -173,3 +173,12 @@ int sss_parse_name(TALLOC_CTX *memctx, return EOK; } + +char * +sss_get_cased_name(TALLOC_CTX *mem_ctx, + const char *orig_name, + bool case_sensitive) +{ + return case_sensitive ? talloc_strdup(mem_ctx, orig_name) : + sss_tc_utf8_str_tolower(mem_ctx, orig_name); +} diff --git a/src/util/util.h b/src/util/util.h index 4ff112b75..5428f0af6 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -401,6 +401,10 @@ int sss_parse_name(TALLOC_CTX *memctx, struct sss_names_ctx *snctx, const char *orig, char **domain, char **name); +char * +sss_get_cased_name(TALLOC_CTX *mem_ctx, const char *orig_name, + bool case_sensitive); + /* from backup-file.c */ int backup_file(const char *src, int dbglvl); |