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

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