From d39e232e9ee28da5d4488135d264d2d1b9e671ba Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Fri, 6 May 2022 13:56:17 +0200 Subject: [PATCH] client uninstall: handle uninstall with authconfig If the client was installed with authconfig, with automount configured to use ldap (--no-sssd), and later updated to a version using authselect, the uninstaller tries to disable the authselect feature with-custom-automount but fails because there is no authselect profile in use. (Upgrade of a client does not transform authconfig settings into authselect settings because we don't have any client upgrader, as opposed to the ipa-server-upgrade for the servers). To avoid uninstallation failure, ignore the error and log a warning. The second part of the commit leverages the "complete" state stored in the statestore, in order to fix issues when a client installation fails and the installation is reverted by the ipa-client-install tool itself. The fix checks if the statestore shows an incomplete installation. If the install was incomplete and failed before any attempt to configure authselect, then unconfigure doesn't need to do anything. In the other cases, unconfigure needs to revert to the pre-ipa state. Fixes: https://pagure.io/freeipa/issue/9147 Reviewed-By: Rob Crittenden --- ipaplatform/redhat/authconfig.py | 9 ++++++++- ipaplatform/redhat/tasks.py | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py index 89f452d66..b51baf585 100644 --- a/ipaplatform/redhat/authconfig.py +++ b/ipaplatform/redhat/authconfig.py @@ -129,7 +129,14 @@ class RedHatAuthSelect(RedHatAuthToolBase): def unconfigure( self, fstore, statestore, was_sssd_installed, was_sssd_configured ): - if not statestore.has_state('authselect') and was_sssd_installed: + # If the installation failed before doing the authselect part + # nothing to do here + complete = statestore.get_state('installation', 'complete') + if complete is not None and not complete and \ + not statestore.has_state('authselect'): + return + + if not statestore.has_state('authselect'): logger.warning( "WARNING: Unable to revert to the pre-installation state " "('authconfig' tool has been deprecated in favor of " diff --git a/ipaplatform/redhat/tasks.py b/ipaplatform/redhat/tasks.py index 63c11b9e3..d056a4829 100644 --- a/ipaplatform/redhat/tasks.py +++ b/ipaplatform/redhat/tasks.py @@ -765,6 +765,12 @@ class RedHatTaskNamespace(BaseTaskNamespace): authselect_cmd = [paths.AUTHSELECT, "disable-feature", "with-custom-automount"] - ipautil.run(authselect_cmd) + try: + ipautil.run(authselect_cmd) + except ipautil.CalledProcessError: + logger.info("Unable to disable with-custom-automount feature") + logger.info("It may happen if the configuration was done " + "using authconfig instead of authselect") + tasks = RedHatTaskNamespace()