Skip to content

Commit 853e095

Browse files
committed
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 444cc29 (namespaces: allow to use pid namespace without mount namespace, 2015-01-27, docker-archive/libcontainer#358), but the change was clobbered by 22df555 (Merge branch 'master' into api, 2015-02-19, docker-archive/libcontainer#388) which landed via 5b73860 (Merge pull request opencontainers#388 from docker/api, 2015-02-19, docker-archive/libcontainer#388) . This commit restores the changes from 444cc29. Signed-off-by: W. Trevor King <[email protected]>
1 parent a618ab5 commit 853e095

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

libcontainer/capabilities_linux.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package libcontainer
44

55
import (
66
"fmt"
7-
"os"
87
"strings"
98

109
"github.com/opencontainers/runc/libcontainer/configs"
@@ -72,7 +71,7 @@ func newContainerCapList(capConfig *configs.Capabilities) (*containerCapabilitie
7271
}
7372
ambient = append(ambient, v)
7473
}
75-
pid, err := capability.NewPid(os.Getpid())
74+
pid, err := capability.NewPid(0)
7675
if err != nil {
7776
return nil, err
7877
}

libcontainer/container_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ func (c *linuxContainer) bootstrapData(cloneFlags uintptr, nsMaps map[configs.Na
18041804
// The following only applies if we are root.
18051805
if !c.config.Rootless {
18061806
// check if we have CAP_SETGID to setgroup properly
1807-
pid, err := capability.NewPid(os.Getpid())
1807+
pid, err := capability.NewPid(0)
18081808
if err != nil {
18091809
return nil, err
18101810
}

0 commit comments

Comments
 (0)