From cd2cbaecfce6b7b607619b34503b62c8afbbe594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Wed, 24 Jul 2019 09:41:19 +0200 Subject: [PATCH] ipa-client-samba: remove state on uninstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "domain_member" state was not removed at uninstall time. Remove it so that future invocations of ipa-client-samba work. Fixes: https://pagure.io/freeipa/issue/8021 Signed-off-by: François Cami https://pagure.io/freeipa/issue/8021 Reviewed-By: Alexander Bokovoy Reviewed-By: Sergey Orlov --- ipaclient/install/ipa_client_samba.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/ipaclient/install/ipa_client_samba.py b/ipaclient/install/ipa_client_samba.py index 6a3c3bd80..126ef32d7 100755 --- a/ipaclient/install/ipa_client_samba.py +++ b/ipaclient/install/ipa_client_samba.py @@ -523,11 +523,25 @@ def run(): if options.uninstall: if statestore.has_state("domain_member"): uninstall(fstore, statestore, options) - print( - "Samba configuration is reverted. " - "However, Samba databases were fully cleaned and " - "old configuration file will not be usable anymore." - ) + try: + keys = ( + "configured", "hardening", "groupmap", "tdb", + "service.principal", "smb.conf" + ) + for key in keys: + statestore.delete_state("domain_member", key) + except Exception as e: + print( + "Error: Failed to remove the domain_member statestores: " + "%s" % e + ) + return 1 + else: + print( + "Samba configuration is reverted. " + "However, Samba databases were fully cleaned and " + "old configuration file will not be usable anymore." + ) else: print("Samba domain member is not configured yet") return 0