From 4e221d70f498cc42b52019122dbd30bcfdb1eba5 Mon Sep 17 00:00:00 2001 From: thewisenerd Date: Sat, 24 Dec 2016 05:03:54 +0530 Subject: main: guess_shell: use $SHELL variable if set fixes #983 --- src/firejail/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') 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) { char *guess_shell(void) { char *shell = NULL; + struct stat s; + + shell = getenv("SHELL"); + if (shell) { + // TODO: handle rogue shell variables? + if (stat(shell, &s) == 0 && access(shell, R_OK) == 0) { + return shell; + } + } + // shells in order of preference char *shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL }; int i = 0; while (shells[i] != NULL) { - struct stat s; // access call checks as real UID/GID, not as effective UID/GID if (stat(shells[i], &s) == 0 && access(shells[i], R_OK) == 0) { shell = shells[i]; -- cgit v1.2.3-54-g00ecf