Skip to content

Commit

Permalink
chore: return an error when AppArmor is unsupported and profile specifie
Browse files Browse the repository at this point in the history
Signed-off-by: MohammadHasan Akbari <[email protected]>
  • Loading branch information
jarqvi committed Oct 1, 2024
1 parent 9cdd15e commit b4fd6b4
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 @@ -12,6 +12,7 @@ import (
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/oci"
cdseccomp "github.com/containerd/containerd/pkg/seccomp"
"github.com/containerd/containerd/pkg/apparmor"
"github.com/containerd/continuity/fs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/profiles/seccomp"
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 b4fd6b4

Please sign in to comment.