summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorMartin Basti <mbasti@redhat.com>2014-06-27 17:04:15 +0200
committerPetr Viktorin <pviktori@redhat.com>2014-07-02 18:41:57 +0200
commit5c2ddaf6606736074c4b548592405a8e98027308 (patch)
treeb3a974770b924ec265eca19857228f880c6b7584 /ipaserver
parentc4b63dc48a4ab6d4a9b7e824dba23a806fd6d741 (diff)
downloadfreeipa-5c2ddaf6606736074c4b548592405a8e98027308.tar.gz
freeipa-5c2ddaf6606736074c4b548592405a8e98027308.tar.xz
freeipa-5c2ddaf6606736074c4b548592405a8e98027308.zip
Allow to add non string values to named conf
Non string values should not start and end with '"' in options section in named.conf Required by ticket: https://fedorahosted.org/freeipa/ticket/4408 Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/bindinstance.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index 78810297a..9a27c7817 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -51,6 +51,9 @@ named_conf_arg_ipa_re = re.compile(r'(?P<indent>\s*)arg\s+"(?P<name>\S+)\s(?P<va
named_conf_arg_options_re = re.compile(r'(?P<indent>\s*)(?P<name>\S+)\s+"(?P<value>[^"]+)"\s*;')
named_conf_arg_ipa_template = "%(indent)sarg \"%(name)s %(value)s\";\n"
named_conf_arg_options_template = "%(indent)s%(name)s \"%(value)s\";\n"
+# non string args for options section
+named_conf_arg_options_re_nonstr = re.compile(r'(?P<indent>\s*)(?P<name>\S+)\s+(?P<value>[^"]+)\s*;')
+named_conf_arg_options_template_nonstr = "%(indent)s%(name)s %(value)s;\n"
def check_inst(unattended):
has_bind = True
@@ -94,14 +97,21 @@ def named_conf_exists():
NAMED_SECTION_OPTIONS = "options"
NAMED_SECTION_IPA = "ipa"
-def named_conf_get_directive(name, section=NAMED_SECTION_IPA):
- """Get a configuration option in bind-dyndb-ldap section of named.conf"""
+def named_conf_get_directive(name, section=NAMED_SECTION_IPA, str_val=True):
+ """Get a configuration option in bind-dyndb-ldap section of named.conf
+
+ :str_val - set to True if directive value is string
+ (only for NAMED_SECTION_OPTIONS)
+ """
if section == NAMED_SECTION_IPA:
named_conf_section_start_re = named_conf_section_ipa_start_re
named_conf_arg_re = named_conf_arg_ipa_re
elif section == NAMED_SECTION_OPTIONS:
named_conf_section_start_re = named_conf_section_options_start_re
- named_conf_arg_re = named_conf_arg_options_re
+ if str_val:
+ named_conf_arg_re = named_conf_arg_options_re
+ else:
+ named_conf_arg_re = named_conf_arg_options_re_nonstr
else:
raise NotImplementedError('Section "%s" is not supported' % section)
@@ -121,7 +131,8 @@ def named_conf_get_directive(name, section=NAMED_SECTION_IPA):
if match and name == match.group('name'):
return match.group('value')
-def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA):
+def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA,
+ str_val=True):
"""
Set configuration option in bind-dyndb-ldap section of named.conf.
@@ -130,6 +141,9 @@ def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA):
If the value is set to None, the configuration option is removed
from named.conf.
+
+ :str_val - set to True if directive value is string
+ (only for NAMED_SECTION_OPTIONS)
"""
new_lines = []
@@ -139,8 +153,12 @@ def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA):
named_conf_arg_template = named_conf_arg_ipa_template
elif section == NAMED_SECTION_OPTIONS:
named_conf_section_start_re = named_conf_section_options_start_re
- named_conf_arg_re = named_conf_arg_options_re
- named_conf_arg_template = named_conf_arg_options_template
+ if str_val:
+ named_conf_arg_re = named_conf_arg_options_re
+ named_conf_arg_template = named_conf_arg_options_template
+ else:
+ named_conf_arg_re = named_conf_arg_options_re_nonstr
+ named_conf_arg_template = named_conf_arg_options_template_nonstr
else:
raise NotImplementedError('Section "%s" is not supported' % section)