MCPcopy Create free account
hub / github.com/containerd/nerdctl / CanApplyExistingProfile

Function CanApplyExistingProfile

pkg/apparmorutil/apparmorutil_linux.go:91–97  ·  view source on GitHub ↗

CanApplyExistingProfile returns whether the current process can apply an existing AppArmor profile to processes. CanApplyExistingProfile does NOT need root. CanApplyExistingProfile checks /sys/module/apparmor/parameters/enabled ,but does NOT check /sys/kernel/security/apparmor , which might not be

()

Source from the content-addressed store, hash-verified

89//
90// Related: https://gitlab.com/apparmor/apparmor/-/blob/v3.0.3/libraries/libapparmor/src/kernel.c#L311
91func CanApplyExistingProfile() bool {
92 paramEnabledOnce.Do(func() {
93 buf, err := filesystem.ReadFile("/sys/module/apparmor/parameters/enabled")
94 paramEnabled = err == nil && len(buf) == 2 && string(buf) == "Y\n"
95 })
96 return paramEnabled
97}
98
99// CanApplySpecificExistingProfile attempts to run `aa-exec -p <NAME> -- true` to check whether
100// the profile can be applied.

Callers 3

generateSecurityOptsFunction · 0.92
fulfillSecurityOptionsFunction · 0.92

Calls 1

ReadFileFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…