public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Danish Prakash <contact@danishpraka.sh>
To: Max Chernoff <git@maxchernoff.ca>, Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top, Paul Holzinger <pholzing@redhat.com>
Subject: Re: [PATCH] contrib/selinux: use regex instead of non-standard bash macro
Date: Mon, 27 Oct 2025 14:19:14 +0530	[thread overview]
Message-ID: <3aad50bb-aab8-423f-9730-21f9a3b3de78@danishpraka.sh> (raw)
In-Reply-To: <a450f3806fab8042e87a7f47574969b7b3a0db69.camel@maxchernoff.ca>

On 10/16/25 4:26 PM, Max Chernoff wrote:
> Hi Stefano,
> 
> On Thu, 2025-10-16 at 10:21 +0200, Stefano Brivio wrote:
>> On Thu, 16 Oct 2025 13:10:41 +0530
>> Danish Prakash <contact@danishpraka.sh> wrote:
>>> It might be possible to avoid using non-standard bash macro (%USERID),
> 
> It's not a Bash macro, it's a SELinux template. This doesn't seem to be
> documented anywhere (which isn't terribly surprising with SELinux), but
> it's defined in this file:
> 
>     https://github.com/SELinuxProject/selinux/blob/ceb5b221/libsemanage/src/genhomedircon.c

Thanks Max, I wasn't aware of it being an SELinux template.

> 
>> I wonder if
>> Max remembers any reason why we couldn't do this in the first place.
> 
> The Fedora SELinux policy always uses %{USERID}, and so I copied it from
> there:
> 
>     $ grep -RnF '%{USERID}' policy/
>     policy/modules/contrib/dbus.fc:29:/run/user/%{USERID}/bus	-s	gen_context(system_u:object_r:session_dbusd_tmp_t,s0)
>     policy/modules/contrib/dbus.fc:30:/run/user/%{USERID}/dbus(/.*)? 	gen_context(system_u:object_r:session_dbusd_tmp_t,s0)
>     policy/modules/contrib/dbus.fc:31:/run/user/%{USERID}/dbus-1(/.*)? 	gen_context(system_u:object_r:session_dbusd_tmp_t,s0)
>     policy/modules/contrib/gnome.fc:25:/run/user/%{USERID}/\.orc(/.*)?		gen_context(system_u:object_r:gstreamer_home_t,s0)
>     policy/modules/contrib/gnome.fc:26:/run/user/%{USERID}/dconf(/.*)?	gen_context(system_u:object_r:config_home_t,s0)
>     policy/modules/contrib/gnome.fc:27:/run/user/%{USERID}/keyring.*	gen_context(system_u:object_r:gkeyringd_tmp_t,s0)
>     policy/modules/kernel/filesystem.fc:17:/run/user/%{USERID}/gvfs		-d	gen_context(system_u:object_r:fusefs_t,s0)
>     policy/modules/kernel/filesystem.fc:18:/run/user/%{USERID}/gvfs/.*	<<none>>
>     policy/modules/system/userdomain.fc:38:/run/user/%{USERID}	-d	gen_context(system_u:object_r:user_tmp_t,s0)
>     policy/modules/system/userdomain.fc:39:/run/user/%{USERID}/.+	<<none>>
> 
>     $ grep -RnF '[0-9]+' policy/  | grep -v /dev/
>     policy/modules/contrib/rpm.fc:52:/usr/bin/rhn_check-[0-9]+\.[0-9]+		--	gen_context(system_u:object_r:rpm_exec_t,s0)
>     policy/modules/contrib/soundserver.fc:12:/run/yiff-[0-9]+\.pid	--	gen_context(system_u:object_r:soundd_var_run_t,s0)
>     policy/modules/kernel/devices.if:6958:##	Allow read the hfi1_[0-9]+ devices
> 
>>> 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
>>> [...]
>>
>> At a glance, this looks like a better solution regardless of the
>> reported issue. It sounds too good to be true, though
> 
> I agree that it looks like a good solution, which makes me wonder why
> the base SELinux policies don't do it that way. The containers SELinux
> policy appears to do things this way
> 
>     $ grep -RnF '[0-9]+'
>     container_selinux.8:166:	/run/user/[0-9]+/gvfs
>     $ grep -RnF '%{USERID}'; echo $?
>     1
> 
> so it's probably (?) okay though.

That's helpful, I guess we can go ahead with this. Stefano, Paul?

> 
> Thanks,
> -- Max


-- 
danishpraka.sh

  reply	other threads:[~2025-10-27  8:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16  7:40 Danish Prakash
2025-10-16  8:21 ` Stefano Brivio
2025-10-16 10:56   ` Max Chernoff
2025-10-27  8:49     ` Danish Prakash [this message]
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=3aad50bb-aab8-423f-9730-21f9a3b3de78@danishpraka.sh \
    --to=contact@danishpraka.sh \
    --cc=git@maxchernoff.ca \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    --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).