Hi!

When modifying SSSD configuration, attempt to add new domain rather 
than replacing whole configuration file.

Only replace file in case it is impossible to parse it by current SSSD 
version.

https://fedorahosted.org/freeipa/ticket/1750

-- 
/ Alexander Bokovoy
>From d09127943967e1760bd2f8a61d10be15776f4255 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Wed, 7 Sep 2011 14:23:29 +0300
Subject: [PATCH] ipa-client-install should not clobber existing SSSD
 configurations

https://fedorahosted.org/freeipa/ticket/1750

When modifying SSSD configuration, attempt to add new domain rather than 
replacing whole configuration file.
Only replace file in case it is impossible to parse it by current SSSD version.
---
 ipa-client/ipa-install/ipa-client-install |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-install 
b/ipa-client/ipa-install/ipa-client-install
index 
fe520be9e79b12b2222fce45c6f7b1716d67ff46..31f0e87da5266cc7528b802a96322254a04cfa6e
 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -609,8 +609,17 @@ $)''', re.VERBOSE)
         print >>sys.stderr, "Failed to set permissions for %s (%s)." % 
(network_filename, str(e))
 
 def configure_sssd_conf(fstore, cli_realm, cli_domain, cli_server, options):
-    sssdconfig = SSSDConfig.SSSDConfig()
-    sssdconfig.new_config()
+    try:
+        sssdconfig = SSSDConfig.SSSDConfig()
+        sssdconfig.import_config()
+    except SSSDConfig.ParsingError, e:
+        # no existing SSSD configuration, make a new one
+        # We do make new SSSDConfig instance because IPAChangeConf-derived 
classes have no
+        # means to reset their state and ParseError exception could come due 
to parsing
+        # error from older version which cannot be upgraded anymore, leaving 
sssdconfig
+        # instance practically unusable
+        sssdconfig = SSSDConfig.SSSDConfig()
+        sssdconfig.new_config()
 
     domain = sssdconfig.new_domain(cli_domain)
     domain.add_provider('ipa', 'id')
-- 
1.7.6.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to