Skip to content

libct: refactor mac labels and sysctl setup#5362

Open
lifubang wants to merge 2 commits into
opencontainers:mainfrom
lifubang:refactor-mac-labels
Open

libct: refactor mac labels and sysctl setup#5362
lifubang wants to merge 2 commits into
opencontainers:mainfrom
lifubang:refactor-mac-labels

Conversation

@lifubang

@lifubang lifubang commented Jul 7, 2026

Copy link
Copy Markdown
Member

This PR do some refactors:

  1. libct: move Selinux/Apparmor setup earlier

    Move SELinux process label and AppArmor profile application into a new
    helper, applyMACLabels, in init_linux.go. This removes duplicated logic
    from standard_init_linux.go and setns_init_linux.go.

    The labels are applied earlier in the container init flow, but only
    take effect for the current process after execve, so this has no impact
    on the init process itself.

  2. libct: move sysctl setup earlier

    Settings under /proc/sys are mostly tied to namespaces rather than the
    rootfs path, so there is no need to wait until after rootfs setup to
    apply them. Move the sysctl writes to before prepareRootfs so they are
    configured earlier in the init process.

This comment was marked as resolved.

@lifubang
lifubang marked this pull request as draft July 7, 2026 10:24
@lifubang
lifubang force-pushed the refactor-mac-labels branch 3 times, most recently from 1b87e80 to 1ef22f2 Compare July 7, 2026 14:23
@lifubang
lifubang requested a review from Copilot July 7, 2026 14:24

This comment was marked as resolved.

@lifubang
lifubang force-pushed the refactor-mac-labels branch from 1ef22f2 to 8a02314 Compare July 7, 2026 14:29
lifubang added 2 commits July 7, 2026 14:30
Move SELinux process label and AppArmor profile application into a new
helper, applyMACLabels, in init_linux.go. This removes duplicated logic
from standard_init_linux.go and setns_init_linux.go.

The labels are applied earlier in the container init flow, but only
take effect for the current process after execve, so this has no impact
on the init process itself.

Signed-off-by: lifubang <lifubang@acmcoder.com>
Settings under /proc/sys are mostly tied to namespaces rather than the
rootfs path, so there is no need to wait until after rootfs setup to
apply them. Move the sysctl writes to before prepareRootfs so they are
configured earlier in the init process.

Signed-off-by: lifubang <lifubang@acmcoder.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@lifubang
lifubang marked this pull request as ready for review July 7, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants