From 91588630ebe436e0586c6234ffda518ebd8501aa Mon Sep 17 00:00:00 2001 From: smitsohu Date: Tue, 22 Dec 2020 17:14:41 +0100 Subject: rework previous commit 45c28b808df9529aca32fdd755ac14e8101af3c1 --- src/firejail/main.c | 13 ++++++------- src/firejail/no_sandbox.c | 1 - 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/firejail/main.c b/src/firejail/main.c index babeac1ef..544bfe83a 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -864,13 +864,12 @@ char *guess_shell(void) { char *shell = NULL; struct stat s; - if (!login_shell) { // if firejail is the login shell, SHELL is set to path of firejail executable - shell = getenv("SHELL"); - if (shell) { - invalid_filename(shell, 0); // no globbing - if (!is_dir(shell) && strstr(shell, "..") == NULL && stat(shell, &s) == 0 && access(shell, X_OK) == 0) - return shell; - } + shell = getenv("SHELL"); + if (shell) { + invalid_filename(shell, 0); // no globbing + if (!is_dir(shell) && strstr(shell, "..") == NULL && stat(shell, &s) == 0 && access(shell, X_OK) == 0 && + strcmp(shell, PATH_FIREJAIL) != 0) + return shell; } // shells in order of preference diff --git a/src/firejail/no_sandbox.c b/src/firejail/no_sandbox.c index 6d01d443a..ef0af1491 100644 --- a/src/firejail/no_sandbox.c +++ b/src/firejail/no_sandbox.c @@ -178,7 +178,6 @@ void run_no_sandbox(int argc, char **argv) { // use $SHELL to get shell used in sandbox, guess shell otherwise assert(login_shell == 0); - cfg.shell = guess_shell(); if (!cfg.shell) { fprintf(stderr, "Error: unable to guess your shell, please set SHELL environment variable\n"); exit(1); -- cgit v1.2.3-70-g09d2