Skip to content

Introduce SELinux policy module for kiwi - #2756

Merged
schaefi merged 1 commit into
mainfrom
kiwi-selinux
Sep 17, 2026
Merged

schaefi merged 1 commit into
mainfrom
kiwi-selinux

Conversation

@Conan-Kudo

@Conan-Kudo Conan-Kudo commented Mar 28, 2025 •

Copy link
Copy Markdown
Member

This policy module ensures that kiwi is set up to function properly in SELinux enforcing mode.

@Conan-Kudo

Copy link
Copy Markdown
Member Author

This is a fuller alternative to #2757 that lets us easily add more things in the future.

@Conan-Kudo Conan-Kudo closed this Mar 28, 2025
@Conan-Kudo
Conan-Kudo deleted the kiwi-selinux branch March 28, 2025 14:30
@Conan-Kudo
Conan-Kudo restored the kiwi-selinux branch March 31, 2025 15:13
@Conan-Kudo Conan-Kudo reopened this Mar 31, 2025
@schaefi

schaefi commented Apr 1, 2025

Copy link
Copy Markdown
Collaborator

Really nice, thanks for this work 👍 I'm pretty dumb regarding selinux policies. Would be great if we get some reviewer with knowledge in that area. Otherwise I'm perfectly fine adding it the way you did it because I believe you tested it to work :)

@ca-hu

ca-hu commented Apr 4, 2025 •

Copy link
Copy Markdown

question: why add this as separate module here instead of in the fedora policy that is used by almost everyone? usually this only makes sense when the maintainers of the project are well-versed in selinux and can maintain this module long-term, otherwise you will run into more issues

also it is a bit odd that the module is reusing an existing type, usually modules define their own types and rules around their type

also: what exactly is breaking?

@Conan-Kudo

Copy link
Copy Markdown
Member Author

question: why add this as separate module here instead of in the fedora policy that is used by basically everyone? usually this only makes sense when the maintainers of the project are well-versed in selinux and can maintain this module long-term, otherwise you will run into more issues

Well, I am well-versed in SELinux. I've done a fair bit of SELinux policy work over the years in both Fedora and openSUSE. And as a team, we do need to develop more skill with SELinux anyway, since not knowing how to deal with it is bad for us as an image build tool.

But there are two big reasons:

  • We need this to work across all distributions and releases using SELinux. And some of those would not get a policy update with this for a long time (if ever).
  • We need a "fast path" since kiwi releases much more frequently than the policy package.

This does not preclude contributing it into fedora-selinux, and that will probably happen down the road as this is firmed up.

also it is a bit odd that the module is reusing an existing type, usually modules define their own types and rules around their type

Yes, I will probably change to this approach, but I need to spend more time to write it.

@Conan-Kudo

Copy link
Copy Markdown
Member Author

also: what exactly is breaking?

There have been requests from Fedora and CentOS to make kiwi work properly in SELinux enforcing mode as all the legacy image build tools in Fedora already do. After soliciting some advice from the OSBuild folks, I had identified an approach to resolve that problem. It also neatly resolves a problem nobody has yet noticed in openSUSE, in which you cannot build an image in SELinux enforcing mode.

@github-actions

github-actions Bot commented Oct 3, 2025

Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed as part of the community meeting.

@github-actions github-actions Bot added the stale label Oct 3, 2025
@schaefi

schaefi commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

@Conan-Kudo it would be so great to see this merged, it feels we are so close

@Conan-Kudo

Copy link
Copy Markdown
Member Author

Yeah, I want to resume this work asap.

@schaefi schaefi removed the stale label Nov 17, 2025
@schaefi

schaefi commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator

Yeah, I want to resume this work asap.

I think we are desperately waiting for this to come true ;)

@Conan-Kudo

Copy link
Copy Markdown
Member Author

Coming back to it now, don't worry. 👍🏾

@schaefi

schaefi commented Feb 22, 2026 •

Copy link
Copy Markdown
Collaborator

Coming back to it now, don't worry. 👍🏾

@Conan-Kudo Are you sure ;)

@Conan-Kudo

Copy link
Copy Markdown
Member Author

Yes, yes! :)

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed as part of the community meeting.

@github-actions github-actions Bot added the stale label Apr 24, 2026
@schaefi

schaefi commented May 4, 2026

Copy link
Copy Markdown
Collaborator

I guess we still want this, dropping stale label

@schaefi schaefi removed the stale label May 4, 2026
@Vogtinator

Copy link
Copy Markdown
Collaborator

I guess we still want this

IMO no, this really belongs in the main upstream policy.

@Conan-Kudo

Copy link
Copy Markdown
Member Author

I've already talked to the fedora-selinux people. We will need it here regardless because when we change things that require new knobs, we need a way to backport it.

@Conan-Kudo

Copy link
Copy Markdown
Member Author

I've been asked to rewrite this to use its own labels and policy tunables, which is why this is taking so long...

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed as part of the community meeting.

@github-actions github-actions Bot added the stale label Sep 7, 2026
@schaefi schaefi removed the stale label Sep 8, 2026
@Conan-Kudo
Conan-Kudo marked this pull request as ready for review September 16, 2026 12:16
@Conan-Kudo
Conan-Kudo marked this pull request as draft September 16, 2026 12:18
@Conan-Kudo
Conan-Kudo force-pushed the kiwi-selinux branch 5 times, most recently from 7146248 to e8fd079 Compare September 16, 2026 12:37
@Conan-Kudo
Conan-Kudo marked this pull request as ready for review September 16, 2026 12:37
@Conan-Kudo

Copy link
Copy Markdown
Member Author

@schaefi I've revised this based on what I've seen for osbuild and other image build tools. Please test and merge if it works for you in SELinux enforcing mode.

@schaefi

schaefi commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks, I created a new Staging build and will test on a selinux enabled system in the AWS cloud. Give me some time to get there... other work related stuff required my attention

@schaefi

schaefi commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

@Conan-Kudo can you please double check on the package build from here

It does fail on several targets, e.g Rawhide and Tumbleweed

Thanks

@schaefi

schaefi commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

I think problem is that selinux is not in the included source files in pyproject.toml
I suggest

include = [
   { path = "selinux", format = "sdist" },  

This policy module ensures that kiwi is set up to function properly
in SELinux enforcing mode.
@Conan-Kudo

Copy link
Copy Markdown
Member Author

Whoops, you're right! Fixed.

@schaefi

schaefi commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

This worked for me, tested on a Fedora cloud instance in AWS with selinux enabled.

Thanks

@schaefi schaefi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@schaefi
schaefi merged commit 012e396 into main Sep 17, 2026
13 checks passed
@schaefi
schaefi deleted the kiwi-selinux branch September 17, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants