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