From f691a55923850a4d315450925fc98733d07b69c9 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Fri, 8 Nov 2013 21:13:35 +0100 Subject: [PATCH] Use _PATH_BSHELL to ensure using a bourne shell [Michael] This commit should fix problems with people using a non-bourne shell as login shell, e.g. fish or rc. AFAICT, $SHELL should only be used for interactive shells, but we just want a bourne shell, not an interactive shell. --- i3-nagbar/main.c | 10 ++-------- i3bar/src/child.c | 8 ++------ src/startup.c | 11 ++--------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index f7a44093..0fa75f8e 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -95,15 +96,8 @@ static void start_application(const char *command) { /* Child process */ setsid(); if (fork() == 0) { - /* Stores the path of the shell */ - static const char *shell = NULL; - - if (shell == NULL) - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - /* This is the child */ - execl(shell, shell, "-c", command, (void*)NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL); /* not reached */ } exit(0); diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 4e5e49c9..dce0218f 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "common.h" @@ -423,12 +424,7 @@ void start_child(char *command) { dup2(pipe_in[1], STDOUT_FILENO); dup2(pipe_out[0], STDIN_FILENO); - static const char *shell = NULL; - - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - - execl(shell, shell, "-c", command, (char*) NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (char*) NULL); return; default: /* Parent-process. Reroute streams */ diff --git a/src/startup.c b/src/startup.c index ee51664f..85e5dbc2 100644 --- a/src/startup.c +++ b/src/startup.c @@ -17,6 +17,7 @@ #include #include +#include #define SN_API_NOT_YET_FROZEN 1 #include @@ -191,15 +192,7 @@ void start_application(const char *command, bool no_startup_id) { if (!no_startup_id) sn_launcher_context_setup_child_process(context); - /* Stores the path of the shell */ - static const char *shell = NULL; - - if (shell == NULL) - if ((shell = getenv("SHELL")) == NULL) - shell = "/bin/sh"; - - /* This is the child */ - execl(shell, shell, "-c", command, (void*)NULL); + execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (void*)NULL); /* not reached */ } _exit(0); -- 2.39.5