From 66c57e6d92a9c5ca7b36ff125375810401e64233 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 27 Nov 2018 16:21:06 -0800 Subject: [PATCH] Fix authselect invocations to work with 1.0.2 Since authselect 1.0.2, invoking an authselect command sequence like this: ['authselect', 'sssd', '', '--force'] does not work: authselect barfs on the empty string arg and errors out. We must only pass a features arg if we actually have some text to go in it. This broke uninstallation. In all cases, features are now passed as separate arguments instead of one argument separated by space. Fixes: https://pagure.io/freeipa/issue/7776 Signed-off-by: Adam Williamson --- ipaplatform/redhat/authconfig.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py index a512345202..9d98b5b644 100644 --- a/ipaplatform/redhat/authconfig.py +++ b/ipaplatform/redhat/authconfig.py @@ -158,15 +158,26 @@ def unconfigure( " ".join(args)) profile = 'sssd' - features = '' + features = [] else: - profile = \ - statestore.restore_state('authselect', 'profile') or 'sssd' - features = \ - statestore.restore_state('authselect', 'features_list') or '' + profile = statestore.restore_state('authselect', 'profile') + if not profile: + profile = 'sssd' + features_state = statestore.restore_state( + 'authselect', 'features_list' + ) statestore.delete_state('authselect', 'mkhomedir') + # only non-empty features, https://pagure.io/freeipa/issue/7776 + if features_state is not None: + features = [ + f.strip() for f in features_state.split(' ') if f.strip() + ] + else: + features = [] - cmd = [paths.AUTHSELECT, "select", profile, features, "--force"] + cmd = [paths.AUTHSELECT, "select", profile] + cmd.extend(features) + cmd.append("--force") ipautil.run(cmd) def backup(self, path): @@ -186,10 +197,9 @@ def restore(self, path): if cfg: profile = cfg[0] - - cmd = [ - paths.AUTHSELECT, "select", profile, - " ".join(cfg[1]), "--force"] + cmd = [paths.AUTHSELECT, "select", profile] + cmd.extend(cfg[1]) + cmd.append("--force") ipautil.run(cmd) def set_nisdomain(self, nisdomain):