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

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