|
|
3ed92b |
From ca880cfb117fc870a6e2710b9e31b2f67d5651e1 Mon Sep 17 00:00:00 2001
|
|
|
3ed92b |
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
3ed92b |
Date: Wed, 29 Jul 2020 13:35:49 +0200
|
|
|
3ed92b |
Subject: [PATCH] ipa-client-install: use the authselect backup during
|
|
|
3ed92b |
uninstall
|
|
|
3ed92b |
|
|
|
3ed92b |
When ipa-client-install is run on a system with no existing
|
|
|
3ed92b |
authselect configuration (for instance a fedora 31 new install),
|
|
|
3ed92b |
uninstallation is picking sssd profile but this may lead to
|
|
|
3ed92b |
a configuration with differences compared to the pre-ipa-client
|
|
|
3ed92b |
state.
|
|
|
3ed92b |
|
|
|
3ed92b |
Now that authselect provides an option to backup the existing
|
|
|
3ed92b |
configuration prior to setting a profile, the client install
|
|
|
3ed92b |
can save the backup name and uninstall is able to apply the
|
|
|
3ed92b |
backup in order to go back to the pre-ipa-client state.
|
|
|
3ed92b |
|
|
|
3ed92b |
Fixes: https://pagure.io/freeipa/issue/8189
|
|
|
3ed92b |
Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
3ed92b |
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
|
|
|
3ed92b |
---
|
|
|
3ed92b |
ipaplatform/redhat/authconfig.py | 37 ++++++++++++++------------------
|
|
|
3ed92b |
1 file changed, 16 insertions(+), 21 deletions(-)
|
|
|
3ed92b |
|
|
|
3ed92b |
diff --git a/ipaplatform/redhat/authconfig.py b/ipaplatform/redhat/authconfig.py
|
|
|
3ed92b |
index 758376f2b..89f452d66 100644
|
|
|
3ed92b |
--- a/ipaplatform/redhat/authconfig.py
|
|
|
3ed92b |
+++ b/ipaplatform/redhat/authconfig.py
|
|
|
3ed92b |
@@ -27,6 +27,7 @@ from ipaplatform.paths import paths
|
|
|
3ed92b |
from ipapython import ipautil
|
|
|
3ed92b |
from ipapython.admintool import ScriptError
|
|
|
3ed92b |
import os
|
|
|
3ed92b |
+import time
|
|
|
3ed92b |
|
|
|
3ed92b |
FILES_TO_NOT_BACKUP = ['passwd', 'group', 'shadow', 'gshadow']
|
|
|
3ed92b |
|
|
|
3ed92b |
@@ -103,28 +104,16 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
|
|
3ed92b |
def configure(self, sssd, mkhomedir, statestore, sudo=True):
|
|
|
3ed92b |
# In the statestore, the following keys are used for the
|
|
|
3ed92b |
# 'authselect' module:
|
|
|
3ed92b |
+ # Old method:
|
|
|
3ed92b |
# profile: name of the profile configured pre-installation
|
|
|
3ed92b |
# features_list: list of features configured pre-installation
|
|
|
3ed92b |
# mkhomedir: True if installation was called with --mkhomedir
|
|
|
3ed92b |
# profile and features_list are used when reverting to the
|
|
|
3ed92b |
# pre-install state
|
|
|
3ed92b |
- cfg = self._parse_authselect_output()
|
|
|
3ed92b |
- if cfg:
|
|
|
3ed92b |
- statestore.backup_state('authselect', 'profile', cfg[0])
|
|
|
3ed92b |
- statestore.backup_state(
|
|
|
3ed92b |
- 'authselect', 'features_list', " ".join(cfg[1]))
|
|
|
3ed92b |
- else:
|
|
|
3ed92b |
- # cfg = None means that the current conf is not managed by
|
|
|
3ed92b |
- # authselect but by authconfig.
|
|
|
3ed92b |
- # As we are using authselect to configure the host,
|
|
|
3ed92b |
- # it will not be possible to revert to a custom authconfig
|
|
|
3ed92b |
- # configuration later (during uninstall)
|
|
|
3ed92b |
- # Best thing to do will be to use sssd profile at this time
|
|
|
3ed92b |
- logger.warning(
|
|
|
3ed92b |
- "WARNING: The configuration pre-client installation is not "
|
|
|
3ed92b |
- "managed by authselect and cannot be backed up. "
|
|
|
3ed92b |
- "Uninstallation may not be able to revert to the original "
|
|
|
3ed92b |
- "state.")
|
|
|
3ed92b |
+ # New method:
|
|
|
3ed92b |
+ # backup: name of the authselect backup
|
|
|
3ed92b |
+ backup_name = "pre_ipaclient_{}".format(time.strftime("%Y%m%d%H%M%S"))
|
|
|
3ed92b |
+ statestore.backup_state('authselect', 'backup', backup_name)
|
|
|
3ed92b |
|
|
|
3ed92b |
cmd = [paths.AUTHSELECT, "select", "sssd"]
|
|
|
3ed92b |
if mkhomedir:
|
|
|
3ed92b |
@@ -133,6 +122,7 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
|
|
3ed92b |
if sudo:
|
|
|
3ed92b |
cmd.append("with-sudo")
|
|
|
3ed92b |
cmd.append("--force")
|
|
|
3ed92b |
+ cmd.append("--backup={}".format(backup_name))
|
|
|
3ed92b |
|
|
|
3ed92b |
ipautil.run(cmd)
|
|
|
3ed92b |
|
|
|
3ed92b |
@@ -179,10 +169,15 @@ class RedHatAuthSelect(RedHatAuthToolBase):
|
|
|
3ed92b |
else:
|
|
|
3ed92b |
features = []
|
|
|
3ed92b |
|
|
|
3ed92b |
- cmd = [paths.AUTHSELECT, "select", profile]
|
|
|
3ed92b |
- cmd.extend(features)
|
|
|
3ed92b |
- cmd.append("--force")
|
|
|
3ed92b |
- ipautil.run(cmd)
|
|
|
3ed92b |
+ backup = statestore.restore_state('authselect', 'backup')
|
|
|
3ed92b |
+ if backup:
|
|
|
3ed92b |
+ cmd = [paths.AUTHSELECT, "backup-restore", backup]
|
|
|
3ed92b |
+ ipautil.run(cmd)
|
|
|
3ed92b |
+ else:
|
|
|
3ed92b |
+ cmd = [paths.AUTHSELECT, "select", profile]
|
|
|
3ed92b |
+ cmd.extend(features)
|
|
|
3ed92b |
+ cmd.append("--force")
|
|
|
3ed92b |
+ ipautil.run(cmd)
|
|
|
3ed92b |
|
|
|
3ed92b |
def backup(self, path):
|
|
|
3ed92b |
current = self._get_authselect_current_output()
|
|
|
3ed92b |
--
|
|
|
3ed92b |
2.26.2
|
|
|
3ed92b |
|
|
|
3ed92b |
# Not needed for 4.7.8 release
|
|
|
3ed92b |
#
|
|
|
3ed92b |
#From 3eaab97e317584bc47d4a27a607267ed90df7ff7 Mon Sep 17 00:00:00 2001
|
|
|
3ed92b |
#From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
3ed92b |
#Date: Wed, 29 Jul 2020 13:40:26 +0200
|
|
|
3ed92b |
#Subject: [PATCH] ipatests: remove the xfail for test_nfs.py
|
|
|
3ed92b |
#
|
|
|
3ed92b |
#Related: https://pagure.io/freeipa/issue/8189
|
|
|
3ed92b |
#Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
3ed92b |
#Reviewed-By: Michal Polovka <mpolovka@redhat.com>
|
|
|
3ed92b |
#---
|
|
|
3ed92b |
# ipatests/test_integration/test_nfs.py | 4 ----
|
|
|
3ed92b |
# 1 file changed, 4 deletions(-)
|
|
|
3ed92b |
#
|
|
|
3ed92b |
#diff --git a/ipatests/test_integration/test_nfs.py b/ipatests/test_integration/test_nfs.py
|
|
|
3ed92b |
#index 7272b0d44..832c56cca 100644
|
|
|
3ed92b |
#--- a/ipatests/test_integration/test_nfs.py
|
|
|
3ed92b |
#+++ b/ipatests/test_integration/test_nfs.py
|
|
|
3ed92b |
#@@ -363,10 +363,6 @@ class TestIpaClientAutomountFileRestore(IntegrationTest):
|
|
|
3ed92b |
# cmd = self.clients[0].run_command(sha256nsswitch_cmd)
|
|
|
3ed92b |
# assert cmd.stdout_text == orig_sha256
|
|
|
3ed92b |
#
|
|
|
3ed92b |
#- @pytest.mark.xfail(
|
|
|
3ed92b |
#- reason="https://pagure.io/freeipa/issue/8189",
|
|
|
3ed92b |
#- strict=True
|
|
|
3ed92b |
#- )
|
|
|
3ed92b |
# def test_nsswitch_backup_restore_sssd(self):
|
|
|
3ed92b |
# self.nsswitch_backup_restore()
|
|
|
3ed92b |
#
|
|
|
3ed92b |
#--
|
|
|
3ed92b |
#2.26.2
|
|
|
3ed92b |
|
|
|
3ed92b |
From 4baf6b292f28481ece483bb8ecbd6a0807d9d45a Mon Sep 17 00:00:00 2001
|
|
|
3ed92b |
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
3ed92b |
Date: Wed, 29 Jul 2020 17:57:53 +0200
|
|
|
3ed92b |
Subject: [PATCH] ipatests: fix test_authselect
|
|
|
3ed92b |
|
|
|
3ed92b |
Before the code fix, install/uninstall on a config without
|
|
|
3ed92b |
any authselect profile was not able to restore the exact
|
|
|
3ed92b |
state but configured sssd profile instead.
|
|
|
3ed92b |
|
|
|
3ed92b |
Now that the code is doing a pre-install backup, uninstall
|
|
|
3ed92b |
restores the exact state and the test needs to be updated
|
|
|
3ed92b |
accordingly.
|
|
|
3ed92b |
|
|
|
3ed92b |
Related: https://pagure.io/freeipa/issue/8189
|
|
|
3ed92b |
Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
3ed92b |
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
|
|
|
3ed92b |
---
|
|
|
3ed92b |
ipatests/test_integration/test_authselect.py | 13 ++++++++-----
|
|
|
3ed92b |
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
3ed92b |
|
|
|
3ed92b |
diff --git a/ipatests/test_integration/test_authselect.py b/ipatests/test_integration/test_authselect.py
|
|
|
3ed92b |
index bdf7d9f77..cba23e707 100644
|
|
|
3ed92b |
--- a/ipatests/test_integration/test_authselect.py
|
|
|
3ed92b |
+++ b/ipatests/test_integration/test_authselect.py
|
|
|
3ed92b |
@@ -100,7 +100,9 @@ class TestClientInstallation(IntegrationTest):
|
|
|
3ed92b |
['rm', '-f', '/etc/authselect/authselect.conf'])
|
|
|
3ed92b |
result = self._install_client()
|
|
|
3ed92b |
assert result.returncode == 0
|
|
|
3ed92b |
- assert self.msg_warn_install in result.stderr_text
|
|
|
3ed92b |
+ # With the fix for 8189, there is no warning any more
|
|
|
3ed92b |
+ # because install is performing a pre-install backup
|
|
|
3ed92b |
+ assert self.msg_warn_install not in result.stderr_text
|
|
|
3ed92b |
# Client installation must configure the 'sssd' profile
|
|
|
3ed92b |
# with sudo
|
|
|
3ed92b |
check_authselect_profile(self.client, default_profile, ('with-sudo',))
|
|
|
3ed92b |
@@ -109,12 +111,13 @@ class TestClientInstallation(IntegrationTest):
|
|
|
3ed92b |
"""
|
|
|
3ed92b |
Test client un-installation when there was no authselect profile
|
|
|
3ed92b |
"""
|
|
|
3ed92b |
- # As the client did not have any authselect profile before install,
|
|
|
3ed92b |
- # uninstall must print a warning about restoring 'sssd' profile
|
|
|
3ed92b |
- # by default
|
|
|
3ed92b |
+ # The client did not have any authselect profile before install,
|
|
|
3ed92b |
+ # but uninstall must be able to restore the backup
|
|
|
3ed92b |
+ # Check that no profile is configured after uninstall
|
|
|
3ed92b |
result = self._uninstall_client()
|
|
|
3ed92b |
assert result.returncode == 0
|
|
|
3ed92b |
- check_authselect_profile(self.client, default_profile)
|
|
|
3ed92b |
+ assert not self.client.transport.file_exists(
|
|
|
3ed92b |
+ '/etc/authselect/authselect.conf')
|
|
|
3ed92b |
|
|
|
3ed92b |
def test_install_client_preconfigured_profile(self):
|
|
|
3ed92b |
"""
|
|
|
3ed92b |
--
|
|
|
3ed92b |
2.26.2
|
|
|
3ed92b |
|