From 04da969aa8b85ade0d226d111129e66b0e4e852c Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 10 Mar 2016 22:23:38 -0800 Subject: [PATCH] Clear groups after entering userns Clears supplementary groups that have effect on the mount permissions before joining the user specified groups happens. Signed-off-by: Tonis Tiigi --- libcontainer/nsenter/nsexec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c index a52b7dc37..ee51c4753 100644 --- a/libcontainer/nsenter/nsexec.c +++ b/libcontainer/nsenter/nsexec.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -383,6 +384,11 @@ static void process_nl_attributes(int pipenum, char *data, int data_size) pr_perror("setgid failed"); exit(1); } + + if (setgroups(0, NULL) == -1) { + pr_perror("setgroups failed"); + exit(1); + } if (consolefd != -1) { if (ioctl(consolefd, TIOCSCTTY, 0) == -1) {