Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

namespaces: allow to use pid namespace without mount namespace #358

Merged
merged 2 commits into from
Feb 3, 2015

Conversation

avagin
Copy link
Contributor

@avagin avagin commented Feb 3, 2015

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

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>
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does 0 mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crosbymichael Change capabilities of the calling process. os.Getpid() and 0 are the same except the case, when you try to access /proc from another pidns

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like drone failing because of this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LK4D4 I have not commited changes in the vendor direcotry.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
@mrunalp
Copy link
Contributor

mrunalp commented Feb 3, 2015

LGTM

1 similar comment
@vmarmol
Copy link
Contributor

vmarmol commented Feb 3, 2015

LGTM

vmarmol added a commit that referenced this pull request Feb 3, 2015
namespaces: allow to use pid namespace without mount namespace
@vmarmol vmarmol merged commit 2da44f8 into docker-archive:master Feb 3, 2015
wking added a commit to wking/runc that referenced this pull request Feb 19, 2018
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 <wking@tremily.us>
wking added a commit to wking/runc that referenced this pull request Feb 19, 2018
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 <wking@tremily.us>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants