From 50dc7ee96caf390bac44dc8c6bf0a8f3fe83e2b8 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 19 Feb 2018 15:23:56 -0800 Subject: [PATCH] libcontainer/capabilities_linux: Drop os.Getpid() call gocapability has supported 0 as "the current PID" since syndtr/gocapability@5e7cce49 (Allow to use the zero value for pid to operate with the current task, 2015-01-15, syndtr/gocapability#2). libcontainer was ported to that approach in 444cc298 (namespaces: allow to use pid namespace without mount namespace, 2015-01-27, docker/libcontainer#358), but the change was clobbered by 22df5551 (Merge branch 'master' into api, 2015-02-19, docker/libcontainer#388) which landed via 5b73860e (Merge pull request #388 from docker/api, 2015-02-19, docker/libcontainer#388). This commit restores the changes from 444cc298. Signed-off-by: W. Trevor King --- libcontainer/capabilities_linux.go | 3 +-- libcontainer/container_linux.go | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libcontainer/capabilities_linux.go b/libcontainer/capabilities_linux.go index 8981b2a2..7c66f572 100644 --- a/libcontainer/capabilities_linux.go +++ b/libcontainer/capabilities_linux.go @@ -4,7 +4,6 @@ package libcontainer import ( "fmt" - "os" "strings" "github.com/opencontainers/runc/libcontainer/configs" @@ -72,7 +71,7 @@ func newContainerCapList(capConfig *configs.Capabilities) (*containerCapabilitie } ambient = append(ambient, v) } - pid, err := capability.NewPid(os.Getpid()) + pid, err := capability.NewPid(0) if err != nil { return nil, err } diff --git a/libcontainer/container_linux.go b/libcontainer/container_linux.go index cfb05b43..db2242e2 100644 --- a/libcontainer/container_linux.go +++ b/libcontainer/container_linux.go @@ -1804,7 +1804,7 @@ func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Na // The following only applies if we are root. if !c.config.Rootless { // check if we have CAP_SETGID to setgroup properly - pid, err := capability.NewPid(os.Getpid()) + pid, err := capability.NewPid(0) if err != nil { return nil, err }