Skip to content

Commit 444cc29

Browse files
committed
namespaces: allow to use pid namespace without mount namespace
The gocapability package uses /proc/PID/status to get a bounding set. If a container uses pidns without mntns, it sees /proc from the host namespace, but the process doesn't know its own pid in this namespace. In this case it can use /proc/self/status, which is always the right one. Signed-off-by: Andrew Vagin <[email protected]>
1 parent e599843 commit 444cc29

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

security/capabilities/capabilities.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package capabilities
22

33
import (
4-
"os"
5-
64
"github.com/syndtr/gocapability/capability"
75
)
86

@@ -11,7 +9,7 @@ const allCapabilityTypes = capability.CAPS | capability.BOUNDS
119
// DropBoundingSet drops the capability bounding set to those specified in the
1210
// container configuration.
1311
func DropBoundingSet(capabilities []string) error {
14-
c, err := capability.NewPid(os.Getpid())
12+
c, err := capability.NewPid(0)
1513
if err != nil {
1614
return err
1715
}
@@ -29,7 +27,7 @@ func DropBoundingSet(capabilities []string) error {
2927

3028
// DropCapabilities drops all capabilities for the current process except those specified in the container configuration.
3129
func DropCapabilities(capList []string) error {
32-
c, err := capability.NewPid(os.Getpid())
30+
c, err := capability.NewPid(0)
3331
if err != nil {
3432
return err
3533
}

update-vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ clone() {
4343
clone git github.com/codegangsta/cli 1.1.0
4444
clone git github.com/coreos/go-systemd v2
4545
clone git github.com/godbus/dbus v2
46-
clone git github.com/syndtr/gocapability 3c85049eae
46+
clone git github.com/syndtr/gocapability 1cf3ac4dc4
4747

4848
# intentionally not vendoring Docker itself... that'd be a circle :)

0 commit comments

Comments
 (0)