Skip to content

Commit

Permalink
Merge pull request #5373 from jarqvi/chore/apparmor
Browse files Browse the repository at this point in the history
Return error when AppArmor is unsupported and profile specified
  • Loading branch information
tonistiigi authored Oct 4, 2024
2 parents c7db68a + 4112470 commit d7978d1
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 0 deletions.
6 changes: 6 additions & 0 deletions executor/oci/spec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/pkg/apparmor"
cdseccomp "github.com/containerd/containerd/pkg/seccomp"
"github.com/containerd/continuity/fs"
"github.com/docker/docker/pkg/idtools"
Expand Down Expand Up @@ -72,6 +73,11 @@ func generateSecurityOpts(mode pb.SecurityMode, apparmorProfile string, selinuxB
opts = append(opts, withDefaultProfile())
}
if apparmorProfile != "" {
// If AppArmor is not supported but a profile was specified, return an error
if !apparmor.HostSupports() {
return nil, errors.New("AppArmor is not supported on this host, but the profile '" + apparmorProfile + "' was specified")
}

opts = append(opts, oci.WithApparmorProfile(apparmorProfile))
}
opts = append(opts, func(_ context.Context, _ oci.Client, _ *containers.Container, s *oci.Spec) error {
Expand Down
28 changes: 28 additions & 0 deletions vendor/github.com/containerd/containerd/pkg/apparmor/apparmor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ github.com/containerd/containerd/metadata/boltutil
github.com/containerd/containerd/mount
github.com/containerd/containerd/namespaces
github.com/containerd/containerd/oci
github.com/containerd/containerd/pkg/apparmor
github.com/containerd/containerd/pkg/cap
github.com/containerd/containerd/pkg/cleanup
github.com/containerd/containerd/pkg/deprecation
Expand Down

0 comments on commit d7978d1

Please sign in to comment.