|
|
bf7bd7 |
From fa4b46e7de7297da3c0e37913eab8cba7f103629 Mon Sep 17 00:00:00 2001
|
|
|
bf7bd7 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
bf7bd7 |
Date: Fri, 9 Oct 2020 15:26:39 +0200
|
|
|
bf7bd7 |
Subject: [PATCH 8/8] negcache: do not use default_domain_suffix
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
When splitting the names from the filter_users and filter_groups options
|
|
|
bf7bd7 |
do not use the default_domain_suffix because it will hide that the
|
|
|
bf7bd7 |
original name is a short name and should be added everywhere.
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
Additionally this patch fixes a typo where sss_parse_name() was used
|
|
|
bf7bd7 |
instead of sss_parse_name_for_domains().
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
Resolves: https://github.com/SSSD/sssd/issues/5238
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
bf7bd7 |
---
|
|
|
bf7bd7 |
src/responder/common/negcache.c | 29 +++++++++++++++--------------
|
|
|
bf7bd7 |
src/tests/cmocka/test_negcache.c | 22 ++++++++++++++++++++--
|
|
|
bf7bd7 |
2 files changed, 35 insertions(+), 16 deletions(-)
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c
|
|
|
bf7bd7 |
index 9ee39ce3e..59e8ad7e7 100644
|
|
|
bf7bd7 |
--- a/src/responder/common/negcache.c
|
|
|
bf7bd7 |
+++ b/src/responder/common/negcache.c
|
|
|
bf7bd7 |
@@ -1000,13 +1000,13 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache,
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
for (i = 0; (filter_list && filter_list[i]); i++) {
|
|
|
bf7bd7 |
ret = sss_parse_name_for_domains(tmpctx, domain_list,
|
|
|
bf7bd7 |
- rctx->default_domain,
|
|
|
bf7bd7 |
+ NULL,
|
|
|
bf7bd7 |
filter_list[i],
|
|
|
bf7bd7 |
&domainname, &name);
|
|
|
bf7bd7 |
if (ret == EAGAIN) {
|
|
|
bf7bd7 |
DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
bf7bd7 |
- "cannot add [%s] to negcache because the required or "
|
|
|
bf7bd7 |
- "default domain are not known yet\n", filter_list[i]);
|
|
|
bf7bd7 |
+ "Can add [%s] only as UPN to negcache because the "
|
|
|
bf7bd7 |
+ "required domain is not known yet\n", filter_list[i]);
|
|
|
bf7bd7 |
} else if (ret != EOK) {
|
|
|
bf7bd7 |
DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bf7bd7 |
"Invalid name in filterUsers list: [%s] (%d)\n",
|
|
|
bf7bd7 |
@@ -1066,12 +1066,12 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache,
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
for (i = 0; (filter_list && filter_list[i]); i++) {
|
|
|
bf7bd7 |
ret = sss_parse_name_for_domains(tmpctx, domain_list,
|
|
|
bf7bd7 |
- rctx->default_domain, filter_list[i],
|
|
|
bf7bd7 |
+ NULL, filter_list[i],
|
|
|
bf7bd7 |
&domainname, &name);
|
|
|
bf7bd7 |
if (ret == EAGAIN) {
|
|
|
bf7bd7 |
DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
bf7bd7 |
- "Cannot add [%s] to negcache because the required or "
|
|
|
bf7bd7 |
- "default domain are not known yet\n", filter_list[i]);
|
|
|
bf7bd7 |
+ "Can add [%s] only as UPN to negcache because the "
|
|
|
bf7bd7 |
+ "required domain is not known yet\n", filter_list[i]);
|
|
|
bf7bd7 |
} else if (ret != EOK) {
|
|
|
bf7bd7 |
DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bf7bd7 |
"Invalid name in filterUsers list: [%s] (%d)\n",
|
|
|
bf7bd7 |
@@ -1158,9 +1158,12 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache,
|
|
|
bf7bd7 |
if (ret != EOK) goto done;
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
for (i = 0; (filter_list && filter_list[i]); i++) {
|
|
|
bf7bd7 |
- ret = sss_parse_name(tmpctx, dom->names, filter_list[i],
|
|
|
bf7bd7 |
- &domainname, &name);
|
|
|
bf7bd7 |
+ ret = sss_parse_name_for_domains(tmpctx, domain_list,
|
|
|
bf7bd7 |
+ NULL, filter_list[i],
|
|
|
bf7bd7 |
+ &domainname, &name);
|
|
|
bf7bd7 |
if (ret != EOK) {
|
|
|
bf7bd7 |
+ /* Groups do not have UPNs, so domain names, if present,
|
|
|
bf7bd7 |
+ * must be known */
|
|
|
bf7bd7 |
DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bf7bd7 |
"Invalid name in filterGroups list: [%s] (%d)\n",
|
|
|
bf7bd7 |
filter_list[i], ret);
|
|
|
bf7bd7 |
@@ -1207,13 +1210,11 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache,
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
for (i = 0; (filter_list && filter_list[i]); i++) {
|
|
|
bf7bd7 |
ret = sss_parse_name_for_domains(tmpctx, domain_list,
|
|
|
bf7bd7 |
- rctx->default_domain, filter_list[i],
|
|
|
bf7bd7 |
+ NULL, filter_list[i],
|
|
|
bf7bd7 |
&domainname, &name);
|
|
|
bf7bd7 |
- if (ret == EAGAIN) {
|
|
|
bf7bd7 |
- DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
bf7bd7 |
- "Cannot add [%s] to negcache because the required or "
|
|
|
bf7bd7 |
- "default domain are not known yet\n", filter_list[i]);
|
|
|
bf7bd7 |
- } else if (ret != EOK) {
|
|
|
bf7bd7 |
+ if (ret != EOK) {
|
|
|
bf7bd7 |
+ /* Groups do not have UPNs, so domain names, if present,
|
|
|
bf7bd7 |
+ * must be known */
|
|
|
bf7bd7 |
DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
bf7bd7 |
"Invalid name in filterGroups list: [%s] (%d)\n",
|
|
|
bf7bd7 |
filter_list[i], ret);
|
|
|
bf7bd7 |
diff --git a/src/tests/cmocka/test_negcache.c b/src/tests/cmocka/test_negcache.c
|
|
|
bf7bd7 |
index fb306b110..30218d52a 100644
|
|
|
bf7bd7 |
--- a/src/tests/cmocka/test_negcache.c
|
|
|
bf7bd7 |
+++ b/src/tests/cmocka/test_negcache.c
|
|
|
bf7bd7 |
@@ -933,7 +933,9 @@ static void test_sss_ncache_reset_prepopulate(void **state)
|
|
|
bf7bd7 |
*
|
|
|
bf7bd7 |
* The result should of course be independent of the present domains. To
|
|
|
bf7bd7 |
* verify this the domains are added one after the other and the negative
|
|
|
bf7bd7 |
- * cache is repopulated each time.
|
|
|
bf7bd7 |
+ * cache is repopulated each time. The result should be also independent of
|
|
|
bf7bd7 |
+ * the setting of default_domain_suffix option which is tested by
|
|
|
bf7bd7 |
+ * test_sss_ncache_short_name_in_domain_with_prefix.
|
|
|
bf7bd7 |
*
|
|
|
bf7bd7 |
* With the given domains, users and group we have to following expectations:
|
|
|
bf7bd7 |
* - the short name entry will be added to the domain and all sub-domains as
|
|
|
bf7bd7 |
@@ -1081,7 +1083,8 @@ static void expect_no_entries_in_dom(struct sss_nc_ctx *ncache,
|
|
|
bf7bd7 |
assert_int_equal(ret, ENOENT);
|
|
|
bf7bd7 |
}
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
-static void test_sss_ncache_short_name_in_domain(void **state)
|
|
|
bf7bd7 |
+static void run_sss_ncache_short_name_in_domain(void **state,
|
|
|
bf7bd7 |
+ bool use_default_domain_prefix)
|
|
|
bf7bd7 |
{
|
|
|
bf7bd7 |
int ret;
|
|
|
bf7bd7 |
struct test_state *ts;
|
|
|
bf7bd7 |
@@ -1131,6 +1134,9 @@ static void test_sss_ncache_short_name_in_domain(void **state)
|
|
|
bf7bd7 |
ncache = ts->ctx;
|
|
|
bf7bd7 |
ts->rctx = mock_rctx(ts, ev, dom, ts->nctx);
|
|
|
bf7bd7 |
assert_non_null(ts->rctx);
|
|
|
bf7bd7 |
+ if (use_default_domain_prefix) {
|
|
|
bf7bd7 |
+ ts->rctx->default_domain = discard_const(TEST_DOM_NAME);
|
|
|
bf7bd7 |
+ }
|
|
|
bf7bd7 |
ts->rctx->cdb = tc->confdb;
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
ret = sss_names_init(ts, tc->confdb, TEST_DOM_NAME, &dom->names);
|
|
|
bf7bd7 |
@@ -1173,6 +1179,16 @@ static void test_sss_ncache_short_name_in_domain(void **state)
|
|
|
bf7bd7 |
expect_no_entries_in_dom(ncache, dom2);
|
|
|
bf7bd7 |
}
|
|
|
bf7bd7 |
|
|
|
bf7bd7 |
+static void test_sss_ncache_short_name_in_domain(void **state)
|
|
|
bf7bd7 |
+{
|
|
|
bf7bd7 |
+ run_sss_ncache_short_name_in_domain(state, false);
|
|
|
bf7bd7 |
+}
|
|
|
bf7bd7 |
+
|
|
|
bf7bd7 |
+static void test_sss_ncache_short_name_in_domain_with_prefix(void **state)
|
|
|
bf7bd7 |
+{
|
|
|
bf7bd7 |
+ run_sss_ncache_short_name_in_domain(state, true);
|
|
|
bf7bd7 |
+}
|
|
|
bf7bd7 |
+
|
|
|
bf7bd7 |
static void test_sss_ncache_reset(void **state)
|
|
|
bf7bd7 |
{
|
|
|
bf7bd7 |
errno_t ret;
|
|
|
bf7bd7 |
@@ -1337,6 +1353,8 @@ int main(void)
|
|
|
bf7bd7 |
setup, teardown),
|
|
|
bf7bd7 |
cmocka_unit_test_setup_teardown(test_sss_ncache_short_name_in_domain,
|
|
|
bf7bd7 |
setup, teardown),
|
|
|
bf7bd7 |
+ cmocka_unit_test_setup_teardown(test_sss_ncache_short_name_in_domain_with_prefix,
|
|
|
bf7bd7 |
+ setup, teardown),
|
|
|
bf7bd7 |
cmocka_unit_test_setup_teardown(test_sss_ncache_reset,
|
|
|
bf7bd7 |
setup, teardown),
|
|
|
bf7bd7 |
cmocka_unit_test_setup_teardown(test_sss_ncache_locate_uid_gid,
|
|
|
bf7bd7 |
--
|
|
|
bf7bd7 |
2.21.3
|
|
|
bf7bd7 |
|