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
()
| 89 | // |
| 90 | // Related: https://gitlab.com/apparmor/apparmor/-/blob/v3.0.3/libraries/libapparmor/src/kernel.c#L311 |
| 91 | func 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. |
no test coverage detected
searching dependent graphs…