summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/config/SSSDConfigTest.py8
-rw-r--r--server/config/ipachangeconf.py33
-rw-r--r--server/config/testconfigs/sssd-valid.conf4
3 files changed, 43 insertions, 2 deletions
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<option>[^:=\s][^:=]*)' # very permissive!
+ r'\s*=\s*' # any number of space/tab,
+ # followed by separator
+ # followed by any # space/tab
+ r'(?P<value>.*)$' # everything up to eol
+ )
+
def __init__(self):
IPAChangeConf.__init__(self, "SSSD")
self.comment = ("#",";")
self.backup_suffix = ".bak"
self.opts = []
+ def parseLine(self, line):
+ """
+ Overrides IPAChangeConf parseLine so that lines are splitted
+ using any separator in self.assign, not just the default one
+ """
+
+ if self.matchEmpty(line):
+ return {'name':'empty', 'type':'empty'}
+
+ value = self.matchComment(line)
+ if value:
+ return {'name':'comment', 'type':'comment', 'value':value.rstrip()}
+
+ mo = self.OPTCRE.match(line)
+ if not mo:
+ raise SyntaxError, 'Syntax Error: Unknown line format'
+
+ try:
+ name, value = mo.group('option', 'value')
+ except IndexError:
+ raise SyntaxError, 'Syntax Error: Unknown line format'
+
+ return {'name':name.strip(), 'type':'option', 'value':value.strip()}
+
def readfp(self, fd):
self.opts.extend(self.parse(fd))
diff --git a/server/config/testconfigs/sssd-valid.conf b/server/config/testconfigs/sssd-valid.conf
index 6725e0a7..82b3fd81 100644
--- a/server/config/testconfigs/sssd-valid.conf
+++ b/server/config/testconfigs/sssd-valid.conf
@@ -30,8 +30,8 @@ auth_provider = local
debug_level = 0
[domain/LDAP]
-id_provider = ldap
-auth_provider = ldap
+id_provider = ldap
+auth_provider=ldap
debug_level = 0
[pam]