Yocto Project Discussions
 help / color / mirror / Atom feed
From: Yi Zhao <yi.zhao@windriver.com>
To: yocto@lists.yoctoproject.org, joe_macdonald@mentor.com, joe@deserted.net
Subject: [meta-selinux][PATCH 2/4] base-files: set correct label for /var/volatile
Date: Wed,  2 Nov 2022 15:30:50 +0800	[thread overview]
Message-ID: <20221102073052.1567876-2-yi.zhao@windriver.com> (raw)
In-Reply-To: <20221102073052.1567876-1-yi.zhao@windriver.com>

By default /var/volatile will be mounted with tmpfs_t instead of var_t
label, which will cause us to have to add some extra rules to eliminate
avc denials of some services.

Set rootcontext for /var/volatile in fstab to make sure it is mounted
with correct label.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 recipes-core/base-files/base-files_%.bbappend  |  1 +
 recipes-core/base-files/base-files_selinux.inc | 13 +++++++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 recipes-core/base-files/base-files_%.bbappend
 create mode 100644 recipes-core/base-files/base-files_selinux.inc

diff --git a/recipes-core/base-files/base-files_%.bbappend b/recipes-core/base-files/base-files_%.bbappend
new file mode 100644
index 0000000..f167033
--- /dev/null
+++ b/recipes-core/base-files/base-files_%.bbappend
@@ -0,0 +1 @@
+require ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'base-files_selinux.inc', '', d)}
diff --git a/recipes-core/base-files/base-files_selinux.inc b/recipes-core/base-files/base-files_selinux.inc
new file mode 100644
index 0000000..f2373aa
--- /dev/null
+++ b/recipes-core/base-files/base-files_selinux.inc
@@ -0,0 +1,13 @@
+REFPOLICY_TYPE = "${@d.getVar('PREFERRED_PROVIDER_virtual/refpolicy').split('-')[1] or ''}"
+
+do_install:append () {
+    if [ -n "${REFPOLICY_TYPE}" ]; then
+        if [ "${REFPOLICY_TYPE}" = "standard" ]; then
+            sed -i 's/\s*\/var\/volatile\s*tmpfs\s*defaults/&,rootcontext=system_u:object_r:var_t/' \
+                ${D}${sysconfdir}/fstab
+        else
+            sed -i 's/\s*\/var\/volatile\s*tmpfs\s*defaults/&,rootcontext=system_u:object_r:var_t:s0/' \
+                ${D}${sysconfdir}/fstab
+        fi
+    fi
+}
-- 
2.25.1



  reply	other threads:[~2022-11-02  7:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02  7:30 [meta-selinux][PATCH 1/4] SELinux-FAQ: remove references to poky-selinux distro Yi Zhao
2022-11-02  7:30 ` Yi Zhao [this message]
2022-11-02  7:30 ` [meta-selinux][PATCH 3/4] libsepol: fix build failure for refpolicy-mls Yi Zhao
2022-11-02  7:30 ` [meta-selinux][PATCH 4/4] refpolicy: upgrade 20210908+git -> 20221101+git Yi Zhao
     [not found]   ` <20221107193343.jrkm4tdey75dwev6@siemens.com>
2022-11-08  2:29     ` Yi Zhao
     [not found]     ` <17257B1B9EFC9AB1.28792@lists.yoctoproject.org>
2022-11-09  3:47       ` [yocto] " Yi Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102073052.1567876-2-yi.zhao@windriver.com \
    --to=yi.zhao@windriver.com \
    --cc=joe@deserted.net \
    --cc=joe_macdonald@mentor.com \
    --cc=yocto@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox