Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo: Don't try to perform labeling if SELinux is disabled #1665

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

cgwalters
Copy link
Collaborator

The default for container execution is that /sys/fs/selinux is not mounted, and the libselinux library function is_selinux_enabled should be used to dynamically check if the system should attempt to perform SELinux labeling.

This is how it's done by rpm, ostree, and systemd for example.

But this code unconditionally tries to label if it finds a policy, which breaks in an obscure corner case
when executed inside a container that includes policy files (e.g. fedora/rhel-bootc) but when we're not using overlayfs for the backend (with BUILDAH_BACKEND=vfs).

The default for container execution is that `/sys/fs/selinux`
is not mounted, and the libselinux library function `is_selinux_enabled`
should be used to dynamically check if the system should attempt to perform SELinux labeling.

This is how it's done by rpm, ostree, and systemd for example.

But this code unconditionally tries to label if it finds a policy,
which breaks in an obscure corner case
when executed inside a container that includes policy files (e.g.
fedora/rhel-bootc) but when we're not using overlayfs for the backend
(with BUILDAH_BACKEND=vfs).
enriquebelarte added a commit to enriquebelarte/ai-lab-recipes-upstream that referenced this pull request Jun 13, 2024
Konflux CI fails when building using bootc images as base throwing this error:
This temporary workaround is needed for build pipeline to work on Konflux CI until libdnf fix is merged to RHEL.
https://issues.redhat.com/browse/RHEL-39796
rpm-software-management/libdnf#1665
enriquebelarte added a commit to enriquebelarte/ai-lab-recipes-upstream that referenced this pull request Jun 13, 2024
Konflux CI fails when building using bootc images as base throwing this error:
`Error: Cannot create repo temporary directory "/var/cache/dnf/baseos-044cae74d71fe9ea/libdnf.1jsyRp": Permission denied`
This temporary workaround is needed for build pipeline to work on Konflux CI until libdnf fix is merged to RHEL.

References:
https://issues.redhat.com/browse/RHEL-39796
rpm-software-management/libdnf#1665

This should be removed once the permanent fix is merged.

Signed-off-by: Enrique Belarte Luque <ebelarte@redhat.com>
@jan-kolarik jan-kolarik self-assigned this Jun 19, 2024
Copy link
Member

@jan-kolarik jan-kolarik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested locally, build passes and no problem detected during runtime. Thanks for the fix!

@jan-kolarik jan-kolarik merged commit d264065 into rpm-software-management:rhel-9.5 Jun 19, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants