diff options
-rw-r--r-- | src/providers/simple/simple_access.c | 17 | ||||
-rw-r--r-- | src/util/sss_utf8.c | 9 | ||||
-rw-r--r-- | src/util/util.h | 1 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/providers/simple/simple_access.c b/src/providers/simple/simple_access.c index 06662e9d..e00079cd 100644 --- a/src/providers/simple/simple_access.c +++ b/src/providers/simple/simple_access.c @@ -35,15 +35,6 @@ #define CONFDB_SIMPLE_ALLOW_GROUPS "simple_allow_groups" #define CONFDB_SIMPLE_DENY_GROUPS "simple_deny_groups" -static bool string_equal(bool cs, const char *s1, const char *s2) -{ - if (cs) { - return strcmp(s1, s2) == 0; - } - - return sss_utf8_case_eq((const uint8_t *)s1, (const uint8_t *)s2) == EOK; -} - errno_t simple_access_check(struct simple_ctx *ctx, const char *username, bool *access_granted) { @@ -68,7 +59,7 @@ errno_t simple_access_check(struct simple_ctx *ctx, const char *username, /* First, check whether the user is in the allowed users list */ if (ctx->allow_users != NULL) { for(i = 0; ctx->allow_users[i] != NULL; i++) { - if (string_equal(cs, username, ctx->allow_users[i])) { + if (sss_string_equal(cs, username, ctx->allow_users[i])) { DEBUG(9, ("User [%s] found in allow list, access granted.\n", username)); @@ -89,7 +80,7 @@ errno_t simple_access_check(struct simple_ctx *ctx, const char *username, /* Next check whether this user has been specifically denied */ if (ctx->deny_users != NULL) { for(i = 0; ctx->deny_users[i] != NULL; i++) { - if (string_equal(cs, username, ctx->deny_users[i])) { + if (sss_string_equal(cs, username, ctx->deny_users[i])) { DEBUG(9, ("User [%s] found in deny list, access denied.\n", username)); @@ -200,7 +191,7 @@ errno_t simple_access_check(struct simple_ctx *ctx, const char *username, matched = false; for (i = 0; ctx->allow_groups[i]; i++) { for(j = 0; groups[j]; j++) { - if (string_equal(cs, groups[j], ctx->allow_groups[i])) { + if (sss_string_equal(cs, groups[j], ctx->allow_groups[i])) { matched = true; break; } @@ -221,7 +212,7 @@ errno_t simple_access_check(struct simple_ctx *ctx, const char *username, matched = false; for (i = 0; ctx->deny_groups[i]; i++) { for(j = 0; groups[j]; j++) { - if (string_equal(cs, groups[j], ctx->deny_groups[i])) { + if (sss_string_equal(cs, groups[j], ctx->deny_groups[i])) { matched = true; break; } diff --git a/src/util/sss_utf8.c b/src/util/sss_utf8.c index 7997a6df..27c5cb60 100644 --- a/src/util/sss_utf8.c +++ b/src/util/sss_utf8.c @@ -171,3 +171,12 @@ errno_t sss_utf8_case_eq(const uint8_t *s1, const uint8_t *s2) #else #error No unicode library #endif + +bool sss_string_equal(bool cs, const char *s1, const char *s2) +{ + if (cs) { + return strcmp(s1, s2) == 0; + } + + return sss_utf8_case_eq((const uint8_t *)s1, (const uint8_t *)s2) == EOK; +} diff --git a/src/util/util.h b/src/util/util.h index 7eb62a9b..985c7898 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -516,6 +516,7 @@ char * sss_tc_utf8_str_tolower(TALLOC_CTX *mem_ctx, const char *s); uint8_t * sss_tc_utf8_tolower(TALLOC_CTX *mem_ctx, const uint8_t *s, size_t len, size_t *_nlen); +bool sss_string_equal(bool cs, const char *s1, const char *s2); /* len includes terminating '\0' */ struct sized_string { |