diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c index f1095d41f..e70e20eec 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -754,12 +754,21 @@ static void delete_x11_file(pid_t pid) { | |||
754 | 754 | ||
755 | char *guess_shell(void) { | 755 | char *guess_shell(void) { |
756 | char *shell = NULL; | 756 | char *shell = NULL; |
757 | struct stat s; | ||
758 | |||
759 | shell = getenv("SHELL"); | ||
760 | if (shell) { | ||
761 | // TODO: handle rogue shell variables? | ||
762 | if (stat(shell, &s) == 0 && access(shell, R_OK) == 0) { | ||
763 | return shell; | ||
764 | } | ||
765 | } | ||
766 | |||
757 | // shells in order of preference | 767 | // shells in order of preference |
758 | char *shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL }; | 768 | char *shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL }; |
759 | 769 | ||
760 | int i = 0; | 770 | int i = 0; |
761 | while (shells[i] != NULL) { | 771 | while (shells[i] != NULL) { |
762 | struct stat s; | ||
763 | // access call checks as real UID/GID, not as effective UID/GID | 772 | // access call checks as real UID/GID, not as effective UID/GID |
764 | if (stat(shells[i], &s) == 0 && access(shells[i], R_OK) == 0) { | 773 | if (stat(shells[i], &s) == 0 && access(shells[i], R_OK) == 0) { |
765 | shell = shells[i]; | 774 | shell = shells[i]; |