Skip to content

Commit

Permalink
libcontainer/capabilities_linux: Drop os.Getpid() call
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
wking committed Feb 19, 2018
1 parent a618ab5 commit 853e095
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions libcontainer/capabilities_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package libcontainer

import (
"fmt"
"os"
"strings"

"github.com/opencontainers/runc/libcontainer/configs"
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 853e095

Please sign in to comment.