Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/portage-stable-packages-list
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ sec-policy/selinux-base
sec-policy/selinux-base-policy
sec-policy/selinux-container
sec-policy/selinux-dbus
sec-policy/selinux-docker
sec-policy/selinux-policykit
sec-policy/selinux-sssd
sec-policy/selinux-unconfined
Expand Down
11 changes: 7 additions & 4 deletions build_library/build_image_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,10 @@ EOF
local real_root_fs_dir
real_root_fs_dir=$(realpath "${root_fs_dir}")
# TODO: Breaks the system:
# sudo setfiles -Dv -r "${real_root_fs_dir}" "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"
# sudo setfiles -Dv -r "${real_root_fs_dir}" "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"/usr
# sudo setfiles -Dv -r "${real_root_fs_dir}" -c "${real_root_fs_dir}"/etc/selinux/mcs/policy/policy.* "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"
# sudo setfiles -Dv -r "${real_root_fs_dir}" -c "${real_root_fs_dir}"/etc/selinux/mcs/policy/policy.* "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"/usr
# For now we only try it with /etc
sudo setfiles -Dv -r "${real_root_fs_dir}" "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"/etc
sudo setfiles -Dv -r "${real_root_fs_dir}" -c "${real_root_fs_dir}"/etc/selinux/mcs/policy/policy.* "${real_root_fs_dir}"/etc/selinux/mcs/contexts/files/file_contexts "${real_root_fs_dir}"/etc
fi

# Temporary hack: set group ownership of /etc/{g,}shadow to the
Expand Down Expand Up @@ -719,7 +719,10 @@ EOF
sudo cp -a "${root_fs_dir}/etc" "${root_fs_dir}/usr/lib/confexts/00-flatcar-default/etc"
sudo mkdir -p "${root_fs_dir}/usr/lib/confexts/00-flatcar-default/etc/extension-release.d/"
echo ID=_any | sudo tee "${root_fs_dir}/usr/lib/confexts/00-flatcar-default/etc/extension-release.d/extension-release.00-flatcar-default" > /dev/null
sudo systemd-repart \
# systemd-repart stages in /var/tmp by default. Inside the SDK, this is within
# Docker's overlay, which may silently fail to accept SELinux labelling
# changes. We must therefore repoint TMPDIR to a bind-mounted directory.
sudo TMPDIR="${BUILD_DIR}" systemd-repart \
--private-key="${SYSEXT_SIGNING_KEY_DIR}/sysexts.key" \
--certificate="${SYSEXT_SIGNING_KEY_DIR}/sysexts.crt" \
--make-ddi=confext \
Expand Down
15 changes: 13 additions & 2 deletions build_sysext
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export SOURCE_DATE_EPOCH=$(stat -c '%Y' "${BUILD_DIR}/fs-root/usr/lib/os-release

# Unmount in order to get rid of the overlay
umount "${BUILD_DIR}/${FLAGS_install_root_basename}"
umount "${BUILD_DIR}/fs-root"

if [[ "$FLAGS_generate_pkginfo" = "${FLAGS_TRUE}" ]] ; then
info " Creating pkginfo squashfs '${BUILD_DIR}/${SYSEXT_ID}_pkginfo.raw'"
Expand Down Expand Up @@ -305,6 +304,15 @@ EOF
info "Removing opaque directory markers to always merge all contents"
find "${BUILD_DIR}/${FLAGS_install_root_basename}" -xdev -type d -exec sh -c 'if [ "$(attr -R -q -g overlay.opaque {} 2>/dev/null)" = y ]; then attr -R -r overlay.opaque {}; fi' \;

if pkg_use_enabled coreos-base/coreos selinux; then
# setfiles from version 3.11 requires the passed path to have no symlinks
real_install_root=$(realpath "${BUILD_DIR}/${FLAGS_install_root_basename}")
real_fs_root=$(realpath "${BUILD_DIR}/fs-root")
setfiles -Dv -r "${real_install_root}" -c "${real_fs_root}"/etc/selinux/mcs/policy/policy.* "${real_fs_root}/etc/selinux/mcs/contexts/files/file_contexts" "${real_install_root}/usr"
fi

umount "${BUILD_DIR}/fs-root"

info "Checking for invalid file ownership"
invalid_files=$(find "${BUILD_DIR}/${FLAGS_install_root_basename}" -user sdk -or -group sdk)
if [[ -n "${invalid_files}" ]]; then
Expand All @@ -330,7 +338,10 @@ else
info "Building sysext without compression (built-in sysexts)"
fi

systemd-repart \
# systemd-repart stages in /var/tmp by default. Inside the SDK, this is within
# Docker's overlay, which may silently fail to accept SELinux labelling changes.
# We must therefore repoint TMPDIR to a bind-mounted directory.
TMPDIR="${BUILD_DIR}" systemd-repart \
--sector-size=4096 \
--private-key="${SYSEXT_SIGNING_KEY_DIR}/sysexts.key" \
--certificate="${SYSEXT_SIGNING_KEY_DIR}/sysexts.crt" \
Expand Down
1 change: 1 addition & 0 deletions changelog/bugfixes/2026-11-17-extensions-selinux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed SELinux labelling of the confexts and system dependent sysexts. These were previously labelled entirely with `container_file_t`. ([scripts#4385](https://github.com/flatcar/scripts/pull/4385))
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ RDEPEND="${RDEPEND}
sec-policy/selinux-base-policy
sec-policy/selinux-container
sec-policy/selinux-dbus
sec-policy/selinux-docker
sec-policy/selinux-policykit
sec-policy/selinux-unconfined
sys-apps/acl
Expand Down
Loading