|
|
0048be |
From 2d9286102f23ea9d13213f1176ba669b9315a75f Mon Sep 17 00:00:00 2001
|
|
|
0048be |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
0048be |
Date: Thu, 6 Sep 2018 13:38:56 +0200
|
|
|
0048be |
Subject: [PATCH] sudo: respect case sensitivity in sudo responder
|
|
|
0048be |
MIME-Version: 1.0
|
|
|
0048be |
Content-Type: text/plain; charset=UTF-8
|
|
|
0048be |
Content-Transfer-Encoding: 8bit
|
|
|
0048be |
|
|
|
0048be |
If the domain is not case sensitive and the case of the original user
|
|
|
0048be |
or group name differs from the name in the rule we failed to find the
|
|
|
0048be |
rule.
|
|
|
0048be |
|
|
|
0048be |
Now we filter the rule only with lower cased values in such domain.
|
|
|
0048be |
|
|
|
0048be |
Steps to reproduce:
|
|
|
0048be |
1. Add user/group with upper case, e.g. USER-1
|
|
|
0048be |
2. Add sudo rule with lower cased name, e.g. sudoUser: user-1
|
|
|
0048be |
3. Login to system with lower case, e.g. user-1
|
|
|
0048be |
4. Run sudo -l
|
|
|
0048be |
|
|
|
0048be |
Without the patch, rule is not found.
|
|
|
0048be |
|
|
|
0048be |
Resolves:
|
|
|
0048be |
https://pagure.io/SSSD/sssd/issue/3820
|
|
|
0048be |
|
|
|
0048be |
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
|
0048be |
(cherry picked from commit d7f0b58e2896ed2ef9ed5a390815c1e4df6caaee)
|
|
|
0048be |
---
|
|
|
0048be |
src/db/sysdb_sudo.c | 17 ++++++++++++++---
|
|
|
0048be |
1 file changed, 14 insertions(+), 3 deletions(-)
|
|
|
0048be |
|
|
|
0048be |
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
|
|
|
0048be |
index 3ad462d8f..19ed97b86 100644
|
|
|
0048be |
--- a/src/db/sysdb_sudo.c
|
|
|
0048be |
+++ b/src/db/sysdb_sudo.c
|
|
|
0048be |
@@ -418,7 +418,17 @@ sysdb_get_sudo_user_info(TALLOC_CTX *mem_ctx,
|
|
|
0048be |
ret = EINVAL;
|
|
|
0048be |
goto done;
|
|
|
0048be |
}
|
|
|
0048be |
- DEBUG(SSSDBG_TRACE_FUNC, "original name: %s\n", orig_name);
|
|
|
0048be |
+
|
|
|
0048be |
+ DEBUG(SSSDBG_TRACE_FUNC, "Original name: %s\n", orig_name);
|
|
|
0048be |
+
|
|
|
0048be |
+ orig_name = sss_get_cased_name(tmp_ctx, orig_name, domain->case_sensitive);
|
|
|
0048be |
+ if (orig_name == NULL) {
|
|
|
0048be |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory!\n");
|
|
|
0048be |
+ ret = ENOMEM;
|
|
|
0048be |
+ goto done;
|
|
|
0048be |
+ }
|
|
|
0048be |
+
|
|
|
0048be |
+ DEBUG(SSSDBG_TRACE_FUNC, "Cased name: %s\n", orig_name);
|
|
|
0048be |
|
|
|
0048be |
if (_uid != NULL) {
|
|
|
0048be |
uid = ldb_msg_find_attr_as_uint64(res->msgs[0], SYSDB_UIDNUM, 0);
|
|
|
0048be |
@@ -450,8 +460,9 @@ sysdb_get_sudo_user_info(TALLOC_CTX *mem_ctx,
|
|
|
0048be |
continue;
|
|
|
0048be |
}
|
|
|
0048be |
|
|
|
0048be |
- sysdb_groupnames[num_groups] = talloc_strdup(sysdb_groupnames,
|
|
|
0048be |
- groupname);
|
|
|
0048be |
+ sysdb_groupnames[num_groups] = \
|
|
|
0048be |
+ sss_get_cased_name(sysdb_groupnames, groupname,
|
|
|
0048be |
+ domain->case_sensitive);
|
|
|
0048be |
if (sysdb_groupnames[num_groups] == NULL) {
|
|
|
0048be |
DEBUG(SSSDBG_MINOR_FAILURE, "Cannot strdup %s\n", groupname);
|
|
|
0048be |
continue;
|
|
|
0048be |
--
|
|
|
0048be |
2.19.1
|
|
|
0048be |
|