From 8403bd9d15a7817a15b85d8e108cad1c155aadbc Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Wed, 11 Nov 2015 14:28:46 +0100 Subject: 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 Reviewed-By: Gabe Alford --- 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 54906e5b2..1d0428772 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) -- cgit