diff options
Diffstat (limited to 'util-linux/nsenter.c')
| -rw-r--r-- | util-linux/nsenter.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c index 9c1dabaa8..0dad595cd 100644 --- a/util-linux/nsenter.c +++ b/util-linux/nsenter.c | |||
| @@ -230,7 +230,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
| 230 | ns->ns_nsfile8 + 3 /* skip over "ns/" */ | 230 | ns->ns_nsfile8 + 3 /* skip over "ns/" */ |
| 231 | ); | 231 | ); |
| 232 | } | 232 | } |
| 233 | /*close(ns_ctx->fd);*/ | 233 | close(ns_ctx->fd); /* should close fds, to not confuse exec'ed PROG */ |
| 234 | /*ns_ctx->fd = -1;*/ | 234 | /*ns_ctx->fd = -1;*/ |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -244,13 +244,13 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
| 244 | } | 244 | } |
| 245 | xfchdir(root_fd); | 245 | xfchdir(root_fd); |
| 246 | xchroot("."); | 246 | xchroot("."); |
| 247 | /*close(root_fd);*/ | 247 | close(root_fd); |
| 248 | /*root_fd = -1;*/ | 248 | /*root_fd = -1;*/ |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | if (wd_fd >= 0) { | 251 | if (wd_fd >= 0) { |
| 252 | xfchdir(wd_fd); | 252 | xfchdir(wd_fd); |
| 253 | /*close(wd_fd);*/ | 253 | close(wd_fd); |
| 254 | /*wd_fd = -1;*/ | 254 | /*wd_fd = -1;*/ |
| 255 | } | 255 | } |
| 256 | 256 | ||
| @@ -259,14 +259,7 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
| 259 | * explicitly requested by the user not to. | 259 | * explicitly requested by the user not to. |
| 260 | */ | 260 | */ |
| 261 | if (!(opts & OPT_nofork) && (opts & OPT_pid)) { | 261 | if (!(opts & OPT_nofork) && (opts & OPT_pid)) { |
| 262 | pid_t pid = xvfork(); | 262 | xvfork_parent_waits_and_exits(); |
| 263 | if (pid > 0) { | ||
| 264 | /* Parent */ | ||
| 265 | int exit_status = wait_for_exitstatus(pid); | ||
| 266 | if (WIFSIGNALED(exit_status)) | ||
| 267 | kill_myself_with_sig(WTERMSIG(exit_status)); | ||
| 268 | return WEXITSTATUS(exit_status); | ||
| 269 | } | ||
| 270 | /* Child continues */ | 263 | /* Child continues */ |
| 271 | } | 264 | } |
| 272 | 265 | ||
| @@ -278,9 +271,5 @@ int nsenter_main(int argc UNUSED_PARAM, char **argv) | |||
| 278 | if (opts & OPT_setuid) | 271 | if (opts & OPT_setuid) |
| 279 | xsetuid(uid); | 272 | xsetuid(uid); |
| 280 | 273 | ||
| 281 | if (*argv) { | 274 | exec_prog_or_SHELL(argv); |
| 282 | BB_EXECVP_or_die(argv); | ||
| 283 | } | ||
| 284 | |||
| 285 | run_shell(getenv("SHELL"), /*login:*/ 1, NULL, NULL); | ||
| 286 | } | 275 | } |
