640e44ca24
- Resolves: rhbz#1375552 - krb5_map_user doesn't seem effective anymore - Resolves: rhbz#1349286 - authconfig fails with SSSDConfig.NoDomainError: default if nonexistent domain is mentioned
126 lines
5.2 KiB
Diff
126 lines
5.2 KiB
Diff
From 3e8165ff6c5251809beb8f8e11ffd45f8bfd69ca Mon Sep 17 00:00:00 2001
|
|
From: Lukas Slebodnik <lslebodn@redhat.com>
|
|
Date: Wed, 21 Sep 2016 13:56:43 +0200
|
|
Subject: [PATCH 77/79] SSSDConfig: Do not fail with nonexisting
|
|
domains/services
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
dict.keys() returns iterator in python3 and not list
|
|
Chaging data in dictionary while using iterator
|
|
fails with "RuntimeError: dictionary changed size during iteration"
|
|
|
|
https://fedorahosted.org/sssd/ticket/3107
|
|
|
|
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
(cherry picked from commit 1773fdad2730f3f910782781fa286f402ce36cca)
|
|
---
|
|
Makefile.am | 1 +
|
|
src/config/SSSDConfig/__init__.py.in | 4 +--
|
|
src/config/SSSDConfigTest.py | 33 ++++++++++++++++++++++
|
|
.../sssd-nonexisting-services-domains.conf | 13 +++++++++
|
|
4 files changed, 49 insertions(+), 2 deletions(-)
|
|
create mode 100644 src/config/testconfigs/sssd-nonexisting-services-domains.conf
|
|
|
|
diff --git a/Makefile.am b/Makefile.am
|
|
index 17c5f26ce9db1e183b30178f1a8714deca1dab03..4385268b21b2de2054d3958f98f28f5ea7cfa191 100644
|
|
--- a/Makefile.am
|
|
+++ b/Makefile.am
|
|
@@ -422,6 +422,7 @@ dist_noinst_DATA = \
|
|
src/config/testconfigs/sssd-badversion.conf \
|
|
src/config/testconfigs/sssd-invalid.conf \
|
|
src/config/testconfigs/sssd-invalid-badbool.conf \
|
|
+ src/config/testconfigs/sssd-nonexisting-services-domains.conf \
|
|
src/config/etc/sssd.api.d/crash_test_dummy \
|
|
contrib/ci/README.md \
|
|
contrib/ci/configure.sh \
|
|
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
|
|
index 0acb751e234ee0c3e6fee332a2ba22f9ac353221..e616ce3dcc7357280418e9abd0bcdeb370b861e6 100644
|
|
--- a/src/config/SSSDConfig/__init__.py.in
|
|
+++ b/src/config/SSSDConfig/__init__.py.in
|
|
@@ -1511,7 +1511,7 @@ class SSSDConfig(SSSDChangeConf):
|
|
# Remove any entries in this list that don't
|
|
# correspond to an active service, for integrity
|
|
configured_services = self.list_services()
|
|
- for srv in service_dict.keys():
|
|
+ for srv in list(service_dict):
|
|
if srv not in configured_services:
|
|
del service_dict[srv]
|
|
|
|
@@ -1794,7 +1794,7 @@ class SSSDConfig(SSSDChangeConf):
|
|
# Remove any entries in this list that don't
|
|
# correspond to an active domain, for integrity
|
|
configured_domains = self.list_domains()
|
|
- for dom in domain_dict.keys():
|
|
+ for dom in list(domain_dict):
|
|
if dom not in configured_domains:
|
|
del domain_dict[dom]
|
|
|
|
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
|
|
index 8a64a257ab978b81ae4b26918c683b25a30fe7c1..006a034477dd64e3c5a0b2dbd1554bdc1b2635b4 100755
|
|
--- a/src/config/SSSDConfigTest.py
|
|
+++ b/src/config/SSSDConfigTest.py
|
|
@@ -1683,6 +1683,39 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase):
|
|
"Domain [%s] unexpectedly found" %
|
|
domain)
|
|
|
|
+ def testListWithInvalidDomain(self):
|
|
+ sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
|
|
+ srcdir + "/etc/sssd.api.d")
|
|
+
|
|
+ # Negative Test - Not Initialized
|
|
+ self.assertRaises(SSSDConfig.NotInitializedError,
|
|
+ sssdconfig.list_domains)
|
|
+
|
|
+ # Positive Test
|
|
+ sssdconfig.import_config(
|
|
+ srcdir + '/testconfigs/sssd-nonexisting-services-domains.conf'
|
|
+ )
|
|
+
|
|
+ domains = sssdconfig.list_active_domains()
|
|
+ self.assertTrue("active" in domains and len(domains) == 1,
|
|
+ "domain 'active' not found among active domains")
|
|
+
|
|
+ domains = sssdconfig.list_inactive_domains()
|
|
+ self.assertTrue("inactive" in domains and len(domains) == 1,
|
|
+ "domain 'inactive' not found among inactive domains")
|
|
+
|
|
+ services = sssdconfig.list_active_services()
|
|
+ self.assertTrue("nss" in services and len(services) == 1,
|
|
+ "service 'nss' not found among active services")
|
|
+
|
|
+ services = sssdconfig.list_inactive_services()
|
|
+ self.assertTrue(len(services) == 2,
|
|
+ "unexpected count of inactive services")
|
|
+ for service in ("sssd", "pam"):
|
|
+ self.assertTrue(service in services,
|
|
+ "service '%s' not found among inactive services"
|
|
+ % service)
|
|
+
|
|
def testGetDomain(self):
|
|
sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf",
|
|
srcdir + "/etc/sssd.api.d")
|
|
diff --git a/src/config/testconfigs/sssd-nonexisting-services-domains.conf b/src/config/testconfigs/sssd-nonexisting-services-domains.conf
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..d1e248001e76c65fa667d55f469e15aa5696faed
|
|
--- /dev/null
|
|
+++ b/src/config/testconfigs/sssd-nonexisting-services-domains.conf
|
|
@@ -0,0 +1,13 @@
|
|
+[domain/active]
|
|
+
|
|
+[domain/inactive]
|
|
+
|
|
+[sssd]
|
|
+domains = nonexistent, active
|
|
+services = nonexistent, nss
|
|
+
|
|
+[nss]
|
|
+debug_level = 1
|
|
+
|
|
+[pam]
|
|
+debug_level = 2
|
|
--
|
|
2.9.3
|
|
|