public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Setting uid / gid is generally useful in nseneter
@ 2014-07-26 20:22 bobtfish
  2014-07-28 11:56 ` Karel Zak
  0 siblings, 1 reply; 4+ messages in thread
From: bobtfish @ 2014-07-26 20:22 UTC (permalink / raw)
  To: util-linux; +Cc: Tomas Doran

From: Tomas Doran <bobtfish@bobtfish.net>

It's useful to be able to set the UID/GID even when not using user namespaces
(for example when creating a non-root shell in a pre-existing docker container)

Signed-off-by: Tomas Doran <bobtfish@bobtfish.net>
---
 sys-utils/nsenter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index d57edc8..23798f9 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -328,7 +328,7 @@ int main(int argc, char *argv[])
 	if (do_fork == 1)
 		continue_as_child();
 
-	if (namespaces & CLONE_NEWUSER) {
+	if (uid > 0 || gid > 0) {
 		if (setgroups(0, NULL))		/* drop supplementary groups */
 			err(EXIT_FAILURE, _("setgroups failed"));
 		if (setgid(gid) < 0)
-- 
2.0.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-29 11:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-26 20:22 [PATCH] Setting uid / gid is generally useful in nseneter bobtfish
2014-07-28 11:56 ` Karel Zak
2014-07-28 19:24   ` Eric W. Biederman
2014-07-29 11:23     ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox