Blame SOURCES/0019-SELinux-add-dedicated-policy-for-ipa-pki-retrieve-key-ipatests-enhance-TestSubCAkeyReplication_rhbz#1870202.patch

7a9cbd
From 52929cbadf0252fcac1019b74663a2808061ea1b Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Thu, 17 Sep 2020 11:30:45 +0200
7a9cbd
Subject: [PATCH] ipatests: enhance TestSubCAkeyReplication
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
enhance the test suite so that it covers:
7a9cbd
- deleting subCAs (disabling them first)
7a9cbd
- checking what happens when creating a dozen+ subCAs at a time
7a9cbd
- adding a subCA that already exists and expect failure
7a9cbd
7a9cbd
Related: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 .../test_replica_promotion.py                 | 52 +++++++++++++++++--
7a9cbd
 1 file changed, 47 insertions(+), 5 deletions(-)
7a9cbd
7a9cbd
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
7a9cbd
index 82117054f..f0b72e1f8 100644
7a9cbd
--- a/ipatests/test_integration/test_replica_promotion.py
7a9cbd
+++ b/ipatests/test_integration/test_replica_promotion.py
7a9cbd
@@ -474,17 +474,35 @@ class TestSubCAkeyReplication(IntegrationTest):
7a9cbd
         SERVER_CERT_NICK: 'u,u,u',
7a9cbd
     }
7a9cbd
 
7a9cbd
-    def add_subca(self, host, name, subject):
7a9cbd
+    def add_subca(self, host, name, subject, raiseonerr=True):
7a9cbd
         result = host.run_command([
7a9cbd
             'ipa', 'ca-add', name,
7a9cbd
             '--subject', subject,
7a9cbd
-            '--desc', self.SUBCA_DESC,
7a9cbd
+            '--desc', self.SUBCA_DESC],
7a9cbd
+            raiseonerr=raiseonerr
7a9cbd
+        )
7a9cbd
+        if raiseonerr:
7a9cbd
+            assert "ipa: ERROR:" not in result.stderr_text
7a9cbd
+            auth_id = "".join(re.findall(AUTH_ID_RE, result.stdout_text))
7a9cbd
+            return '{} {}'.format(IPA_CA_NICKNAME, auth_id)
7a9cbd
+        else:
7a9cbd
+            assert "ipa: ERROR:" in result.stderr_text
7a9cbd
+            assert result.returncode != 0
7a9cbd
+            return result
7a9cbd
+
7a9cbd
+    def del_subca(self, host, name):
7a9cbd
+        host.run_command([
7a9cbd
+            'ipa', 'ca-disable', name
7a9cbd
         ])
7a9cbd
-        auth_id = "".join(re.findall(AUTH_ID_RE, result.stdout_text))
7a9cbd
-        return '{} {}'.format(IPA_CA_NICKNAME, auth_id)
7a9cbd
+        result = host.run_command([
7a9cbd
+            'ipa', 'ca-del', name
7a9cbd
+        ])
7a9cbd
+        assert "Deleted CA \"{}\"".format(name) in result.stdout_text
7a9cbd
 
7a9cbd
     def check_subca(self, host, name, cert_nick):
7a9cbd
-        host.run_command(['ipa', 'ca-show', name])
7a9cbd
+        result = host.run_command(['ipa', 'ca-show', name])
7a9cbd
+        # ipa ca-show returns 0 even if the cert cannot be found locally.
7a9cbd
+        assert "ipa: ERROR:" not in result.stderr_text
7a9cbd
         tasks.run_certutil(
7a9cbd
             host, ['-L', '-n', cert_nick], paths.PKI_TOMCAT_ALIAS_DIR
7a9cbd
         )
7a9cbd
@@ -627,6 +645,30 @@ class TestSubCAkeyReplication(IntegrationTest):
7a9cbd
         ssl = replica.run_command(ssl_cmd)
7a9cbd
         assert 'Issuer: CN = {}'.format(self.SUBCA_MASTER) in ssl.stdout_text
7a9cbd
 
7a9cbd
+    def test_del_subca_master_on_replica(self):
7a9cbd
+        self.del_subca(self.replicas[0], self.SUBCA_MASTER)
7a9cbd
+
7a9cbd
+    def test_del_subca_replica(self):
7a9cbd
+        self.del_subca(self.replicas[0], self.SUBCA_REPLICA)
7a9cbd
+
7a9cbd
+    def test_scale_add_subca(self):
7a9cbd
+        master = self.master
7a9cbd
+        replica = self.replicas[0]
7a9cbd
+
7a9cbd
+        subcas = {}
7a9cbd
+        for i in range(0, 16):
7a9cbd
+            name = "_".join((self.SUBCA_MASTER, str(i)))
7a9cbd
+            cn = "_".join((self.SUBCA_MASTER_CN, str(i)))
7a9cbd
+            subcas[name] = self.add_subca(master, name, cn)
7a9cbd
+            self.add_subca(master, name, cn, raiseonerr=False)
7a9cbd
+
7a9cbd
+        # give replication some time
7a9cbd
+        time.sleep(15)
7a9cbd
+
7a9cbd
+        for name in subcas:
7a9cbd
+            self.check_subca(replica, name, subcas[name])
7a9cbd
+            self.del_subca(replica, name)
7a9cbd
+
7a9cbd
 
7a9cbd
 class TestReplicaInstallCustodia(IntegrationTest):
