From 9e88e38f2fa4e6b752ac87392b8af8db03a2b82a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 7 Dec 2009 21:17:20 +0100 Subject: Handle spaces in config parser Fixes: #301 --- server/config/SSSDConfigTest.py | 8 ++++++++ server/config/ipachangeconf.py | 33 +++++++++++++++++++++++++++++++ server/config/testconfigs/sssd-valid.conf | 4 ++-- 3 files changed, 43 insertions(+), 2 deletions(-) (limited to 'server') diff --git a/server/config/SSSDConfigTest.py b/server/config/SSSDConfigTest.py index aca1fbd4..ac37aec9 100644 --- a/server/config/SSSDConfigTest.py +++ b/server/config/SSSDConfigTest.py @@ -149,6 +149,14 @@ class SSSDConfigTestValid(unittest.TestCase): sssdconfig.write('/tmp/testModifyExistingConfig.conf') + def testSpaces(self): + sssdconfig = SSSDConfig.SSSDConfig("etc/sssd.api.conf", + "etc/sssd.api.d") + sssdconfig.import_config("testconfigs/sssd-valid.conf") + ldap_domain = sssdconfig.get_domain('LDAP') + self.assertEqual(ldap_domain.get_option('auth_provider'), 'ldap') + self.assertEqual(ldap_domain.get_option('id_provider'), 'ldap') + class SSSDConfigTestSSSDService(unittest.TestCase): def setUp(self): self.schema = SSSDConfig.SSSDConfigSchema("etc/sssd.api.conf", diff --git a/server/config/ipachangeconf.py b/server/config/ipachangeconf.py index 3e5029a9..9635de44 100644 --- a/server/config/ipachangeconf.py +++ b/server/config/ipachangeconf.py @@ -23,6 +23,7 @@ import os import string import time import shutil +import re def openLocked(filename, perms): fd = -1 @@ -460,12 +461,44 @@ class IPAChangeConf: # A SSSD-specific subclass of IPAChangeConf class SSSDChangeConf(IPAChangeConf): + OPTCRE = re.compile( + r'(?P