Merge pull request #4719 from philips/Capabilities-to-CapabilitiesMask

refactor(libcontainer): rename to CapabilitiesMask
This commit is contained in:
Guillaume J. Charmes 2014-03-17 11:15:29 -07:00
commit c838fc9266
5 changed files with 20 additions and 20 deletions

View file

@ -40,7 +40,7 @@ Sample `container.json` file:
"HOSTNAME=11bb30683fb0",
"TERM=xterm"
],
"capabilities" : [
"capabilities_mask" : [
"SETPCAP",
"SYS_MODULE",
"SYS_RAWIO",

View file

@ -9,7 +9,7 @@ import (
// DropCapabilities drops capabilities for the current process based
// on the container's configuration.
func DropCapabilities(container *libcontainer.Container) error {
if drop := getCapabilities(container); len(drop) > 0 {
if drop := getCapabilitiesMask(container); len(drop) > 0 {
c, err := capability.NewPid(os.Getpid())
if err != nil {
return err
@ -23,10 +23,10 @@ func DropCapabilities(container *libcontainer.Container) error {
return nil
}
// getCapabilities returns the specific cap values for the libcontainer types
func getCapabilities(container *libcontainer.Container) []capability.Cap {
// getCapabilitiesMask returns the specific cap mask values for the libcontainer types
func getCapabilitiesMask(container *libcontainer.Container) []capability.Cap {
drop := []capability.Cap{}
for _, c := range container.Capabilities {
for _, c := range container.CapabilitiesMask {
drop = append(drop, c.Value)
}
return drop

View file

@ -19,7 +19,7 @@ type Container struct {
Env []string `json:"environment,omitempty"` // environment to set
Tty bool `json:"tty,omitempty"` // setup a proper tty or not
Namespaces Namespaces `json:"namespaces,omitempty"` // namespaces to apply
Capabilities Capabilities `json:"capabilities,omitempty"` // capabilities to drop
CapabilitiesMask Capabilities `json:"capabilities_mask,omitempty"` // capabilities to drop
Networks []*Network `json:"networks,omitempty"` // nil for host's network stack
Cgroups *cgroups.Cgroup `json:"cgroups,omitempty"` // cgroups
Context Context `json:"context,omitempty"` // generic context for specific options (apparmor, selinux)

View file

@ -14,7 +14,7 @@
"NEWUTS",
"NEWNET"
],
"capabilities": [
"capabilities_mask": [
"SETPCAP",
"SYS_MODULE",
"SYS_RAWIO",

View file

@ -30,6 +30,6 @@ func TestCapabilitiesContains(t *testing.T) {
t.Fatal("capabilities should not contain SYS_ADMIN")
}
if !caps.Contains("MKNOD") {
t.Fatal("capabilities should container MKNOD but does not")
t.Fatal("capabilities should contain MKNOD but does not")
}
}