aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/main.c')
-rw-r--r--src/firejail/main.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 7ec2d6114..12ac01de7 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -862,12 +862,11 @@ static void run_cmd_and_exit(int i, int argc, char **argv) {
862char *guess_shell(void) { 862char *guess_shell(void) {
863 const char *shell; 863 const char *shell;
864 char *retval; 864 char *retval;
865 struct stat s;
866 865
867 shell = env_get("SHELL"); 866 shell = env_get("SHELL");
868 if (shell) { 867 if (shell) {
869 invalid_filename(shell, 0); // no globbing 868 invalid_filename(shell, 0); // no globbing
870 if (!is_dir(shell) && strstr(shell, "..") == NULL && stat(shell, &s) == 0 && access(shell, X_OK) == 0 && 869 if (access(shell, X_OK) == 0 && !is_dir(shell) && strstr(shell, "..") == NULL &&
871 strcmp(shell, PATH_FIREJAIL) != 0) 870 strcmp(shell, PATH_FIREJAIL) != 0)
872 goto found; 871 goto found;
873 } 872 }
@@ -878,12 +877,15 @@ char *guess_shell(void) {
878 int i = 0; 877 int i = 0;
879 while (shells[i] != NULL) { 878 while (shells[i] != NULL) {
880 // access call checks as real UID/GID, not as effective UID/GID 879 // access call checks as real UID/GID, not as effective UID/GID
881 if (stat(shells[i], &s) == 0 && access(shells[i], X_OK) == 0) { 880 if (access(shells[i], X_OK) == 0) {
882 shell = shells[i]; 881 shell = shells[i];
883 break; 882 goto found;
884 } 883 }
885 i++; 884 i++;
886 } 885 }
886
887 return NULL;
888
887 found: 889 found:
888 retval = strdup(shell); 890 retval = strdup(shell);
889 if (!retval) 891 if (!retval)