From 6fa123447f8acfbbdb442a1cbac38997a8e81208 Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Tue, 30 Jun 2015 15:55:40 +0200 Subject: [PATCH] FIX: Clear SSSD caches when uninstalling the client https://fedorahosted.org/freeipa/ticket/5049 Reviewed-By: Simo Sorce --- ipa-client/ipa-install/ipa-client-install | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install index 8bc3fbe9a..a1564583c 100755 --- a/ipa-client/ipa-install/ipa-client-install +++ b/ipa-client/ipa-install/ipa-client-install @@ -479,6 +479,7 @@ def uninstall(options, env): statestore._load() hostname = None + ipa_domain = None was_sssd_configured = False try: sssdconfig = SSSDConfig.SSSDConfig() @@ -503,6 +504,10 @@ def uninstall(options, env): hostname = domain.get_option('ipa_hostname') except SSSDConfig.NoOptionError: continue + try: + ipa_domain = domain.get_option('ipa_domain') + except SSSDConfig.NoOptionError: + pass except Exception, e: # We were unable to read existing SSSD config. This might mean few things: # - sssd wasn't installed @@ -632,14 +637,14 @@ def uninstall(options, env): remove_file(paths.SSSD_MC_GROUP) remove_file(paths.SSSD_MC_PASSWD) - ipa_domain = domain.get_option('ipa_domain') - sssd_domain_ldb = "cache_" + ipa_domain + ".ldb" - sssd_ldb_file = os.path.join(paths.SSSD_DB, sssd_domain_ldb) - remove_file(sssd_ldb_file) + if ipa_domain: + sssd_domain_ldb = "cache_" + ipa_domain + ".ldb" + sssd_ldb_file = os.path.join(paths.SSSD_DB, sssd_domain_ldb) + remove_file(sssd_ldb_file) - sssd_domain_ccache = "ccache_" + ipa_domain.upper() - sssd_ccache_file = os.path.join(paths.SSSD_DB, sssd_domain_ccache) - remove_file(sssd_domain_ccache) + sssd_domain_ccache = "ccache_" + ipa_domain.upper() + sssd_ccache_file = os.path.join(paths.SSSD_DB, sssd_domain_ccache) + remove_file(sssd_ccache_file) # Next if-elif-elif construction deals with sssd.conf file. # Old pre-IPA domains are preserved due merging the old sssd.conf