diff options
-rw-r--r-- | libbb/run_shell.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index c2ff69651..9bec43b7c 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
@@ -59,7 +59,7 @@ void FAST_FUNC exec_shell(const char *shell, int loginshell, const char **additi | |||
59 | while (args && *args) | 59 | while (args && *args) |
60 | args++; | 60 | args++; |
61 | 61 | ||
62 | args = xmalloc(sizeof(char*) * (2 + (args - additional_args))); | 62 | args = xzalloc(sizeof(args[0]) * (2 + (args - additional_args))); |
63 | 63 | ||
64 | if (!shell || !shell[0]) | 64 | if (!shell || !shell[0]) |
65 | shell = DEFAULT_SHELL; | 65 | shell = DEFAULT_SHELL; |
@@ -67,12 +67,11 @@ void FAST_FUNC exec_shell(const char *shell, int loginshell, const char **additi | |||
67 | args[0] = bb_get_last_path_component_nostrip(shell); | 67 | args[0] = bb_get_last_path_component_nostrip(shell); |
68 | if (loginshell) | 68 | if (loginshell) |
69 | args[0] = xasprintf("-%s", args[0]); | 69 | args[0] = xasprintf("-%s", args[0]); |
70 | args[1] = NULL; | 70 | /*args[1] = NULL; - already is */ |
71 | if (additional_args) { | 71 | if (additional_args) { |
72 | int cnt = 1; | 72 | int cnt = 0; |
73 | for (;;) | 73 | while (*additional_args) |
74 | if ((args[cnt++] = *additional_args++) == NULL) | 74 | args[++cnt] = *additional_args++; |
75 | break; | ||
76 | } | 75 | } |
77 | 76 | ||
78 | #if ENABLE_SELINUX | 77 | #if ENABLE_SELINUX |
@@ -91,5 +90,8 @@ void FAST_FUNC exec_prog_or_SHELL(char **argv) | |||
91 | if (argv[0]) { | 90 | if (argv[0]) { |
92 | BB_EXECVP_or_die(argv); | 91 | BB_EXECVP_or_die(argv); |
93 | } | 92 | } |
93 | /* Why login=1? Both users (nsenter and unshare) do indeed exec | ||
94 | * a _login_ shell (with dash in argv[0])! | ||
95 | */ | ||
94 | exec_shell(getenv("SHELL"), /*login:*/ 1, NULL); | 96 | exec_shell(getenv("SHELL"), /*login:*/ 1, NULL); |
95 | } | 97 | } |