Skip to content

Commit 824e4ad

Browse files
author
Mrunal Patel
authored
Merge pull request #2803 from AkihiroSuda/fix-arch-apparmor
apparmor: try attr/apparmor/exec before attr/exec
2 parents 9f13653 + f3f563b commit 824e4ad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

libcontainer/apparmor/apparmor_linux.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package apparmor
22

33
import (
44
"bytes"
5+
"errors"
56
"fmt"
67
"io/ioutil"
78
"os"
@@ -21,7 +22,13 @@ func IsEnabled() bool {
2122
func setProcAttr(attr, value string) error {
2223
// Under AppArmor you can only change your own attr, so use /proc/self/
2324
// instead of /proc/<tid>/ like libapparmor does
24-
f, err := os.OpenFile("/proc/self/attr/"+attr, os.O_WRONLY, 0)
25+
attrPath := "/proc/self/attr/apparmor/" + attr
26+
if _, err := os.Stat(attrPath); errors.Is(err, os.ErrNotExist) {
27+
// fall back to the old convention
28+
attrPath = "/proc/self/attr/" + attr
29+
}
30+
31+
f, err := os.OpenFile(attrPath, os.O_WRONLY, 0)
2532
if err != nil {
2633
return err
2734
}

0 commit comments

Comments
 (0)