diff options
Diffstat (limited to 'util-linux/nsenter.c')
-rw-r--r-- | util-linux/nsenter.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index 12c86b0ed..d91b0b509 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c | |||
@@ -13,14 +13,6 @@ | |||
13 | //config: select PLATFORM_LINUX | 13 | //config: select PLATFORM_LINUX |
14 | //config: help | 14 | //config: help |
15 | //config: Run program with namespaces of other processes. | 15 | //config: Run program with namespaces of other processes. |
16 | //config: | ||
17 | //config:config FEATURE_NSENTER_LONG_OPTS | ||
18 | //config: bool "Enable long options" | ||
19 | //config: default y | ||
20 | //config: depends on NSENTER && LONG_OPTS | ||
21 | //config: help | ||
22 | //config: Support long options for the nsenter applet. This makes | ||
23 | //config: the busybox implementation more compatible with upstream. | ||
24 | 16 | ||
25 | //applet:IF_NSENTER(APPLET(nsenter, BB_DIR_USR_BIN, BB_SUID_DROP)) | 17 | //applet:IF_NSENTER(APPLET(nsenter, BB_DIR_USR_BIN, BB_SUID_DROP)) |
26 | 18 | ||
@@ -28,22 +20,6 @@ | |||
28 | 20 | ||
29 | //usage:#define nsenter_trivial_usage | 21 | //usage:#define nsenter_trivial_usage |
30 | //usage: "[OPTIONS] [PROG [ARGS]]" | 22 | //usage: "[OPTIONS] [PROG [ARGS]]" |
31 | //usage:#if ENABLE_FEATURE_NSENTER_LONG_OPTS | ||
32 | //usage:#define nsenter_full_usage "\n" | ||
33 | //usage: "\n -t,--target PID Target process to get namespaces from" | ||
34 | //usage: "\n -m,--mount[=FILE] Enter mount namespace" | ||
35 | //usage: "\n -u,--uts[=FILE] Enter UTS namespace (hostname etc)" | ||
36 | //usage: "\n -i,--ipc[=FILE] Enter System V IPC namespace" | ||
37 | //usage: "\n -n,--net[=FILE] Enter network namespace" | ||
38 | //usage: "\n -p,--pid[=FILE] Enter pid namespace" | ||
39 | //usage: "\n -U,--user[=FILE] Enter user namespace" | ||
40 | //usage: "\n -S,--setuid UID Set uid in entered namespace" | ||
41 | //usage: "\n -G,--setgid GID Set gid in entered namespace" | ||
42 | //usage: "\n --preserve-credentials Don't touch uids or gids" | ||
43 | //usage: "\n -r,--root[=DIR] Set root directory" | ||
44 | //usage: "\n -w,--wd[=DIR] Set working directory" | ||
45 | //usage: "\n -F,--no-fork Don't fork before exec'ing PROG" | ||
46 | //usage:#else | ||
47 | //usage:#define nsenter_full_usage "\n" | 23 | //usage:#define nsenter_full_usage "\n" |
48 | //usage: "\n -t PID Target process to get namespaces from" | 24 | //usage: "\n -t PID Target process to get namespaces from" |
49 | //usage: "\n -m[FILE] Enter mount namespace" | 25 | //usage: "\n -m[FILE] Enter mount namespace" |
@@ -54,10 +30,12 @@ | |||
54 | //usage: "\n -U[FILE] Enter user namespace" | 30 | //usage: "\n -U[FILE] Enter user namespace" |
55 | //usage: "\n -S UID Set uid in entered namespace" | 31 | //usage: "\n -S UID Set uid in entered namespace" |
56 | //usage: "\n -G GID Set gid in entered namespace" | 32 | //usage: "\n -G GID Set gid in entered namespace" |
33 | //usage: IF_LONG_OPTS( | ||
34 | //usage: "\n --preserve-credentials Don't touch uids or gids" | ||
35 | //usage: ) | ||
57 | //usage: "\n -r[DIR] Set root directory" | 36 | //usage: "\n -r[DIR] Set root directory" |
58 | //usage: "\n -w[DIR] Set working directory" | 37 | //usage: "\n -w[DIR] Set working directory" |
59 | //usage: "\n -F Don't fork before exec'ing PROG" | 38 | //usage: "\n -F Don't fork before exec'ing PROG" |
60 | //usage:#endif | ||
61 | 39 | ||
62 | #include <sched.h> | 40 | #include <sched.h> |
63 | #ifndef CLONE_NEWUTS | 41 | #ifndef CLONE_NEWUTS |
@@ -101,7 +79,7 @@ enum { | |||
101 | OPT_root = 1 << 9, | 79 | OPT_root = 1 << 9, |
102 | OPT_wd = 1 << 10, | 80 | OPT_wd = 1 << 10, |
103 | OPT_nofork = 1 << 11, | 81 | OPT_nofork = 1 << 11, |
104 | OPT_prescred = (1 << 12) * ENABLE_FEATURE_NSENTER_LONG_OPTS, | 82 | OPT_prescred = (1 << 12) * ENABLE_LONG_OPTS, |
105 | }; | 83 | }; |
106 | enum { | 84 | enum { |
107 | NS_USR_POS = 0, | 85 | NS_USR_POS = 0, |
@@ -130,7 +108,7 @@ static const struct namespace_descr ns_list[] = { | |||
130 | */ | 108 | */ |
131 | static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t+S+G+r::w::F"; | 109 | static const char opt_str[] ALIGN1 = "U::i::u::n::p::m::""t+S+G+r::w::F"; |
132 | 110 | ||
133 | #if ENABLE_FEATURE_NSENTER_LONG_OPTS | 111 | #if ENABLE_LONG_OPTS |
134 | static const char nsenter_longopts[] ALIGN1 = | 112 | static const char nsenter_longopts[] ALIGN1 = |
135 | "user\0" Optional_argument "U" | 113 | "user\0" Optional_argument "U" |
136 | "ipc\0" Optional_argument "i" | 114 | "ipc\0" Optional_argument "i" |
@@ -190,8 +168,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
190 | 168 | ||
191 | memset(ns_ctx_list, 0, sizeof(ns_ctx_list)); | 169 | memset(ns_ctx_list, 0, sizeof(ns_ctx_list)); |
192 | 170 | ||
193 | IF_FEATURE_NSENTER_LONG_OPTS(applet_long_options = nsenter_longopts); | 171 | opts = getopt32long(argv, opt_str, nsenter_longopts, |
194 | opts = getopt32(argv, opt_str, | ||
195 | &ns_ctx_list[NS_USR_POS].path, | 172 | &ns_ctx_list[NS_USR_POS].path, |
196 | &ns_ctx_list[NS_IPC_POS].path, | 173 | &ns_ctx_list[NS_IPC_POS].path, |
197 | &ns_ctx_list[NS_UTS_POS].path, | 174 | &ns_ctx_list[NS_UTS_POS].path, |