Skip to content

Commit

Permalink
namespaces: allow to use pid namespace without mount namespace
Browse files Browse the repository at this point in the history
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 <avagin@openvz.org>
  • Loading branch information
avagin committed Feb 3, 2015
1 parent e599843 commit 444cc29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions security/capabilities/capabilities.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package capabilities

import (
"os"

"github.com/syndtr/gocapability/capability"
)

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

// DropCapabilities drops all capabilities for the current process except those specified in the container configuration.
func DropCapabilities(capList []string) error {
c, err := capability.NewPid(os.Getpid())
c, err := capability.NewPid(0)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion update-vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ clone() {
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/syndtr/gocapability 3c85049eae
clone git github.com/syndtr/gocapability 1cf3ac4dc4

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

0 comments on commit 444cc29

Please sign in to comment.