From 00abcf89d9ad026ddce4af0038db7953b01d8b8b Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Tue, 24 Feb 2015 08:02:09 -0500 Subject: [PATCH 1/2] Linux has added a new capability audit_read Docker-DCO-1.1-Signed-off-by: Dan Walsh (github: rhatdan) --- capabilities_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/capabilities_linux.go b/capabilities_linux.go index b1c5c1760..6b8b465c5 100644 --- a/capabilities_linux.go +++ b/capabilities_linux.go @@ -49,6 +49,7 @@ var capabilityList = map[string]capability.Cap{ "SETFCAP": capability.CAP_SETFCAP, "WAKE_ALARM": capability.CAP_WAKE_ALARM, "BLOCK_SUSPEND": capability.CAP_BLOCK_SUSPEND, + "AUDIT_READ": capability.CAP_AUDIT_READ, } func newCapWhitelist(caps []string) (*whitelist, error) { From 5b2be7d9d8444e0a5b706944c878cd0048ef026a Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Tue, 24 Feb 2015 08:08:21 -0500 Subject: [PATCH 2/2] Update to latest gocapability package Docker-DCO-1.1-Signed-off-by: Dan Walsh (github: rhatdan) --- update-vendor.sh | 2 +- .../capability/capability_linux.go | 42 ++++++++- .../syndtr/gocapability/capability/enum.go | 89 ++++++++++--------- 3 files changed, 89 insertions(+), 44 deletions(-) diff --git a/update-vendor.sh b/update-vendor.sh index ab201d6fd..c48fb5f0b 100755 --- a/update-vendor.sh +++ b/update-vendor.sh @@ -44,6 +44,6 @@ clone git github.com/codegangsta/cli 1.1.0 clone git github.com/coreos/go-systemd v2 clone git github.com/godbus/dbus v2 clone git github.com/Sirupsen/logrus v0.6.0 -clone git github.com/syndtr/gocapability 1cf3ac4dc4 +clone git github.com/syndtr/gocapability e55e583369 # intentionally not vendoring Docker itself... that'd be a circle :) diff --git a/vendor/src/github.com/syndtr/gocapability/capability/capability_linux.go b/vendor/src/github.com/syndtr/gocapability/capability/capability_linux.go index 3f658e528..24dc85fa8 100644 --- a/vendor/src/github.com/syndtr/gocapability/capability/capability_linux.go +++ b/vendor/src/github.com/syndtr/gocapability/capability/capability_linux.go @@ -24,12 +24,46 @@ const ( linuxCapVer3 = 0x20080522 ) -var capVers uint32 +var ( + capVers uint32 + capLastCap Cap +) func init() { var hdr capHeader capget(&hdr, nil) capVers = hdr.version + + if initLastCap() == nil { + CAP_LAST_CAP = capLastCap + if capLastCap > 31 { + capUpperMask = (uint32(1) << (uint(capLastCap) - 31)) - 1 + } else { + capUpperMask = 0 + } + } +} + +func initLastCap() error { + if capLastCap != 0 { + return nil + } + + f, err := os.Open("/proc/sys/kernel/cap_last_cap") + if err != nil { + return err + } + defer f.Close() + + var b []byte = make([]byte, 11) + _, err = f.Read(b) + if err != nil { + return err + } + + fmt.Sscanf(string(b), "%d", &capLastCap) + + return nil } func mkStringCap(c Capabilities, which CapType) (ret string) { @@ -383,6 +417,10 @@ func (c *capsV3) Load() (err error) { } func (c *capsV3) Apply(kind CapType) (err error) { + err = initLastCap() + if err != nil { + return + } if kind&BOUNDS == BOUNDS { var data [2]capData err = capget(&c.hdr, &data[0]) @@ -390,7 +428,7 @@ func (c *capsV3) Apply(kind CapType) (err error) { return } if (1<