From: Danish Prakash <contact@danishpraka.sh>
To: sbrivio@redhat.com
Cc: passt-dev@passt.top, Danish Prakash <contact@danishpraka.sh>
Subject: [PATCH] contrib/selinux: use regex instead of non-standard bash macro
Date: Thu, 16 Oct 2025 13:10:41 +0530 [thread overview]
Message-ID: <20251016074045.562352-1-contact@danishpraka.sh> (raw)
It might be possible to avoid using non-standard bash macro (%USERID),
and instead using regex to match user ids. This would also mean
discarding the explicit restorecon call while packaging[1].
[1] - https://passt.top/passt/commit/?id=e019323538699967c155c29411545223dadfc0f5
Link: https://bugzilla.suse.com/show_bug.cgi?id=1246291
Signed-off-by: Danish Prakash <contact@danishpraka.sh>
---
contrib/fedora/passt.spec | 11 -----------
contrib/selinux/pasta.fc | 12 ++++++------
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec
index 663289f53d97..d1bcf4a74338 100644
--- a/contrib/fedora/passt.spec
+++ b/contrib/fedora/passt.spec
@@ -103,17 +103,6 @@ fi
%posttrans selinux
%selinux_relabel_post -s %{selinuxtype}
-# %selinux_relabel_post calls fixfiles(8) with the previous file_contexts file
-# (see selabel_file(5)) in order to restore only the file contexts which
-# actually changed. However, as file_contexts doesn't support %{USERID}
-# substitutions, this will not work for specific file contexts that pasta needs
-# to have under /run/user.
-#
-# Restore those explicitly, hiding errors from restorecon(8): we can't pass a
-# path that's more specific than this, but at the same time /run/user often
-# contains FUSE mountpoints that can't be accessed as root, leading to
-# "Permission denied" messages, but not failures.
-restorecon -R /run/user 2>/dev/null
%files
%license LICENSES/{GPL-2.0-or-later.txt,BSD-3-Clause.txt}
diff --git a/contrib/selinux/pasta.fc b/contrib/selinux/pasta.fc
index e60c6148f412..82dbcbe2b75e 100644
--- a/contrib/selinux/pasta.fc
+++ b/contrib/selinux/pasta.fc
@@ -12,11 +12,11 @@
/usr/bin/pasta.avx2 system_u:object_r:pasta_exec_t:s0
/tmp/pasta\.pcap system_u:object_r:pasta_log_t:s0
/var/run/pasta\.pid system_u:object_r:pasta_pid_t:s0
-/run/user/%{USERID}/netns system_u:object_r:ifconfig_var_run_t:s0
-/run/user/%{USERID}/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
+/run/user/[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/run/user/[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
# In case XDG_RUNTIME_DIR is not set (i.e. no systemd user session) Podman falls
# back to a location under /tmp
-/tmp/storage-run-%{USERID}/netns system_u:object_r:ifconfig_var_run_t:s0
-/tmp/storage-run-%{USERID}/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
-/tmp/containers-user-%{USERID}/netns system_u:object_r:ifconfig_var_run_t:s0
-/tmp/containers-user-%{USERID}/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/storage-run-[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/storage-run-[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/containers-user-[0-9]+/netns system_u:object_r:ifconfig_var_run_t:s0
+/tmp/containers-user-[0-9]+/containers/networks/rootless-netns system_u:object_r:ifconfig_var_run_t:s0
--
2.51.0
next reply other threads:[~2025-10-16 7:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 7:40 Danish Prakash [this message]
2025-10-16 8:21 ` Stefano Brivio
2025-10-16 10:56 ` Max Chernoff
2025-10-27 8:49 ` Danish Prakash
2025-10-27 9:07 ` Stefano Brivio
2025-10-27 9:41 ` Max Chernoff
2025-10-28 6:28 ` Danish Prakash
2025-10-28 23:17 ` Stefano Brivio
2025-10-30 8:20 ` [PATCH v2] contrib/selinux: use regex instead of SELinux template Danish Prakash
2025-10-30 8:37 ` [PATCH] contrib/selinux: use regex instead of non-standard bash macro Danish Prakash
2025-10-30 8:43 ` Stefano Brivio
2025-10-30 10:06 ` Stefano Brivio
2025-10-30 10:50 ` Danish Prakash
2025-10-30 10:49 ` [PATCH v2] contrib/selinux: use regex instead of SELinux template Danish Prakash
2025-11-04 6:48 ` Max Chernoff
2025-11-04 21:13 ` Stefano Brivio
2025-11-05 10:28 ` Max Chernoff
2025-11-05 15:31 ` Stefano Brivio
2025-11-06 12:09 ` Max Chernoff
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=20251016074045.562352-1-contact@danishpraka.sh \
--to=contact@danishpraka.sh \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).