From f6064cb42b7016641a4823ebd49032edff54befa Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 21 Sep 2015 16:06:08 -0700 Subject: [PATCH] Update CAP_ prefix for new spec format Signed-off-by: Michael Crosby --- daemon/execdriver/native/create.go | 8 +++++++- daemon/execdriver/native/exec.go | 8 ++++++++ daemon/execdriver/utils.go | 1 - 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/daemon/execdriver/native/create.go b/daemon/execdriver/native/create.go index da64c74012..d76dbd2585 100644 --- a/daemon/execdriver/native/create.go +++ b/daemon/execdriver/native/create.go @@ -65,7 +65,13 @@ func (d *Driver) createContainer(ctx context.Context, c *execdriver.Command, hoo return nil, err } } - + // add CAP_ prefix to all caps for new libcontainer update to match + // the spec format. + for i, s := range container.Capabilities { + if !strings.HasPrefix(s, "CAP_") { + container.Capabilities[i] = fmt.Sprintf("CAP_%s", s) + } + } container.AdditionalGroups = c.GroupAdd if c.AppArmorProfile != "" { diff --git a/daemon/execdriver/native/exec.go b/daemon/execdriver/native/exec.go index 8327cc7650..ac6c13fb29 100644 --- a/daemon/execdriver/native/exec.go +++ b/daemon/execdriver/native/exec.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "os/exec" + "strings" "syscall" "github.com/docker/docker/context" @@ -36,6 +37,13 @@ func (d *Driver) Exec(ctx context.Context, c *execdriver.Command, processConfig if processConfig.Privileged { p.Capabilities = execdriver.GetAllCapabilities() } + // add CAP_ prefix to all caps for new libcontainer update to match + // the spec format. + for i, s := range p.Capabilities { + if !strings.HasPrefix(s, "CAP_") { + p.Capabilities[i] = fmt.Sprintf("CAP_%s", s) + } + } config := active.Config() if err := setupPipes(&config, processConfig, p, pipes); err != nil { diff --git a/daemon/execdriver/utils.go b/daemon/execdriver/utils.go index 6712dafd64..7860e04026 100644 --- a/daemon/execdriver/utils.go +++ b/daemon/execdriver/utils.go @@ -119,6 +119,5 @@ func TweakCapabilities(basics, adds, drops []string) ([]string, error) { newCaps = append(newCaps, strings.ToUpper(cap)) } } - return newCaps, nil }