Hi,

Simple regexp substitution caused that the domain directive fell under
an inapprorpiate section, if the domain directive was not present. Hence
the idmapd.conf file was not properly parsed.

Use IPAChangeConf to put the directive in its correct place even if it
the domain directive is missing.

https://fedorahosted.org/freeipa/ticket/5069
From 220fc10dd3ba5454f6bd28fa4d85149a4e5b8f92 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Wed, 11 Nov 2015 14:23:43 +0100
Subject: [PATCH] ipachangeconf: Add ability to preserve section case

The IPAChangeConf normallizes section names to lower case. There are
cases where this behaviour might not be desirable, so provide a way to
opt out.

https://fedorahosted.org/freeipa/ticket/5069
---
 ipa-client/ipaclient/ipachangeconf.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ipa-client/ipaclient/ipachangeconf.py b/ipa-client/ipaclient/ipachangeconf.py
index 3d485adbd6bddc7371874dea6f39c48ea2c49c44..e257c82228a56ad02284dce4f799a216c9648feb 100644
--- a/ipa-client/ipaclient/ipachangeconf.py
+++ b/ipa-client/ipaclient/ipachangeconf.py
@@ -63,6 +63,7 @@ class IPAChangeConf:
         self.deol = self.eol[0]
         self.sectnamdel = ("[", "]")
         self.subsectdel = ("{", "}")
+        self.case_insensitive_sections = True
 
     def setProgName(self, name):
         self.progname = name
@@ -114,7 +115,9 @@ class IPAChangeConf:
         return False
 
     def matchSection(self, line):
-        cl = "".join(line.strip().split()).lower()
+        cl = "".join(line.strip().split())
+        cl = cl.lower() if self.case_insensitive_sections else cl
+
         if len(self.sectnamdel) != 2:
             return False
         if not cl.startswith(self.sectnamdel[0]):
-- 
2.4.3

From 3bfc005eb1ca74a0508a8340012347b8ddce7681 Mon Sep 17 00:00:00 2001
From: Tomas Babej <tba...@redhat.com>
Date: Wed, 11 Nov 2015 14:28:46 +0100
Subject: [PATCH] ipa-client-automount: Leverage IPAChangeConf to configure the
 domain for idmapd

Simple regexp substitution caused that the domain directive fell under
an inapprorpiate section, if the domain directive was not present. Hence
the idmapd.conf file was not properly parsed.

Use IPAChangeConf to put the directive in its correct place even if it
the domain directive is missing.

https://fedorahosted.org/freeipa/ticket/5069
---
 ipa-client/ipa-install/ipa-client-automount | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-automount b/ipa-client/ipa-install/ipa-client-automount
index 54906e5b2c37d555bcd5e6f0dd4fae4b5bd0c917..1d04287722c3a0646c0fcc51f3b2c5b7d0cc80df 100755
--- a/ipa-client/ipa-install/ipa-client-automount
+++ b/ipa-client/ipa-install/ipa-client-automount
@@ -318,11 +318,21 @@ def configure_nfs(fstore, statestore):
 
     print("Configured %s" % paths.SYSCONFIG_NFS)
 
-    replacevars = {
-        'Domain': api.env.domain,
-    }
-    ipautil.backup_config_and_replace_variables(fstore,
-        paths.IDMAPD_CONF, replacevars=replacevars)
+    # Prepare the changes
+    # We need to use IPAChangeConf as simple regexp substitution
+    # does not cut it here
+    conf = ipachangeconf.IPAChangeConf("IPA automount installer")
+    conf.case_insensitive_sections = False
+    conf.setOptionAssignment(" = ")
+    conf.setSectionNameDelimiters(("[", "]"))
+
+    changes = [conf.setOption('Domain', api.env.domain)]
+    section_with_changes = [conf.setSection('General', changes)]
+
+    # Backup the file and apply the changes
+    fstore.backup_file(paths.IDMAPD_CONF)
+    conf.changeConf(paths.IDMAPD_CONF, section_with_changes)
+
     tasks.restore_context(paths.IDMAPD_CONF)
 
     print("Configured %s" % paths.IDMAPD_CONF)
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to