From 7beeb9e61b7f18a8c2e9aa015958cffde9b76c05 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 16 Apr 2021 10:31:30 +0200 Subject: [PATCH] Use execlp("sh") instead of execl("/bin/sh") This stops assuming the POSIX shell command is located in /bin. --- sway/commands/exec_always.c | 2 +- sway/swaynag.c | 4 ++-- swaynag/swaynag.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 39e48a44..3786bfb7 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -65,7 +65,7 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) { close(fd[0]); if ((child = fork()) == 0) { close(fd[1]); - execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); + execlp("sh", "sh", "-c", cmd, (void *)NULL); _exit(0); } ssize_t s = 0; diff --git a/sway/swaynag.c b/sway/swaynag.c index db5a919a..ba582989 100644 --- a/sway/swaynag.c +++ b/sway/swaynag.c @@ -87,8 +87,8 @@ bool swaynag_spawn(const char *swaynag_command, size_t length = strlen(swaynag_command) + strlen(swaynag->args) + 2; char *cmd = malloc(length); snprintf(cmd, length, "%s %s", swaynag_command, swaynag->args); - execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); - sway_log_errno(SWAY_ERROR, "execl failed"); + execlp("sh", "sh", "-c", cmd, NULL); + sway_log_errno(SWAY_ERROR, "execlp failed"); _exit(EXIT_FAILURE); } _exit(EXIT_SUCCESS); diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 1d1dbee2..609e4831 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -30,8 +30,8 @@ static bool terminal_execute(char *terminal, char *command) { chmod(fname, S_IRUSR | S_IWUSR | S_IXUSR); char *cmd = malloc(sizeof(char) * (strlen(terminal) + strlen(" -e ") + strlen(fname) + 1)); sprintf(cmd, "%s -e %s", terminal, fname); - execl("/bin/sh", "/bin/sh", "-c", cmd, NULL); - sway_log_errno(SWAY_ERROR, "Failed to run command, execl() returned."); + execlp("sh", "sh", "-c", cmd, NULL); + sway_log_errno(SWAY_ERROR, "Failed to run command, execlp() returned."); free(cmd); return false; } @@ -69,8 +69,8 @@ static void swaynag_button_execute(struct swaynag *swaynag, sway_log(SWAY_DEBUG, "$TERMINAL not found. Running directly"); } - execl("/bin/sh", "/bin/sh", "-c", button->action, NULL); - sway_log_errno(SWAY_DEBUG, "execl failed"); + execlp("sh", "sh", "-c", button->action, NULL); + sway_log_errno(SWAY_DEBUG, "execlp failed"); _exit(EXIT_FAILURE); } }