mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #40083 from thaJeztah/daemon_consts
daemon: use constants for AppArmor and Seccomp
This commit is contained in:
commit
dde030a6b1
8 changed files with 13 additions and 12 deletions
|
@ -11,7 +11,8 @@ import (
|
|||
|
||||
// Define constants for native driver
|
||||
const (
|
||||
defaultApparmorProfile = "docker-default"
|
||||
unconfinedAppArmorProfile = "unconfined"
|
||||
defaultApparmorProfile = "docker-default"
|
||||
)
|
||||
|
||||
func ensureDefaultAppArmorProfile() error {
|
||||
|
|
|
@ -24,7 +24,7 @@ func (daemon *Daemon) saveApparmorConfig(container *container.Container) error {
|
|||
}
|
||||
|
||||
} else {
|
||||
container.AppArmorProfile = "unconfined"
|
||||
container.AppArmorProfile = unconfinedAppArmorProfile
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ func (daemon *Daemon) execSetPlatformOpt(c *container.Container, ec *exec.Config
|
|||
} else if c.HostConfig.Privileged {
|
||||
// `docker exec --privileged` does not currently disable AppArmor
|
||||
// profiles. Privileged configuration of the container is inherited
|
||||
appArmorProfile = "unconfined"
|
||||
appArmorProfile = unconfinedAppArmorProfile
|
||||
} else {
|
||||
appArmorProfile = "docker-default"
|
||||
appArmorProfile = defaultApparmorProfile
|
||||
}
|
||||
|
||||
if appArmorProfile == "docker-default" {
|
||||
if appArmorProfile == defaultApparmorProfile {
|
||||
// Unattended upgrades and other fun services can unload AppArmor
|
||||
// profiles inadvertently. Since we cannot store our profile in
|
||||
// /etc/apparmor.d, nor can we practically add other ways of
|
||||
|
|
|
@ -49,5 +49,5 @@ func TestExecSetPlatformOptPrivileged(t *testing.T) {
|
|||
c.HostConfig = &containertypes.HostConfig{Privileged: true}
|
||||
err = d.execSetPlatformOpt(c, ec, p)
|
||||
assert.NilError(t, err)
|
||||
assert.Equal(t, "unconfined", p.ApparmorProfile)
|
||||
assert.Equal(t, unconfinedAppArmorProfile, p.ApparmorProfile)
|
||||
}
|
||||
|
|
|
@ -113,12 +113,12 @@ func WithApparmor(c *container.Container) coci.SpecOpts {
|
|||
if c.AppArmorProfile != "" {
|
||||
appArmorProfile = c.AppArmorProfile
|
||||
} else if c.HostConfig.Privileged {
|
||||
appArmorProfile = "unconfined"
|
||||
appArmorProfile = unconfinedAppArmorProfile
|
||||
} else {
|
||||
appArmorProfile = "docker-default"
|
||||
appArmorProfile = defaultApparmorProfile
|
||||
}
|
||||
|
||||
if appArmorProfile == "docker-default" {
|
||||
if appArmorProfile == defaultApparmorProfile {
|
||||
// Unattended upgrades and other fun services can unload AppArmor
|
||||
// profiles inadvertently. Since we cannot store our profile in
|
||||
// /etc/apparmor.d, nor can we practically add other ways of
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
)
|
||||
|
||||
var supportsSeccomp = false
|
||||
const supportsSeccomp = false
|
||||
|
||||
// WithSeccomp sets the seccomp profile
|
||||
func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var supportsSeccomp = true
|
||||
const supportsSeccomp = true
|
||||
|
||||
// WithSeccomp sets the seccomp profile
|
||||
func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
)
|
||||
|
||||
var supportsSeccomp = false
|
||||
const supportsSeccomp = false
|
||||
|
||||
// WithSeccomp sets the seccomp profile
|
||||
func WithSeccomp(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
||||
|
|
Loading…
Reference in a new issue