Skip to content

export: Add --warn-unlabeled flag for SELinux label handling - #2446

Open
gursewak1997 wants to merge 1 commit into
bootc-dev:mainfrom
gursewak1997:export-warn-unlabeled
Open

export: Add --warn-unlabeled flag for SELinux label handling#2446
gursewak1997 wants to merge 1 commit into
bootc-dev:mainfrom
gursewak1997:export-warn-unlabeled

Conversation

@gursewak1997

@gursewak1997 gursewak1997 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Align SKIP_PATHS with ostree-ext's FORCE_CLEAN_PATHS (add run, var/cache) and replace --disable-selinux with a --selinux=enabled|warn-on-missing|disabled flag so users can preserve labels for files the policy covers while skipping unmatched ones.

@bootc-bot
bootc-bot Bot requested a review from cgwalters September 9, 2026 19:19

@cgwalters cgwalters 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.

Files with no matching policy rule cause a hard error, forcing users to pass --disable-selinux which loses all labels. Customers then need external scripts to reapply labels after extraction.

Wait but did this customer not know that one can add custom file paths?

Like this for example:

RUN semanage fcontext -a --equal /etc /extra-etc

This should ensure that any files in the container dropped into /extra-etc have the same label as /etc.

Or in short I think the fix almost always should be to add labels for the files, not to ignore unlabeled...

Comment thread crates/lib/src/cli.rs Outdated
Comment thread crates/lib/src/container_export.rs
@gursewak1997

Copy link
Copy Markdown
Contributor Author

Also, working on the root cause. I am running a workflow right now.

Comment thread crates/lib/src/container_export.rs Outdated
Replace the boolean --disable-selinux with a --selinux flag supporting
three modes: enabled (default, current behavior), warn-on-missing
(label every file the policy covers, skip the rest with a summary
count), and disabled (no labeling).

This provides a safety net for custom images with files outside the
SKIP_PATHS list that lack file_contexts coverage. Without it, the only
option is --selinux=disabled which loses all labels.

Introduce a SepolicyState enum that mirrors the CLI enum, a
maybe_add_selinux_label helper that consolidates labeling across all
four call sites, and optional_label() in lsm.rs as a non-failing
companion to require_label().

Assisted-by: AI
Signed-off-by: gursewak1997 <gursmangat@gmail.com>
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.

2 participants