summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2017-02-05 20:25:23 +0100
committerJakub Hrozek <jhrozek@redhat.com>2017-02-10 16:55:04 +0100
commita5ecc93abb01cece628fdef04ebad43bba267419 (patch)
tree1edeb70559484f6f6ede6e26c397b457c65651f8 /src/db
parent00c0b7bc6969d31deab9e8e7541b4a6483b78b3e (diff)
downloadsssd-a5ecc93abb01cece628fdef04ebad43bba267419.tar.gz
sssd-a5ecc93abb01cece628fdef04ebad43bba267419.tar.xz
sssd-a5ecc93abb01cece628fdef04ebad43bba267419.zip
SUDO: Only store lowercased attribute value once
The current code doesn't handle the situation where lowercasing the sudoUser attribute would yield the same value again. For example: sudoUser: TUSER sudoUser tuser would break. This patch switches to using the utility function sysdb_attrs_add_lower_case_string() which already checks for duplicates. Resolves: https://fedorahosted.org/sssd/ticket/3301 Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb_sudo.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
index f5160f190..97a1bee99 100644
--- a/src/db/sysdb_sudo.c
+++ b/src/db/sysdb_sudo.c
@@ -857,7 +857,6 @@ static errno_t sysdb_sudo_add_lowered_users(struct sss_domain_info *domain,
{
TALLOC_CTX *tmp_ctx;
const char **users = NULL;
- const char *lowered = NULL;
errno_t ret;
if (domain->case_sensitive == true || rule == NULL) {
@@ -884,19 +883,9 @@ static errno_t sysdb_sudo_add_lowered_users(struct sss_domain_info *domain,
}
for (int i = 0; users[i] != NULL; i++) {
- lowered = sss_tc_utf8_str_tolower(tmp_ctx, users[i]);
- if (lowered == NULL) {
- DEBUG(SSSDBG_OP_FAILURE, "Cannot convert name to lowercase.\n");
- ret = ENOMEM;
- goto done;
- }
-
- if (strcmp(users[i], lowered) == 0) {
- /* It protects us from adding duplicate. */
- continue;
- }
-
- ret = sysdb_attrs_add_string(rule, SYSDB_SUDO_CACHE_AT_USER, lowered);
+ ret = sysdb_attrs_add_lower_case_string(rule, true,
+ SYSDB_SUDO_CACHE_AT_USER,
+ users[i]);
if (ret != EOK) {
DEBUG(SSSDBG_OP_FAILURE,
"Unable to add %s attribute [%d]: %s\n",