Browse code

Revert "apparmor: Check if apparmor_parser is available"

This reverts commit ab3fa46502381293b7dc5526c296e7e598d1983b.

This fix was partial, and is not needed with the proper fix in
containerd.

Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>

Bjorn Neergaard authored on 2023/02/12 07:48:04
Showing 1 changed files
... ...
@@ -5,12 +5,9 @@ package daemon // import "github.com/docker/docker/daemon"
5 5
 
6 6
 import (
7 7
 	"fmt"
8
-	"os"
9
-	"sync"
10 8
 
11 9
 	"github.com/containerd/containerd/pkg/apparmor"
12 10
 	aaprofile "github.com/docker/docker/profiles/apparmor"
13
-	"github.com/sirupsen/logrus"
14 11
 )
15 12
 
16 13
 // Define constants for native driver
... ...
@@ -19,11 +16,6 @@ const (
19 19
 	defaultAppArmorProfile    = "docker-default"
20 20
 )
21 21
 
22
-var (
23
-	checkAppArmorOnce   sync.Once
24
-	isAppArmorAvailable bool
25
-)
26
-
27 22
 // DefaultApparmorProfile returns the name of the default apparmor profile
28 23
 func DefaultApparmorProfile() string {
29 24
 	if apparmor.HostSupports() {
... ...
@@ -33,20 +25,7 @@ func DefaultApparmorProfile() string {
33 33
 }
34 34
 
35 35
 func ensureDefaultAppArmorProfile() error {
36
-	checkAppArmorOnce.Do(func() {
37
-		if apparmor.HostSupports() {
38
-			// Restore the apparmor_parser check removed in containerd:
39
-			// https://github.com/containerd/containerd/commit/1acca8bba36e99684ee3489ea4a42609194ca6b9
40
-			// Fixes: https://github.com/moby/moby/issues/44900
41
-			if _, err := os.Stat("/sbin/apparmor_parser"); err == nil {
42
-				isAppArmorAvailable = true
43
-			} else {
44
-				logrus.Warn("AppArmor enabled on system but \"apparmor_parser\" binary is missing, so profile can't be loaded")
45
-			}
46
-		}
47
-	})
48
-
49
-	if isAppArmorAvailable {
36
+	if apparmor.HostSupports() {
50 37
 		loaded, err := aaprofile.IsLoaded(defaultAppArmorProfile)
51 38
 		if err != nil {
52 39
 			return fmt.Errorf("Could not check if %s AppArmor profile was loaded: %s", defaultAppArmorProfile, err)