diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-03-22 16:49:12 +0100 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-03-30 08:15:34 -0400 |
commit | 3b90d7fc44d93596322ab2d073e935a144721535 (patch) | |
tree | e0b6fd3bf132910325fa622a12bf706785884faa /src/util/usertools.c | |
parent | 99dfc685fbc6f8b06b8becb45264afe7b76b057f (diff) | |
download | sssd-3b90d7fc44d93596322ab2d073e935a144721535.tar.gz sssd-3b90d7fc44d93596322ab2d073e935a144721535.tar.xz sssd-3b90d7fc44d93596322ab2d073e935a144721535.zip |
Support lookup of services with case-insensitive protocol
Add sss_get_cased_name_list utility function
LDAP services: Save lowercased protocol names in case-insensitive domains
https://fedorahosted.org/sssd/ticket/1260
Proxy services: Save lowercased protocol names and aliases in case-insensitive domains
Diffstat (limited to 'src/util/usertools.c')
-rw-r--r-- | src/util/usertools.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/util/usertools.c b/src/util/usertools.c index 64e8b1037..ff189e32f 100644 --- a/src/util/usertools.c +++ b/src/util/usertools.c @@ -182,3 +182,40 @@ sss_get_cased_name(TALLOC_CTX *mem_ctx, return case_sensitive ? talloc_strdup(mem_ctx, orig_name) : sss_tc_utf8_str_tolower(mem_ctx, orig_name); } + +errno_t +sss_get_cased_name_list(TALLOC_CTX *mem_ctx, const char * const *orig, + bool case_sensitive, const char ***_cased) +{ + const char **out; + size_t num, i; + + if (orig == NULL) { + *_cased = NULL; + return EOK; + } + + for (num=0; orig[num]; num++); /* count the num of strings */ + + if (num == 0) { + *_cased = NULL; + return EOK; + } + + out = talloc_array(mem_ctx, const char *, num + 1); + if (out == NULL) { + return ENOMEM; + } + + for (i = 0; i < num; i++) { + out[i] = sss_get_cased_name(out, orig[i], case_sensitive); + if (out[i] == NULL) { + talloc_free(out); + return ENOMEM; + } + } + + out[num] = NULL; + *_cased = out; + return EOK; +} |