2023-08-18 00:11:11 +02:00
|
|
|
{{- /* apparmor.d - Full set of apparmor profiles */ -}}
|
|
|
|
{{- /* Copyright (C) 2021-2023 Alexandre Pujol <alexandre@pujol.io> */ -}}
|
|
|
|
{{- /* SPDX-License-Identifier: GPL-2.0-only */ -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- range .Abi -}}
|
|
|
|
{{- if .IsMagic -}}
|
|
|
|
{{ "abi <" }}{{ .Path }}{{ ">,\n" }}
|
|
|
|
{{- else -}}
|
|
|
|
{{ "abi \"" }}{{ .Path }}{{ "\",\n" }}
|
|
|
|
{{- end }}
|
|
|
|
{{ end -}}
|
|
|
|
|
|
|
|
{{- range .Aliases -}}
|
|
|
|
{{ "alias " }}{{ .Path }}{{ " -> " }}{{ .RewrittenPath }}{{ ",\n" }}
|
|
|
|
{{ end -}}
|
|
|
|
|
|
|
|
{{- range .Includes -}}
|
|
|
|
{{- "include " -}}
|
|
|
|
{{- if .IfExists -}}
|
|
|
|
{{- "if exists " -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if .IsMagic -}}
|
|
|
|
{{ "<" }}{{ .Path }}{{ ">,\n" }}
|
|
|
|
{{- else -}}
|
|
|
|
{{ "\"" }}{{ .Path }}{{ "\",\n" }}
|
|
|
|
{{- end }}
|
|
|
|
{{ end -}}
|
|
|
|
|
|
|
|
{{- range .Variables -}}
|
|
|
|
{{ "@{" }}{{ .Name }}{{ "} = " }}
|
|
|
|
{{- range .Values -}}
|
|
|
|
{{ . }}{{ " " }}
|
|
|
|
{{- end }}
|
|
|
|
{{ end -}}
|
|
|
|
|
|
|
|
{{- "profile " -}}
|
|
|
|
{{- with .Name -}}
|
|
|
|
{{ . }}{{ " " }}
|
|
|
|
{{- end -}}
|
|
|
|
{{- with .Attachments -}}
|
|
|
|
{{ join . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Attributes -}}
|
|
|
|
{{ "xattrs=(" }}{{ join . }}{{ ") " }}
|
|
|
|
{{- end -}}
|
|
|
|
{{- with .Flags -}}
|
|
|
|
{{ "flags=(" }}{{ join . }}{{ ") " }}
|
|
|
|
{{- end -}}
|
|
|
|
{{ "{\n" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- $oldtype := "" -}}
|
|
|
|
{{- range .Rules -}}
|
|
|
|
{{- $type := typeof . -}}
|
|
|
|
{{- if and (ne $type $oldtype) (ne $oldtype "") -}}
|
|
|
|
{{- "\n" -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- indent "" -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Include" -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- "include " -}}
|
|
|
|
{{- if .IfExists -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ "if exists " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-08-22 23:58:35 +02:00
|
|
|
{{- if .IsMagic -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ "<" }}{{ .Path }}{{ ">" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- else -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ "\"" }}{{ .Path }}{{ "\"" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Rlimit" -}}
|
|
|
|
{{ "set rlimit " }}{{ .Key }} {{ .Op }} {{ .Value }}{{ "," }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Capability" -}}
|
|
|
|
{{ "capability " }}{{ .Name }}{{ "," }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Network" -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- if eq .AccessType "deny" -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ "deny " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ "network " }}
|
|
|
|
{{- with .Domain -}}
|
|
|
|
{{ . }}{{ " " }}
|
|
|
|
{{- end -}}
|
|
|
|
{{- with .Type -}}
|
|
|
|
{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- else -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Protocol -}}
|
|
|
|
{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Mount" -}}
|
|
|
|
{{- "mount " -}}
|
|
|
|
{{- with .FsType -}}
|
|
|
|
{{ "fstype=" }}{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Options -}}
|
|
|
|
{{ "options=(" }}{{ join . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Source -}}
|
|
|
|
{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .MountPoint -}}
|
|
|
|
{{ "-> " }}{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Umount" -}}
|
|
|
|
{{- "umount " -}}
|
|
|
|
{{- with .FsType -}}
|
|
|
|
{{ "fstype=" }}{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Options -}}
|
|
|
|
{{ "options=(" }}{{ join . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .MountPoint -}}
|
|
|
|
{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Remount" -}}
|
|
|
|
{{- "remount " -}}
|
|
|
|
{{- with .FsType -}}
|
|
|
|
{{ "fstype=" }}{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Options -}}
|
|
|
|
{{ "options=(" }}{{ join . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Remount -}}
|
|
|
|
{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Unix" -}}
|
|
|
|
{{- "unix " -}}
|
|
|
|
{{- with .Access -}}
|
|
|
|
{{ "(" }}{{ . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Type -}}
|
|
|
|
{{ "type=" }}{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Address -}}
|
|
|
|
{{ "addr=" }}{{ . }}{{ " " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- if .Peer -}}
|
|
|
|
{{ "peer=(label=" }}{{ .Peer }}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .PeerAddr -}}
|
|
|
|
{{ ", addr="}}{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- ")" -}}
|
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Ptrace" -}}
|
|
|
|
{{- "ptrace " -}}
|
|
|
|
{{- with .Access -}}
|
|
|
|
{{ "(" }}{{ . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Peer -}}
|
|
|
|
{{ "peer=" }}{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Signal" -}}
|
|
|
|
{{- "signal " -}}
|
|
|
|
{{- with .Access -}}
|
|
|
|
{{ "(" }}{{ . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Set -}}
|
|
|
|
{{ "set=(" }}{{ . }}{{ ") " }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Peer -}}
|
|
|
|
{{ "peer=" }}{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "Dbus" -}}
|
|
|
|
{{- "dbus " -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- if eq .Access "bind" -}}
|
|
|
|
bind bus={{ .Bus }} name={{ .Name }}
|
|
|
|
{{- else -}}
|
|
|
|
{{ .Access }} bus={{ .Bus }} path={{ .Path }}{{ "\n" }}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Interface -}}
|
|
|
|
{{ overindent "interface=" }}{{ . }}{{ "\n" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Member -}}
|
|
|
|
{{ overindent "member=" }}{{ . }}{{ " " }}{{ "\n" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- if and .Name .Label -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ overindent "peer=(name=" }}{{ .Name }}{{ ", label="}}{{ .Label }}{{ ")" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- else -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Name -}}
|
|
|
|
{{ overindent "peer=(name=" }}{{ . }}{{ ")" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- with .Label -}}
|
|
|
|
{{ overindent "peer=(label=" }}{{ . }}{{ ")" }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- if eq $type "File" -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- if .Owner -}}
|
|
|
|
{{- "owner " -}}
|
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{ .Path }}{{ " " }}{{ .Access }}
|
|
|
|
{{- with .Target -}}
|
|
|
|
{{ " -> " }}{{ . }}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "," -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- if .FileInherit -}}
|
|
|
|
{{- " # file_inherit" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if .NoNewPrivs -}}
|
|
|
|
{{- " # no new privs" -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
|
2023-09-25 01:15:51 +02:00
|
|
|
{{- "\n" -}}
|
|
|
|
{{- $oldtype = $type -}}
|
2023-08-18 00:11:11 +02:00
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- "}\n" -}}
|