Yocto Project Discussions
 help / color / mirror / Atom feed
From: Armin Kuster <akuster808@gmail.com>
To: yocto@lists.yoctoproject.org
Cc: Yi Zhao <yi.zhao@windriver.com>, Joe MacDonald <joe@deserted.net>,
	Armin Kuster <akuster@mvista.com>
Subject: [meta-selinux][dunfell][patch 2/4] audit: set correct security context for /var/log/audit
Date: Thu, 27 Jul 2023 14:07:46 -0400	[thread overview]
Message-ID: <20230727180748.107196-3-akuster808@gmail.com> (raw)
In-Reply-To: <20230727180748.107196-1-akuster808@gmail.com>

From: Yi Zhao <yi.zhao@windriver.com>

By default /var/log is a symbolic link of /var/volatile/log. But
restorecon does not follow symbolic links then we will encounter the
following error when set /var/log/audit directory:

$ /sbin/restorecon -F /var/log/audit
/sbin/restorecon: SELinux: Could not get canonical path for /var/log/audit restorecon: Permission denied.

Use readlink to find the real path before set security context.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Joe MacDonald <joe@deserted.net>
(cherry picked from commit 8b79480663bc9de2343e0146ed8d3d0e59ab48be)
Signed-off-by: Armin Kuster <akuster@mvista.com>
---
 recipes-security/audit/audit/auditd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 mode change 100755 => 100644 recipes-security/audit/audit/auditd

diff --git a/recipes-security/audit/audit/auditd b/recipes-security/audit/audit/auditd
old mode 100755
new mode 100644
index cda2e43..6aa7f94
--- a/recipes-security/audit/audit/auditd
+++ b/recipes-security/audit/audit/auditd
@@ -86,7 +86,7 @@ do_reload() {
 
 if [ ! -e /var/log/audit ]; then
 	mkdir -p /var/log/audit
-	[ -x /sbin/restorecon ] && /sbin/restorecon -F /var/log/audit
+	[ -x /sbin/restorecon ] && /sbin/restorecon -F $(readlink -f /var/log/audit)
 fi
 
 case "$1" in
-- 
2.34.1



  parent reply	other threads:[~2023-07-27 18:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 18:07 [meta-selinux][dunfell][patch 0/4] Selinux failed to enable do to errors Armin Kuster
2023-07-27 18:07 ` [meta-selinux][dunfell][patch 1/4] refpolicy: remove version 2.20190201 Armin Kuster
2023-07-27 18:07 ` Armin Kuster [this message]
2023-07-27 18:07 ` [meta-selinux][dunfell][patch 3/4] sysklogd: set correct security context for /var/log in initscript Armin Kuster
2023-07-27 18:07 ` [meta-selinux][dunfell][patch 4/4] refpolicy: update to 20200229+git Armin Kuster

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=20230727180748.107196-3-akuster808@gmail.com \
    --to=akuster808@gmail.com \
    --cc=akuster@mvista.com \
    --cc=joe@deserted.net \
    --cc=yi.zhao@windriver.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