Blame SOURCES/0012-CAless-installation-set-the-perms-on-KDC-cert-file_rhbz#1863616.patch

91acb2
From 81c955e561dd42ab70a39bf636c90e82a9d7d899 Mon Sep 17 00:00:00 2001
91acb2
From: Florence Blanc-Renaud <flo@redhat.com>
91acb2
Date: Mon, 3 Aug 2020 18:52:07 +0200
91acb2
Subject: [PATCH] CAless installation: set the perms on KDC cert file
91acb2
91acb2
In CA less installation, the KDC certificate file does not have
91acb2
the expected 644 permissions. As a consequence, WebUI login
91acb2
fails.
91acb2
91acb2
The fix makes sure that the KDC cert file is saved with 644 perms.
91acb2
91acb2
Fixes: https://pagure.io/freeipa/issue/8440
91acb2
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
91acb2
---
91acb2
 ipaserver/install/krbinstance.py | 2 ++
91acb2
 1 file changed, 2 insertions(+)
91acb2
91acb2
diff --git a/ipaserver/install/krbinstance.py b/ipaserver/install/krbinstance.py
91acb2
index 09d14693c..1910ff374 100644
91acb2
--- a/ipaserver/install/krbinstance.py
91acb2
+++ b/ipaserver/install/krbinstance.py
91acb2
@@ -536,6 +536,8 @@ class KrbInstance(service.Service):
91acb2
         certs.install_pem_from_p12(self.pkcs12_info[0],
91acb2
                                    self.pkcs12_info[1],
91acb2
                                    paths.KDC_CERT)
91acb2
+        # The KDC cert needs to be readable by everyone
91acb2
+        os.chmod(paths.KDC_CERT, 0o644)
91acb2
         certs.install_key_from_p12(self.pkcs12_info[0],
91acb2
                                    self.pkcs12_info[1],
91acb2
                                    paths.KDC_KEY)
91acb2
-- 
91acb2
2.26.2
91acb2
91acb2
From 295dd4235f693b7b4b4270b46a28cb6e7b3d00b4 Mon Sep 17 00:00:00 2001
91acb2
From: Florence Blanc-Renaud <flo@redhat.com>
91acb2
Date: Mon, 3 Aug 2020 18:53:47 +0200
91acb2
Subject: [PATCH] ipatests: check KDC cert permissions in CA less install
91acb2
91acb2
The KDC certificate file must be stored with 644 permissions.
91acb2
Add a test checking the file permissions on server + replica.
91acb2
91acb2
Related: https://pagure.io/freeipa/issue/8440
91acb2
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
91acb2
---
91acb2
 ipatests/test_integration/test_caless.py | 9 +++++++++
91acb2
 1 file changed, 9 insertions(+)
91acb2
91acb2
diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
91acb2
index a7b2cbbbc..1ea7d9896 100644
91acb2
--- a/ipatests/test_integration/test_caless.py
91acb2
+++ b/ipatests/test_integration/test_caless.py
91acb2
@@ -1527,6 +1527,13 @@ class TestCertInstall(CALessBase):
91acb2
         assert result.returncode == 0
91acb2
 
91acb2
 
91acb2
+def verify_kdc_cert_perms(host):
91acb2
+    """Verify that the KDC cert pem file has 0644 perms"""
91acb2
+    cmd = host.run_command(['stat', '-c',
91acb2
+                           '"%a %G:%U"', paths.KDC_CERT])
91acb2
+    assert "644 root:root" in cmd.stdout_text
91acb2
+
91acb2
+
91acb2
 class TestPKINIT(CALessBase):
91acb2
     """Install master and replica with PKINIT"""
91acb2
     num_replicas = 1
91acb2
@@ -1540,6 +1547,7 @@ class TestPKINIT(CALessBase):
91acb2
         result = cls.install_server(pkinit_pkcs12_exists=True,
91acb2
                                     pkinit_pin=_DEFAULT)
91acb2
         assert result.returncode == 0
91acb2
+        verify_kdc_cert_perms(cls.master)
91acb2
 
91acb2
     @replica_install_teardown
91acb2
     def test_server_replica_install_pkinit(self):
91acb2
@@ -1549,6 +1557,7 @@ class TestPKINIT(CALessBase):
91acb2
                                       pkinit_pin=_DEFAULT)
91acb2
         assert result.returncode == 0
91acb2
         self.verify_installation()
91acb2
+        verify_kdc_cert_perms(self.replicas[0])
91acb2
 
91acb2
 
91acb2
 class TestServerReplicaCALessToCAFull(CALessBase):
91acb2
-- 
91acb2
2.26.2
91acb2