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 <rcritten@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2022-05-06 13:56:17 +02:00 committed by Rob Crittenden
parent c2e79fa0b6
commit ce0592bd47
2 changed files with 15 additions and 2 deletions

View File

@ -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 "

View File

@ -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()