It appears that since commit ca6aa02 (sysext.just: Install packages in SELinux stage as needed), building the libvirtd and libvirtd-desktop sysexts fails during the reset-selinux-labels step with:
setfiles: Could not set context for ./usr/bin/swtpm: Invalid argument
error: Recipe `reset-selinux-labels` failed with exit code 255
This affects both the FCOS and Fedora Atomic Desktop base images, confirming the issue is not specific to any one base image but affects any base image that does not ship the full Fedora SELinux policy.
For reference, simpler sysexts like python3 build successfully without any workaround, confirming the regression is specific to sysexts that include packages whose file contexts are absent from the base image policy.
Root cause
Commit ca6aa02 introduced an optimization that only installs packages inside the podman container during the SELinux labeling step when ./rootfs/usr/share/selinux/packages exists. The commit message states:
"We only need to install the packages from the sysext in the container if there are additional SELinux modules"
However, it seems this does not hold for sysexts that include packages whose file contexts exist in the full Fedora policy but are absent from the base image policy. Since neither libvirtd nor libvirtd-desktop ship a custom SELinux policy module, that directory is absent, so the container runs setfiles using only the bare base image policy.
The base image policy does not include file contexts for all packages in these sysexts — in particular swtpm, qemu-kvm, and related packages. When setfiles encounters a file with no matching context in the policy, it returns EINVAL.
Before ca6aa02, packages were always installed in the container before running setfiles, so the full Fedora policy was available and all files could be labeled correctly.
Steps to reproduce
- Clone the repo on a host with SELinux enforcing
cd libvirtd (or cd libvirtd-desktop)
just build quay.io/fedora/fedora-coreos:stable x86_64 (or just build quay.io/fedora-ostree-desktops/base-atomic:42 x86_64)
- Observe
setfiles: Could not set context for ./usr/bin/swtpm: Invalid argument
Workaround
Override reset-selinux-labels in the local justfile to run setfiles directly on the host (requires root and a host with SELinux enforcing + full Fedora policy installed). Confirmed working for both libvirtd and libvirtd-desktop:
reset-selinux-labels target arch=arch:
#!/bin/bash
set -euo pipefail
if [[ -n "{{debug}}" ]]; then
set -x
fi
echo "🏷 Resetting SELinux labels"
cd rootfs
setfiles -r . /etc/selinux/targeted/contexts/files/file_contexts .
chcon --user=system_u --recursive .
Expected behavior
Sysexts that do not ship a custom SELinux policy module but include packages whose file contexts are not in the base image policy should still be labeled correctly.
Environment
- Host OS: Fedora Server 43 (SELinux enforcing, targeted policy)
- Affected sysexts:
libvirtd, libvirtd-desktop
- Target images affected:
quay.io/fedora/fedora-coreos:stable (libvirtd)
quay.io/fedora-ostree-desktops/base-atomic:42/43/44 (libvirtd-desktop)
- Likely affected: any sysext including packages not in the base image policy (e.g.
swtpm, qemu-kvm) without a custom SELinux policy module
It appears that since commit ca6aa02 (
sysext.just: Install packages in SELinux stage as needed), building thelibvirtdandlibvirtd-desktopsysexts fails during thereset-selinux-labelsstep with:This affects both the FCOS and Fedora Atomic Desktop base images, confirming the issue is not specific to any one base image but affects any base image that does not ship the full Fedora SELinux policy.
For reference, simpler sysexts like
python3build successfully without any workaround, confirming the regression is specific to sysexts that include packages whose file contexts are absent from the base image policy.Root cause
Commit ca6aa02 introduced an optimization that only installs packages inside the podman container during the SELinux labeling step when
./rootfs/usr/share/selinux/packagesexists. The commit message states:However, it seems this does not hold for sysexts that include packages whose file contexts exist in the full Fedora policy but are absent from the base image policy. Since neither
libvirtdnorlibvirtd-desktopship a custom SELinux policy module, that directory is absent, so the container runssetfilesusing only the bare base image policy.The base image policy does not include file contexts for all packages in these sysexts — in particular
swtpm,qemu-kvm, and related packages. Whensetfilesencounters a file with no matching context in the policy, it returnsEINVAL.Before ca6aa02, packages were always installed in the container before running
setfiles, so the full Fedora policy was available and all files could be labeled correctly.Steps to reproduce
cd libvirtd(orcd libvirtd-desktop)just build quay.io/fedora/fedora-coreos:stable x86_64(orjust build quay.io/fedora-ostree-desktops/base-atomic:42 x86_64)setfiles: Could not set context for ./usr/bin/swtpm: Invalid argumentWorkaround
Override
reset-selinux-labelsin the localjustfileto runsetfilesdirectly on the host (requires root and a host with SELinux enforcing + full Fedora policy installed). Confirmed working for bothlibvirtdandlibvirtd-desktop:Expected behavior
Sysexts that do not ship a custom SELinux policy module but include packages whose file contexts are not in the base image policy should still be labeled correctly.
Environment
libvirtd,libvirtd-desktopquay.io/fedora/fedora-coreos:stable(libvirtd)quay.io/fedora-ostree-desktops/base-atomic:42/43/44(libvirtd-desktop)swtpm,qemu-kvm) without a custom SELinux policy module