From 1174a84b28800e4ab751659131f6c9ff88e24151 Mon Sep 17 00:00:00 2001 From: qpismont Date: Sun, 1 Nov 2026 21:58:09 +0100 Subject: [PATCH] Verify flatpak SELinux label at build time Replace the best-effort semodule/setfiles workarounds with a build-time check that fails fast if flatpak-system-helper is not labeled flatpak_helper_exec_t. Also reinstall flatpak-selinux to ensure the policy is present. --- Containerfile | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/Containerfile b/Containerfile index 15a55b3..a00456e 100644 --- a/Containerfile +++ b/Containerfile @@ -57,11 +57,17 @@ RUN dnf install -y --refresh --setopt=tsflags=nodocs \ gstreamer1-plugins-base \ gstreamer1-vaapi \ ffmpeg \ - flatpak \ && (dnf remove -y alacritty waybar gnome-software gnome-software-rpm-ostree gnome-system-monitor showtime decibels snapshot PackageKit PackageKit-gstreamer-plugin PackageKit-command-not-found toolbox || true) \ && dnf install -y flatpak \ + && dnf reinstall -y flatpak-selinux \ && dnf clean all +#Verifie que la politique SELinux connait bien le label du helper flatpak. Sans ce +#module (paquet flatpak-selinux), le binaire reste "unlabeled_t", systemd refuse +#de l'executer (203/EXEC) et /usr etant en lecture seule au runtime, l'image serait +#inutilisable pour flatpak. Mieux vaut un build qui echoue qu'une image cassee. +RUN matchpathcon /usr/libexec/flatpak-system-helper | grep -q flatpak_helper_exec_t + #Configuration de GDM : clavier FR (GNOME Initial Setup cree le premier compte au boot) COPY config/xorg-keyboard.conf /etc/X11/xorg.conf.d/00-keyboard.conf @@ -71,25 +77,6 @@ RUN wget https://cdn.filen.io/@filen/desktop/release/latest/Filen_linux_x86_64.r && dnf clean all \ && rm -f /tmp/filen.rpm -#SELinux : dans certains environnements de build (buildah rootful/overlay), les -#transactions semodule des scriptlets rpm echouent (sandbox /etc/selinux/targeted/tmp) -#et le module flatpak n'arrive jamais dans le store -> le helper reste unlabeled_t. -#On (re)installe explicitement le module puis on recompile la politique, en -#meilleur effort pour ne pas casser le build. -RUN rm -rf /etc/selinux/targeted/tmp; \ - semodule -i /usr/share/selinux/packages/flatpak.pp.bz2 \ - || echo "AVERTISSEMENT: module SELinux flatpak non installe"; \ - semodule -n -B \ - || { echo "AVERTISSEMENT: politique SELinux non recompilee dans ce build"; ls -la /etc/selinux/targeted; }; \ - true - -#Relabelle /usr depuis les file_contexts du store : rpm peut installer un binaire -#(flatpak-system-helper) avant que le module SELinux de son paquet ne soit pris en -#compte, et le fichier reste sans label. Comme /usr est en lecture seule sur le -#systeme deploye, le label doit etre correct dans l'image. -RUN setfiles -r / -F /etc/selinux/targeted/active/file_contexts /usr/libexec /usr/bin /usr/sbin \ - || echo "AVERTISSEMENT: relabel partiel de /usr" - #Installation de starship RUN curl -sS https://starship.rs/install.sh | sh -s -- -y