apparmor: Set abi conditionally

The "abi" keyword was added for apparmor 3.0
The original change to add this ended up breaking versions < 3.0.
The abi itself is a macro in /etc/apparmor.d so we can check if the
macro exists to determine if we *can* set an abi in the template.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff
2026-04-22 16:36:30 -07:00
parent e8bf940080
commit d88e83aabf

View File

@@ -40,8 +40,8 @@ import (
const dir = "/etc/apparmor.d"
const defaultTemplate = `
abi <abi/3.0>,
{{if .Abi}}abi <{{.Abi}}>,
{{end}}
{{range $value := .Imports}}
{{$value}}
{{end}}
@@ -96,6 +96,7 @@ profile {{.Name}} flags=(attach_disconnected,mediate_deleted) {
`
type data struct {
Abi string
Name string
Imports []string
InnerImports []string
@@ -118,6 +119,11 @@ func loadData(name string) (*data, error) {
Name: name,
}
const abi = "abi/3.0"
if macroExists(abi) {
p.Abi = abi
}
if macroExists("tunables/global") {
p.Imports = append(p.Imports, "#include <tunables/global>")
} else {