]> git.sur5r.net Git - i3/i3/commitdiff
Use _PATH_BSHELL to ensure using a bourne shell
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 8 Nov 2013 20:13:35 +0000 (21:13 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 9 Nov 2013 09:11:32 +0000 (10:11 +0100)
[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
i3bar/src/child.c
src/startup.c

index f7a44093dd05defbfccb756092aeb10a7e9d74c4..0fa75f8e0550dc9b00dd78b84c8826179b7d69ad 100644 (file)
@@ -22,6 +22,7 @@
 #include <getopt.h>
 #include <limits.h>
 #include <fcntl.h>
+#include <paths.h>
 
 #include <xcb/xcb.h>
 #include <xcb/xcb_aux.h>
@@ -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);
index 4e5e49c928edf37f1e3ff450c0cb5b5c0f87ddaa..dce0218fd305fda1ee38be246a47cc2e3618f249 100644 (file)
@@ -22,6 +22,7 @@
 #include <yajl/yajl_parse.h>
 #include <yajl/yajl_version.h>
 #include <yajl/yajl_gen.h>
+#include <paths.h>
 
 #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 */
index ee51664fa3dd7ab360ed5674d87667df772fb018..85e5dbc2e400b75651398cd2c0746677811b2ee6 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <paths.h>
 
 #define SN_API_NOT_YET_FROZEN 1
 #include <libsn/sn-launcher.h>
@@ -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);