aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar thewisenerd <thewisenerd@protonmail.com>2016-12-24 05:03:54 +0530
committerLibravatar thewisenerd <thewisenerd@protonmail.com>2016-12-24 05:09:38 +0530
commit4e221d70f498cc42b52019122dbd30bcfdb1eba5 (patch)
tree13b646b19639dbe901143a61178f6edd044ef931 /src
parenttesting (diff)
downloadfirejail-4e221d70f498cc42b52019122dbd30bcfdb1eba5.tar.gz
firejail-4e221d70f498cc42b52019122dbd30bcfdb1eba5.tar.zst
firejail-4e221d70f498cc42b52019122dbd30bcfdb1eba5.zip
main: guess_shell: use $SHELL variable if set
fixes #983
Diffstat (limited to 'src')
-rw-r--r--src/firejail/main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 15820f7dd..c74fb02d2 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
755char *guess_shell(void) { 755char *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];