libct: refactor mac labels and sysctl setup#5362
Open
lifubang wants to merge 2 commits into
Open
Conversation
lifubang
force-pushed
the
refactor-mac-labels
branch
from
July 7, 2026 10:19
e00df6e to
3979bf7
Compare
lifubang
marked this pull request as draft
July 7, 2026 10:24
lifubang
force-pushed
the
refactor-mac-labels
branch
3 times, most recently
from
July 7, 2026 14:23
1b87e80 to
1ef22f2
Compare
lifubang
force-pushed
the
refactor-mac-labels
branch
from
July 7, 2026 14:29
1ef22f2 to
8a02314
Compare
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>
lifubang
force-pushed
the
refactor-mac-labels
branch
from
July 7, 2026 14:31
8a02314 to
530a43e
Compare
lifubang
marked this pull request as ready for review
July 7, 2026 14:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR do some refactors:
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.
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.