diff mbox series

[meta-selinux,2/4] refpolicy: label start_getty as bin_t in corecommands.fc

Message ID 20261124114137.2203106-3-chenqi_hycx@cetc.com.cn
State New
Headers show
Series Add selint and fix local refpolicy patches | expand

Commit Message

Chen Qi Nov. 24, 2026, 11:41 a.m. UTC
From: Chen Qi <chenqi_hycx@cetc.com.cn>

SELint reports:

  getty.fc: 7: (S): Type bin_t is declared in module corecommands, but
  used in file context here. (S-002)

bin_t is declared in corecommands, so the context for the wrapper script
belongs in that module.

Assisted-by: Codewhale:deepseek-flash
Signed-off-by: Chen Qi <chenqi_hycx@cetc.com.cn>
---
 ...ecommands-label-start_getty-as-bin_t.patch | 30 +++++++++++++++++++
 ...etty-add-file-context-to-start_getty.patch | 27 -----------------
 .../refpolicy/refpolicy_common.inc            |  2 +-
 3 files changed, 31 insertions(+), 28 deletions(-)
 create mode 100644 recipes-security/refpolicy/refpolicy/0023-fc-corecommands-label-start_getty-as-bin_t.patch
 delete mode 100644 recipes-security/refpolicy/refpolicy/0023-fc-getty-add-file-context-to-start_getty.patch
diff mbox series

Patch

diff --git a/recipes-security/refpolicy/refpolicy/0023-fc-corecommands-label-start_getty-as-bin_t.patch b/recipes-security/refpolicy/refpolicy/0023-fc-corecommands-label-start_getty-as-bin_t.patch
new file mode 100644
index 0000000..6353aa7
--- /dev/null
+++ b/recipes-security/refpolicy/refpolicy/0023-fc-corecommands-label-start_getty-as-bin_t.patch
@@ -0,0 +1,30 @@ 
+From 75ad7b87b85a3fb0f0d00b88831a3171a01e8fa0 Mon Sep 17 00:00:00 2001
+From: Yi Zhao <yi.zhao@windriver.com>
+Date: Fri, 15 Nov 2019 16:07:30 +0800
+Subject: [PATCH] fc/corecommands: label start_getty as bin_t
+
+start_getty is a wrapper script, so it must not inherit getty_exec_t
+from the /usr/bin/.*getty pattern.  bin_t is declared in corecommands,
+hence the label belongs in that module's file context.
+
+Upstream-Status: Inappropriate [embedded specific]
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ policy/modules/kernel/corecommands.fc | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/policy/modules/kernel/corecommands.fc b/policy/modules/kernel/corecommands.fc
+index 110e7471d..3b13d3ba8 100644
+--- a/policy/modules/kernel/corecommands.fc
++++ b/policy/modules/kernel/corecommands.fc
+@@ -178,6 +178,7 @@ ifdef(`distro_gentoo',`
+ /usr/bin/scponlyc		--	gen_context(system_u:object_r:shell_exec_t,s0)
+ /usr/bin/sh			--	gen_context(system_u:object_r:shell_exec_t,s0)
+ /usr/bin/smrsh			--	gen_context(system_u:object_r:shell_exec_t,s0)
++/usr/bin/start_getty		--	gen_context(system_u:object_r:bin_t,s0)
+ /usr/bin/tcsh			--	gen_context(system_u:object_r:shell_exec_t,s0)
+ /usr/bin/yash			--	gen_context(system_u:object_r:shell_exec_t,s0)
+ /usr/bin/zsh.*			--	gen_context(system_u:object_r:shell_exec_t,s0)
+-- 
+2.34.1
diff --git a/recipes-security/refpolicy/refpolicy/0023-fc-getty-add-file-context-to-start_getty.patch b/recipes-security/refpolicy/refpolicy/0023-fc-getty-add-file-context-to-start_getty.patch
deleted file mode 100644
index e9b70b2..0000000
--- a/recipes-security/refpolicy/refpolicy/0023-fc-getty-add-file-context-to-start_getty.patch
+++ /dev/null
@@ -1,27 +0,0 @@ 
-From 75ad7b87b85a3fb0f0d00b88831a3171a01e8fa0 Mon Sep 17 00:00:00 2001
-From: Yi Zhao <yi.zhao@windriver.com>
-Date: Fri, 15 Nov 2019 16:07:30 +0800
-Subject: [PATCH] fc/getty: add file context to start_getty
-
-Upstream-Status: Inappropriate [embedded specific]
-
-Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
----
- policy/modules/system/getty.fc | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/policy/modules/system/getty.fc b/policy/modules/system/getty.fc
-index c7701c930..8b70b609a 100644
---- a/policy/modules/system/getty.fc
-+++ b/policy/modules/system/getty.fc
-@@ -4,6 +4,7 @@
- /run/agetty\.reload	--	gen_context(system_u:object_r:getty_runtime_t,s0)
- 
- /usr/bin/.*getty	--	gen_context(system_u:object_r:getty_exec_t,s0)
-+/usr/bin/start_getty	--	gen_context(system_u:object_r:bin_t,s0)
- 
- 
- /var/log/mgetty\.log.*	--	gen_context(system_u:object_r:getty_log_t,s0)
--- 
-2.34.1
-
diff --git a/recipes-security/refpolicy/refpolicy_common.inc b/recipes-security/refpolicy/refpolicy_common.inc
index 3f629bc..be0aa83 100644
--- a/recipes-security/refpolicy/refpolicy_common.inc
+++ b/recipes-security/refpolicy/refpolicy_common.inc
@@ -38,7 +38,7 @@  SRC_URI += " \
         file://0020-fc-ldap-apply-policy-to-ldap-alternatives.patch \
         file://0021-fc-postgresql-apply-policy-to-postgresql-alternative.patch \
         file://0022-fc-usermanage-apply-policy-to-usermanage-alternative.patch \
-        file://0023-fc-getty-add-file-context-to-start_getty.patch \
+        file://0023-fc-corecommands-label-start_getty-as-bin_t.patch \
         file://0024-fc-vlock-apply-policy-to-vlock-alternatives.patch \
         file://0025-fc-add-fcontext-for-init-scripts-and-systemd-service.patch \
         file://0026-file_contexts.subs_dist-set-aliase-for-root-director.patch \