 flags at run time, it will be granted access to the root name space.
 
 Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
+
+Upstream-Status: Pending
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
 ---
- sys-utils/nsenter.c |   21 ++++++++++++++++++---
+ sys-utils/nsenter.c | 21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)
 
+diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
+index 4432cd3..476688f 100644
 --- a/sys-utils/nsenter.c
 +++ b/sys-utils/nsenter.c
-@@ -84,6 +84,7 @@ static void usage(int status)
+@@ -85,6 +85,7 @@ static void __attribute__((__noreturn__)) usage(void)
  	fputs(_(" -i, --ipc[=<file>]     enter System V IPC namespace\n"), out);
  	fputs(_(" -n, --net[=<file>]     enter network namespace\n"), out);
  	fputs(_(" -p, --pid[=<file>]     enter pid namespace\n"), out);
 +	fputs(_(" -P  --parent           enter parent name space\n"), out);
  	fputs(_(" -C, --cgroup[=<file>]  enter cgroup namespace\n"), out);
  	fputs(_(" -U, --user[=<file>]    enter user namespace\n"), out);
- 	fputs(_(" -S, --setuid <uid>     set uid in entered namespace\n"), out);
-@@ -107,6 +108,7 @@ static void usage(int status)
+ 	fputs(_(" -T, --time[=<file>]    enter time namespace\n"), out);
+@@ -108,6 +109,7 @@ static void __attribute__((__noreturn__)) usage(void)
  static pid_t namespace_target_pid = 0;
  static int root_fd = -1;
  static int wd_fd = -1;

 		if ((ret == child) && (WIFSTOPPED(status))) {
 			/* The child suspended so suspend us as well */
 			kill(getpid(), SIGSTOP);
@@ -218,6 +229,7 @@ int main(int argc, char *argv[])
 		{ "ipc", optional_argument, NULL, 'i' },
 		{ "net", optional_argument, NULL, 'n' },
 		{ "pid", optional_argument, NULL, 'p' },
+		{ "parent", no_argument, NULL, 'P' },
 		{ "user", optional_argument, NULL, 'U' },
 		{ "cgroup", optional_argument, NULL, 'C' },
 		{ "setuid", required_argument, NULL, 'S' },
@@ -249,7 +261,7 @@ int main(int argc, char *argv[])
 	atexit(close_stdout);
 
 	while ((c =
-		getopt_long(argc, argv, "+ahVt:m::u::i::n::p::C::U::S:G:r::w::FZ",
+		getopt_long(argc, argv, "+ahVt:m::u::i::n::Pp::C::U::S:G:r::w::FZ",
 			    longopts, NULL)) != -1) {
 		switch (c) {
 		case 'h':
@@ -300,6 +312,9 @@ int main(int argc, char *argv[])
 			else
 				namespaces |= CLONE_NEWCGROUP;
 			break;

From ffcb719a7fc66165f64a8b2489e6947c4662d049 Mon Sep 17 00:00:00 2001
From: Jason Wessel <jason.wessel@windriver.com>
Date: Wed, 26 Aug 2020 20:06:08 -0700
Subject: [PATCH] nsenter: Add "-P" option for access to root/parent name space

The idea behind this patch is that the kernel will extend the setns()
