Skip to content

selabel: Break hardlinks when different SELinux labels are assigned#296

Open
cgwalters wants to merge 1 commit into
composefs:mainfrom
cgwalters:selabel-break-hardlinks
Open

selabel: Break hardlinks when different SELinux labels are assigned#296
cgwalters wants to merge 1 commit into
composefs:mainfrom
cgwalters:selabel-break-hardlinks

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

When two filesystem paths are hardlinked (share the same LeafId in the in-memory tree) but the SELinux policy assigns them different labels, we had "last looked at wins" behavior.

This conflict between hardlinks and SELinux has come up many times (it bit me badly in bootc when trying to have the binary also be
a systemd generator, so we ended up with a helper shell script).

Fix this by just breaking the hardlink, which is also what OSTree does.

Assisted-by: OpenCode (claude-sonnet-4-6@default)

When two filesystem paths are hardlinked (share the same LeafId in the
in-memory tree) but the SELinux policy assigns them different labels,
we had "last looked at wins" behavior.

This conflict between hardlinks and SELinux has come up many times
(it bit me badly in bootc when trying to have the binary also be
 a systemd generator, so we ended up with a helper shell script).

Fix this by just breaking the hardlink, which is also what OSTree does.

Assisted-by: OpenCode (claude-sonnet-4-6@default)
Signed-off-by: Colin Walters <walters@verbum.org>
@cgwalters cgwalters added this to the 0.5 milestone May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant