Repository navigation
Replies: 1 comment
|
I asked Claude to lay out my solution in a straightforward, step-by-step manner, so this should be pretty easy to follow. Let me know if you need any extra help. Neither a bug nor holding it wrong — a sysext falls straight through the condition that decides whether to relabel, and because the default is 1. The check looks for the policy inside the image. selinux = root / "etc/selinux/config"
if not selinux.exists():
if fatal and config.selinux_relabel == ConfigFeature.enabled:
die("SELinux relabel is requested but could not find selinux config at /etc/selinux/config")
return Noneand, further down, it reads 2. Why you got no warning. 3. Setting 4. Relabel against the host policy in a finalize script instead. #!/bin/sh
# mkosi.finalize
[ "$1" = "final" ] || exit 0
setfiles -m -F -r "$BUILDROOT" \
/etc/selinux/targeted/contexts/files/file_contexts \
"$BUILDROOT/usr"That is the same setfiles invocation mkosi itself uses ( 5. Two things to keep in mind. Build as root — the man page notes that unprivileged setfiles cannot set labels absent from the host policy. And check the result before rebooting, because a sysext that hangs the boot is an unpleasant way to find out: unsquashfs -l emacs.raw | head # or the erofs equivalent
getfattr -n security.selinux -d <a file from the merged /usr>6. If this is deemed worth changing upstream, the small version is making the |
Uh oh!
There was an error while loading. Please reload this page.
Recently, I figured out that I could use
mkosito build a sysext containing a custom Emacs build for my system.It worked fine, until I restarted my machine. The machine would boot, but then hang on a black screen. Luckily I could get to a tty, login and disable my custom sysext. After which the machine boots again as normal.
I think I have identified the underlying issue. However, I'm not sure if this is a bug in
mkosior if I'm just holding it wrong.Looking in
journalctlin the affected boots I get 100s-1000s of SELinux denials after the stage where my sysexts are enabledI don't understand SELinux, but I think
tcontext=unconfined_u:object_r:unlabeled_t:s0means it doesn't like something being unlabelled.After seeing the discussion in #130 and discovering
SELinuxRelabel=I added theselinux-polcyFedora package to thebaseimage, andmkosiwas able to relabel the files ok. However, when the sysext is enabled, some of my directories are still unlabelled.If I mount the image with
systemd-dissectall the directories appear to be unlabeled - basically the opposite issue seen in #3148 😅Here is my current config
mkosi.conf
mkosi.images/base/mkosi.conf
mkosi.images/emacs/mkosi.conf
mkosi.images/emacs/mkosi.build.chroot
I did some poking around with a
mkosi.finalisescript and some of the directories appear to have a label, but they seem to lose it by the time they make it to theerofsimage.If anyone has any thoughts/suggestions it would be much appreciated :)
All reactions