Skip to content

Commit d7978d1

Browse files
authored
Merge pull request moby#5373 from jarqvi/chore/apparmor
Return error when AppArmor is unsupported and profile specified
2 parents c7db68a + 4112470 commit d7978d1

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

executor/oci/spec_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/containerd/containerd/containers"
1212
"github.com/containerd/containerd/mount"
1313
"github.com/containerd/containerd/oci"
14+
"github.com/containerd/containerd/pkg/apparmor"
1415
cdseccomp "github.com/containerd/containerd/pkg/seccomp"
1516
"github.com/containerd/continuity/fs"
1617
"github.com/docker/docker/pkg/idtools"
@@ -72,6 +73,11 @@ func generateSecurityOpts(mode pb.SecurityMode, apparmorProfile string, selinuxB
7273
opts = append(opts, withDefaultProfile())
7374
}
7475
if apparmorProfile != "" {
76+
// If AppArmor is not supported but a profile was specified, return an error
77+
if !apparmor.HostSupports() {
78+
return nil, errors.New("AppArmor is not supported on this host, but the profile '" + apparmorProfile + "' was specified")
79+
}
80+
7581
opts = append(opts, oci.WithApparmorProfile(apparmorProfile))
7682
}
7783
opts = append(opts, func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {

vendor/github.com/containerd/containerd/pkg/apparmor/apparmor.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/containerd/pkg/apparmor/apparmor_linux.go

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/containerd/containerd/pkg/apparmor/apparmor_unsupported.go

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ github.com/containerd/containerd/metadata/boltutil
286286
github.com/containerd/containerd/mount
287287
github.com/containerd/containerd/namespaces
288288
github.com/containerd/containerd/oci
289+
github.com/containerd/containerd/pkg/apparmor
289290
github.com/containerd/containerd/pkg/cap
290291
github.com/containerd/containerd/pkg/cleanup
291292
github.com/containerd/containerd/pkg/deprecation

0 commit comments

Comments
 (0)