Skip to content

Commit

Permalink
Use execlp("sh") instead of execl("/bin/sh")
Browse files Browse the repository at this point in the history
This stops assuming the POSIX shell command is located in /bin.
  • Loading branch information
emersion authored and kennylevinsen committed Apr 22, 2021
1 parent e3e99d9 commit 7beeb9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sway/commands/exec_always.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions sway/swaynag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions swaynag/swaynag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 7beeb9e

Please sign in to comment.