diff options
Diffstat (limited to 'src/firejail/join.c')
-rw-r--r-- | src/firejail/join.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/firejail/join.c b/src/firejail/join.c index acd17366a..35e302bf0 100644 --- a/src/firejail/join.c +++ b/src/firejail/join.c | |||
@@ -306,10 +306,25 @@ void join(pid_t pid, const char *homedir, int argc, char **argv, int index) { | |||
306 | if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0) | 306 | if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0) |
307 | errExit("setenv"); | 307 | errExit("setenv"); |
308 | 308 | ||
309 | // run icmdline trough /bin/bash | 309 | // run cmdline trough /bin/bash |
310 | if (cfg.command_line == NULL) | 310 | if (cfg.command_line == NULL) { |
311 | // replace the process with a regular bash session | 311 | struct stat s; |
312 | execlp("/bin/bash", "/bin/bash", NULL); | 312 | |
313 | // replace the process with a shell | ||
314 | if (stat("/bin/bash", &s) == 0) | ||
315 | execlp("/bin/bash", "/bin/bash", NULL); | ||
316 | else if (stat("/usr/bin/zsh", &s) == 0) | ||
317 | execlp("/usr/bin/zsh", "/usr/bin/zsh", NULL); | ||
318 | else if (stat("/bin/csh", &s) == 0) | ||
319 | execlp("/bin/csh", "/bin/csh", NULL); | ||
320 | else if (stat("/bin/sh", &s) == 0) | ||
321 | execlp("/bin/sh", "/bin/sh", NULL); | ||
322 | |||
323 | // no shell found, print an error and exit | ||
324 | fprintf(stderr, "Error: no POSIX shell found\n"); | ||
325 | sleep(5); | ||
326 | exit(1); | ||
327 | } | ||
313 | else { | 328 | else { |
314 | // run the command supplied by the user | 329 | // run the command supplied by the user |
315 | int cwd = 0; | 330 | int cwd = 0; |