]> git.ipfire.org Git - thirdparty/util-linux.git/commit
nsenter: enter namespaces in two passes
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Fri, 15 Apr 2016 15:10:20 +0000 (08:10 -0700)
committerKarel Zak <kzak@redhat.com>
Fri, 22 Apr 2016 09:03:01 +0000 (11:03 +0200)
commit854d0fef7f2bbae6e13a2b2ec8116b7e29541d45
treed37cb645a0b469379574fad1d0a3ae514a7d4740
parent1bd62f72d8281cdd089fbef43652656dd3c60642
nsenter: enter namespaces in two passes

We have two use cases for user namespaces, one to elevate the
privilege of an unprivileged user, in which case we have to enter the
user namespace before all other namespaces (otherwise there isn't
enough permission to enter any other namespace).  And the other one is
where we're deprivileging a user and thus have to enter the user
namespace last (because that's the point at which we lose the
privileges).  On the first pass, we start at the position one after
the user namespace clearing the file descriptors as we close them
after calling setns().  If setns() fails on the first pass, ignore the
failure assuming that it will succeed after we enter the user
namespace.

Addresses: https://github.com/karelzak/util-linux/issues/315
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/nsenter.c