Blob Blame History Raw
From 05c5be1b1c5ae63c5547d248d926b3411bff2733 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Nov 29 2018 15:58:38 +0000
Subject: 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 <awilliam@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>

---

diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py
index 77ccc36..58cf7df 100644
--- a/ipaplatform/redhat/authconfig.py
+++ b/ipaplatform/redhat/authconfig.py
@@ -158,15 +158,26 @@ class RedHatAuthSelect(RedHatAuthToolBase):
                 " ".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 @@ class RedHatAuthSelect(RedHatAuthToolBase):
 
         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):