Skip to content

Commit

Permalink
incusd/apparmor/qemu: Allow access to agent path
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
  • Loading branch information
stgraber committed Jan 24, 2024
1 parent 5218bed commit 07c74ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/server/apparmor/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ func instanceProfile(sysOS *sys.OS, inst instance, extraBinaries []string) (stri
return "", err
}

agentPath := ""
if os.Getenv("INCUS_AGENT_PATH") != "" {
agentPath, err = filepath.EvalSymlinks(os.Getenv("INCUS_AGENT_PATH"))
if err != nil {
return "", err
}
}

execPath := localUtil.GetExecPath()
execPathFull, err := filepath.EvalSymlinks(execPath)
if err == nil {
Expand All @@ -217,6 +225,7 @@ func instanceProfile(sysOS *sys.OS, inst instance, extraBinaries []string) (stri
"path": path,
"raw": rawContent,
"ovmfPath": ovmfPath,
"agentPath": agentPath,
})
if err != nil {
return "", err
Expand Down
5 changes: 5 additions & 0 deletions internal/server/apparmor/instance_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ profile "{{ .name }}" flags=(attach_disconnected,mediate_deleted) {
deny /sys/module/apparmor/parameters/enabled r,
deny /sys/kernel/mm/transparent_hugepage/hpage_pmd_size r,
{{if .agentPath -}}
{{ .agentPath }}/ r,
{{ .agentPath }}/* r,
{{- end }}
{{if .libraryPath -}}
# Entries from LD_LIBRARY_PATH
{{range $index, $element := .libraryPath}}
Expand Down

0 comments on commit 07c74ed

Please sign in to comment.