pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0004-Repeated-uninstallation-of-ipa-client-samba-crashes_rhbz#1732529.patch

544061
From b9b98097a47f27b56500edc972c438597e6609b1 Mon Sep 17 00:00:00 2001
544061
From: François Cami <fcami@redhat.com>
544061
Date: Jul 26 2019 13:09:42 +0000
544061
Subject: ipatests: test multiple invocations of ipa-client-samba --uninstall
544061
544061
544061
Related-to: https://pagure.io/freeipa/issue/8019
544061
Signed-off-by: François Cami <fcami@redhat.com>
544061
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
544061
Reviewed-By: Sergey Orlov <sorlov@redhat.com>
544061
544061
---
544061
544061
diff --git a/ipatests/test_integration/test_smb.py b/ipatests/test_integration/test_smb.py
544061
index 4e295c0..26d70b3 100644
544061
--- a/ipatests/test_integration/test_smb.py
544061
+++ b/ipatests/test_integration/test_smb.py
544061
@@ -150,3 +150,6 @@ class TestSMB(IntegrationTest):
544061
 
544061
         smbsrv = self.replicas[0]
544061
         smbsrv.run_command(['ipa-client-samba', '--uninstall', '-U'])
544061
+        # test for https://pagure.io/freeipa/issue/8019
544061
+        # try another uninstall after the first one:
544061
+        smbsrv.run_command(['ipa-client-samba', '--uninstall', '-U'])
544061
544061
From 256a6a879061d2b97c11e9cd97b2427579610fa1 Mon Sep 17 00:00:00 2001
544061
From: François Cami <fcami@redhat.com>
544061
Date: Jul 26 2019 13:09:42 +0000
544061
Subject: ipa-client-samba: remove and restore smb.conf only on first uninstall
544061
544061
544061
Fixes: https://pagure.io/freeipa/issue/8019
544061
Signed-off-by: François Cami <fcami@redhat.com>
544061
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
544061
Reviewed-By: Sergey Orlov <sorlov@redhat.com>
544061
544061
---
544061
544061
diff --git a/ipaclient/install/ipa_client_samba.py b/ipaclient/install/ipa_client_samba.py
544061
index e2be67d..6a3c3bd 100755
544061
--- a/ipaclient/install/ipa_client_samba.py
544061
+++ b/ipaclient/install/ipa_client_samba.py
544061
@@ -433,8 +433,9 @@ def uninstall(fstore, statestore, options):
544061
     ipautil.remove_ccache(ccache_path=paths.KRB5CC_SAMBA)
544061
 
544061
     # Remove samba's configuration file
544061
-    ipautil.remove_file(paths.SMB_CONF)
544061
-    fstore.restore_file(paths.SMB_CONF)
544061
+    if fstore.has_file(paths.SMB_CONF):
544061
+        ipautil.remove_file(paths.SMB_CONF)
544061
+        fstore.restore_file(paths.SMB_CONF)
544061
 
544061
     # Remove samba's persistent and temporary tdb files
544061
     tdb_files = [
544061
@@ -624,7 +625,7 @@ def run():
544061
             api.Command.service_del(api.env.smb_princ)
544061
         except AttributeError:
544061
             logger.error(
544061
-                "Chosen IPA master %s does not have support to"
544061
+                "Chosen IPA master %s does not have support to "
544061
                 "set up Samba domain members", server,
544061
             )
544061
             return 1
544061
544061
From 00ba2ae6681dafa92d3f00f2a4e11adaa477ea0e Mon Sep 17 00:00:00 2001
544061
From: François Cami <fcami@redhat.com>
544061
Date: Jul 26 2019 13:09:42 +0000
544061
Subject: ipatests: test ipa-client-samba after --uninstall
544061
544061
544061
Related-to: https://pagure.io/freeipa/issue/8021
544061
Signed-off-by: François Cami <fcami@redhat.com>
544061
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
544061
Reviewed-By: Sergey Orlov <sorlov@redhat.com>
544061
544061
---
544061
544061
diff --git a/ipatests/test_integration/test_smb.py b/ipatests/test_integration/test_smb.py
544061
index 26d70b3..933d468 100644
544061
--- a/ipatests/test_integration/test_smb.py
544061
+++ b/ipatests/test_integration/test_smb.py
544061
@@ -153,3 +153,8 @@ class TestSMB(IntegrationTest):
544061
         # test for https://pagure.io/freeipa/issue/8019
544061
         # try another uninstall after the first one:
544061
         smbsrv.run_command(['ipa-client-samba', '--uninstall', '-U'])
544061
+        # test for https://pagure.io/freeipa/issue/8021
544061
+        # try to install again:
544061
+        smbsrv.run_command(["ipa-client-samba", "-U"])
544061
+        # cleanup:
544061
+        smbsrv.run_command(['ipa-client-samba', '--uninstall', '-U'])
544061
544061
From 551cd68d0959b1ee761ead6338dc06c544c0c5da Mon Sep 17 00:00:00 2001
544061
From: François Cami <fcami@redhat.com>
544061
Date: Jul 26 2019 13:09:42 +0000
544061
Subject: ipa-client-samba: remove state on uninstall
544061
544061
544061
The "domain_member" state was not removed at uninstall time.
544061
Remove it so that future invocations of ipa-client-samba work.
544061
544061
Fixes: https://pagure.io/freeipa/issue/8021
544061
Signed-off-by: François Cami <fcami@redhat.com>
544061
544061
https://pagure.io/freeipa/issue/8021
544061
544061
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
544061
Reviewed-By: Sergey Orlov <sorlov@redhat.com>
544061
544061
---
544061
544061
diff --git a/ipaclient/install/ipa_client_samba.py b/ipaclient/install/ipa_client_samba.py
544061
index 6a3c3bd..126ef32 100755
544061
--- a/ipaclient/install/ipa_client_samba.py
544061
+++ b/ipaclient/install/ipa_client_samba.py
544061
@@ -523,11 +523,25 @@ def run():
544061
     if options.uninstall:
544061
         if statestore.has_state("domain_member"):
544061
             uninstall(fstore, statestore, options)
544061
-            print(
544061
-                "Samba configuration is reverted. "
544061
-                "However, Samba databases were fully cleaned and "
544061
-                "old configuration file will not be usable anymore."
544061
-            )
544061
+            try:
544061
+                keys = (
544061
+                    "configured", "hardening", "groupmap", "tdb",
544061
+                    "service.principal", "smb.conf"
544061
+                )
544061
+                for key in keys:
544061
+                    statestore.delete_state("domain_member", key)
544061
+            except Exception as e:
544061
+                print(
544061
+                    "Error: Failed to remove the domain_member statestores: "
544061
+                    "%s" % e
544061
+                )
544061
+                return 1
544061
+            else:
544061
+                print(
544061
+                    "Samba configuration is reverted. "
544061
+                    "However, Samba databases were fully cleaned and "
544061
+                    "old configuration file will not be usable anymore."
544061
+                )
544061
         else:
544061
             print("Samba domain member is not configured yet")
544061
         return 0
544061