From 83fb8aa53d15dd7ee2c62bffa4fc04f70646650b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 8 Jan 2015 12:27:59 +0100 Subject: [PATCH] nsenter: keep semantic consistent The current nseneter behavior is inconsistent and depends on way how namespace is specified on command line # nsenter --user vs. # nseneter --user=filename if the namespace is specified by than nsenter does not do additinal setting and actions (e.g. does not call setgroups, setuid). This is bug. Signed-off-by: Karel Zak --- sys-utils/nsenter.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index e00a3e4727..50f77f3819 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -283,6 +283,15 @@ int main(int argc, char *argv[]) if (do_wd) open_target_fd(&wd_fd, "cwd", NULL); + /* + * Update namespaces variable to contain all requested namespaces + */ + for (nsfile = namespace_files; nsfile->nstype; nsfile++) { + if (nsfile->fd < 0) + continue; + namespaces |= nsfile->nstype; + } + /* * Now that we know which namespaces we want to enter, enter them. */ -- 2.39.5