7a9cbd
     """
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 5a5962426d8174212f0b7efef1a9e53aaecb5901 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Fri, 18 Sep 2020 11:55:37 +0200
7a9cbd
Subject: [PATCH] SELinux: Add dedicated policy for ipa-pki-retrieve-key
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
Add proper labeling, transition and policy for ipa-pki-retrieve-key.
7a9cbd
Make sure tomcat_t can execute ipa-pki-retrieve-key.
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: Christian Heimes <cheimes@redhat.com>
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.fc |  1 +
7a9cbd
 selinux/ipa.te | 28 ++++++++++++++++++++++++++++
7a9cbd
 2 files changed, 29 insertions(+)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.fc b/selinux/ipa.fc
7a9cbd
index a98cc4665..1176f383c 100644
7a9cbd
--- a/selinux/ipa.fc
7a9cbd
+++ b/selinux/ipa.fc
7a9cbd
@@ -30,5 +30,6 @@
7a9cbd
 /usr/libexec/ipa/custodia/ipa-custodia-pki-tomcat		--	gen_context(system_u:object_r:ipa_custodia_pki_tomcat_exec_t,s0)
7a9cbd
 /usr/libexec/ipa/custodia/ipa-custodia-pki-tomcat-wrapped	--	gen_context(system_u:object_r:ipa_custodia_pki_tomcat_exec_t,s0)
7a9cbd
 /usr/libexec/ipa/custodia/ipa-custodia-ra-agent		--	gen_context(system_u:object_r:ipa_custodia_ra_agent_exec_t,s0)
7a9cbd
+/usr/libexec/ipa/ipa-pki-retrieve-key				--	gen_context(system_u:object_r:ipa_pki_retrieve_key_exec_t,s0)
7a9cbd
 
7a9cbd
 /var/log/ipa-custodia.audit.log(/.*)?				--	gen_context(system_u:object_r:ipa_custodia_log_t,s0)
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index 3fa4ba980..26daed293 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -75,6 +75,9 @@ files_tmp_file(ipa_custodia_tmp_t)
7a9cbd
 type pki_tomcat_cert_t;
7a9cbd
 type node_t;
7a9cbd
 
7a9cbd
+type ipa_pki_retrieve_key_exec_t;
7a9cbd
+init_script_file(ipa_pki_retrieve_key_exec_t)
7a9cbd
+
7a9cbd
 ########################################
7a9cbd
 #
7a9cbd
 # ipa_otpd local policy
7a9cbd
@@ -412,3 +415,28 @@ optional_policy(`
7a9cbd
 optional_policy(`
7a9cbd
        systemd_private_tmp(ipa_custodia_tmp_t)
7a9cbd
 ')
7a9cbd
+
7a9cbd
+optional_policy(`
7a9cbd
+    gen_require(`
7a9cbd
+        type tomcat_t;
7a9cbd
+    ')
7a9cbd
+    can_exec(tomcat_t, ipa_pki_retrieve_key_exec_t)
7a9cbd
+    pki_manage_tomcat_etc_rw(ipa_pki_retrieve_key_exec_t)
7a9cbd
+')
7a9cbd
+
7a9cbd
+optional_policy(`
7a9cbd
+    gen_require(`
7a9cbd
+        type devlog_t;
7a9cbd
+    ')
7a9cbd
+
7a9cbd
+    dontaudit ipa_custodia_t devlog_t:lnk_file read_lnk_file_perms;
7a9cbd
+')
7a9cbd
+
7a9cbd
+optional_policy(`
7a9cbd
+    java_exec(ipa_custodia_pki_tomcat_exec_t)
7a9cbd
+    # allow Java to read system status and RNG
7a9cbd
+    dev_read_urand(ipa_custodia_t)
7a9cbd
+    dev_read_rand(ipa_custodia_t)
7a9cbd
+    kernel_read_network_state(ipa_custodia_t)
7a9cbd
+    dev_read_sysfs(ipa_custodia_t)
7a9cbd
+')
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From c126610ea6605a1ff36cecf2e2f5b2cb97130831 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Fri, 18 Sep 2020 17:45:39 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: let custodia_t map custodia_tmp_t
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
This is used by the JVM perf counters.
7a9cbd
7a9cbd
Related: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 1 +
7a9cbd
 1 file changed, 1 insertion(+)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index 26daed293..0a9ccaf83 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -347,6 +347,7 @@ logging_log_filetrans(ipa_custodia_t, ipa_custodia_log_t, { dir file })
7a9cbd
 
7a9cbd
 manage_dirs_pattern(ipa_custodia_t, ipa_custodia_tmp_t, ipa_custodia_tmp_t)
7a9cbd
 manage_files_pattern(ipa_custodia_t, ipa_custodia_tmp_t, ipa_custodia_tmp_t)
7a9cbd
+mmap_exec_files_pattern(ipa_custodia_t, ipa_custodia_tmp_t, ipa_custodia_tmp_t)
7a9cbd
 files_tmp_filetrans(ipa_custodia_t, ipa_custodia_tmp_t, { dir file })
7a9cbd
 
7a9cbd
 kernel_dgram_send(ipa_custodia_t)
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 310dbd6eec337f0747d73fa87363083a742fc5dc Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Mon, 21 Sep 2020 11:32:52 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: ipa_pki_retrieve_key_exec_t =>
7a9cbd
 ipa_pki_retrieve_key_t
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
Grant pki_manage_tomcat_etc_rw to ipa_pki_retrieve_key_t instead of
7a9cbd
ipa_pki_retrieve_key_exec_t.
7a9cbd
As suggested by Ondrej Mosnáček.
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 4 +++-
7a9cbd
 1 file changed, 3 insertions(+), 1 deletion(-)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index 0a9ccaf83..92a3b2359 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -78,6 +78,8 @@ type node_t;
7a9cbd
 type ipa_pki_retrieve_key_exec_t;
7a9cbd
 init_script_file(ipa_pki_retrieve_key_exec_t)
7a9cbd
 
7a9cbd
+type ipa_pki_retrieve_key_t;
7a9cbd
+
7a9cbd
 ########################################
7a9cbd
 #
7a9cbd
 # ipa_otpd local policy
7a9cbd
@@ -422,7 +424,7 @@ optional_policy(`
7a9cbd
         type tomcat_t;
7a9cbd
     ')
7a9cbd
     can_exec(tomcat_t, ipa_pki_retrieve_key_exec_t)
7a9cbd
-    pki_manage_tomcat_etc_rw(ipa_pki_retrieve_key_exec_t)
7a9cbd
+    pki_manage_tomcat_etc_rw(ipa_pki_retrieve_key_t)
7a9cbd
 ')
7a9cbd
 
7a9cbd
 optional_policy(`
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 0518c63768b50973f3d3129547f5b4b95335f4a8 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Mon, 21 Sep 2020 11:37:12 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: ipa_custodia_pki_tomcat_exec_t =>
7a9cbd
 ipa_custodia_pki_tomcat_t
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
ipa_custodia_pki_tomcat_exec_t was granted java_exec by mistake ; replace by
7a9cbd
ipa_custodia_pki_tomcat_t.
7a9cbd
As suggested by Ondrej Mosnáček.
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 4 +++-
7a9cbd
 1 file changed, 3 insertions(+), 1 deletion(-)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index 92a3b2359..b2c618a53 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -63,6 +63,8 @@ init_script_file(ipa_custodia_dmldap_exec_t)
7a9cbd
 type ipa_custodia_pki_tomcat_exec_t;
7a9cbd
 init_script_file(ipa_custodia_pki_tomcat_exec_t)
7a9cbd
 
7a9cbd
+type ipa_custodia_pki_tomcat_t;
7a9cbd
+
7a9cbd
 type ipa_custodia_ra_agent_exec_t;
7a9cbd
 init_script_file(ipa_custodia_ra_agent_exec_t)
7a9cbd
 
7a9cbd
@@ -436,7 +438,7 @@ optional_policy(`
7a9cbd
 ')
7a9cbd
 
7a9cbd
 optional_policy(`
7a9cbd
-    java_exec(ipa_custodia_pki_tomcat_exec_t)
7a9cbd
+    java_exec(ipa_custodia_pki_tomcat_t)
7a9cbd
     # allow Java to read system status and RNG
7a9cbd
     dev_read_urand(ipa_custodia_t)
7a9cbd
     dev_read_rand(ipa_custodia_t)
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 25cf7af0d41bbd34621f37c95802675b42baeae9 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Tue, 22 Sep 2020 11:36:13 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: flag ipa_pki_retrieve_key_exec_t as
7a9cbd
 domain_type
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 1 +
7a9cbd
 1 file changed, 1 insertion(+)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index b2c618a53..42b010133 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -78,6 +78,7 @@ type pki_tomcat_cert_t;
7a9cbd
 type node_t;
7a9cbd
 
7a9cbd
 type ipa_pki_retrieve_key_exec_t;
7a9cbd
+domain_type(ipa_pki_retrieve_key_exec_t)
7a9cbd
 init_script_file(ipa_pki_retrieve_key_exec_t)
7a9cbd
 
7a9cbd
 type ipa_pki_retrieve_key_t;
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 7ad04841245668e3126cb1718ef7ec1b744526e8 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Tue, 22 Sep 2020 13:12:05 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: make interfaces for kernel modules
7a9cbd
 non-optional
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
Interfaces for kernel modules do not need to be in an optional module.
7a9cbd
Also make sure ipa_custodia_t can log.
7a9cbd
Suggested by Lukas Vrabec.
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 16 +++++++++-------
7a9cbd
 1 file changed, 9 insertions(+), 7 deletions(-)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index 42b010133..f984a0f94 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -78,10 +78,9 @@ type pki_tomcat_cert_t;
7a9cbd
 type node_t;
7a9cbd
 
7a9cbd
 type ipa_pki_retrieve_key_exec_t;
7a9cbd
-domain_type(ipa_pki_retrieve_key_exec_t)
7a9cbd
-init_script_file(ipa_pki_retrieve_key_exec_t)
7a9cbd
-
7a9cbd
 type ipa_pki_retrieve_key_t;
7a9cbd
+domain_type(ipa_pki_retrieve_key_t)
7a9cbd
+init_script_file(ipa_pki_retrieve_key_exec_t)
7a9cbd
 
7a9cbd
 ########################################
7a9cbd
 #
7a9cbd
@@ -356,6 +355,7 @@ mmap_exec_files_pattern(ipa_custodia_t, ipa_custodia_tmp_t, ipa_custodia_tmp_t)
7a9cbd
 files_tmp_filetrans(ipa_custodia_t, ipa_custodia_tmp_t, { dir file })
7a9cbd
 
7a9cbd
 kernel_dgram_send(ipa_custodia_t)
7a9cbd
+kernel_read_network_state(ipa_custodia_t)
7a9cbd
 
7a9cbd
 auth_read_passwd(ipa_custodia_t)
7a9cbd
 
7a9cbd
@@ -366,6 +366,10 @@ can_exec(ipa_custodia_t, ipa_custodia_ra_agent_exec_t)
7a9cbd
 corecmd_exec_bin(ipa_custodia_t)
7a9cbd
 corecmd_mmap_bin_files(ipa_custodia_t)
7a9cbd
 
7a9cbd
+dev_read_urand(ipa_custodia_t)
7a9cbd
+dev_read_rand(ipa_custodia_t)
7a9cbd
+dev_read_sysfs(ipa_custodia_t)
7a9cbd
+
7a9cbd
 domain_use_interactive_fds(ipa_custodia_t)
7a9cbd
 
7a9cbd
 files_mmap_usr_files(ipa_custodia_t)
7a9cbd
@@ -377,6 +381,8 @@ files_read_etc_files(ipa_custodia_t)
7a9cbd
 libs_exec_ldconfig(ipa_custodia_t)
7a9cbd
 libs_ldconfig_exec_entry_type(ipa_custodia_t)
7a9cbd
 
7a9cbd
+logging_send_syslog_msg(ipa_custodia_t)
7a9cbd
+
7a9cbd
 miscfiles_read_generic_certs(ipa_custodia_t)
7a9cbd
 miscfiles_read_localization(ipa_custodia_t)
7a9cbd
 
7a9cbd
@@ -441,8 +447,4 @@ optional_policy(`
7a9cbd
 optional_policy(`
7a9cbd
     java_exec(ipa_custodia_pki_tomcat_t)
7a9cbd
     # allow Java to read system status and RNG
7a9cbd
-    dev_read_urand(ipa_custodia_t)
7a9cbd
-    dev_read_rand(ipa_custodia_t)
7a9cbd
-    kernel_read_network_state(ipa_custodia_t)
7a9cbd
-    dev_read_sysfs(ipa_custodia_t)
7a9cbd
 ')
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd
7a9cbd
From 6a31605c1d249416ed7627755bca23a1cc45a581 Mon Sep 17 00:00:00 2001
7a9cbd
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
7a9cbd
Date: Tue, 22 Sep 2020 13:34:40 +0200
7a9cbd
Subject: [PATCH] SELinux Policy: Allow tomcat_t to read kerberos keytabs
7a9cbd
MIME-Version: 1.0
7a9cbd
Content-Type: text/plain; charset=UTF-8
7a9cbd
Content-Transfer-Encoding: 8bit
7a9cbd
7a9cbd
This is required to fix:
7a9cbd
avc: denied  { search } for  pid=1930 comm="ipa-pki-retriev" name="krb5" dev="dm-0" ino=8620822 scontext=system_u:system_r:tomcat_t:s0 tcontext=system_u:object_r:krb5_keytab_t:s0 tclass=dir permissive=0
7a9cbd
7a9cbd
Macros suggested by: Ondrej Mosnacek
7a9cbd
7a9cbd
Fixes: https://pagure.io/freeipa/issue/8488
7a9cbd
Signed-off-by: François Cami <fcami@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
7a9cbd
Reviewed-By: Christian Heimes <cheimes@redhat.com>
7a9cbd
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
7a9cbd
Reviewed-By: Ondrej Mosnacek <omosnace@redhat.com>
7a9cbd
Reviewed-By: Lukas Vrabec <lvrabec@redhat.com>
7a9cbd
Reviewed-By: Zdenek Pytela <zpytela@redhat.com>
7a9cbd
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
7a9cbd
---
7a9cbd
 selinux/ipa.te | 8 ++++++++
7a9cbd
 1 file changed, 8 insertions(+)
7a9cbd
7a9cbd
diff --git a/selinux/ipa.te b/selinux/ipa.te
7a9cbd
index f984a0f94..fa577191c 100644
7a9cbd
--- a/selinux/ipa.te
7a9cbd
+++ b/selinux/ipa.te
7a9cbd
@@ -448,3 +448,11 @@ optional_policy(`
7a9cbd
     java_exec(ipa_custodia_pki_tomcat_t)
7a9cbd
     # allow Java to read system status and RNG
7a9cbd
 ')
7a9cbd
+
7a9cbd
+optional_policy(`
7a9cbd
+    gen_require(`
7a9cbd
+        type tomcat_t;
7a9cbd
+    ')
7a9cbd
+    kerberos_read_config(tomcat_t)
7a9cbd
+    kerberos_read_keytab(tomcat_t)
7a9cbd
+')
7a9cbd
-- 
7a9cbd
2.26.2
7a9cbd