diff options
author | Rostislav Pehlivanov <atomnuker@gmail.com> | 2018-05-06 00:20:49 +0100 |
---|---|---|
committer | Rostislav Pehlivanov <atomnuker@gmail.com> | 2018-05-06 00:20:49 +0100 |
commit | b592351eeff55a0a95f9b65d403fcfda9cf02957 (patch) | |
tree | 664422efe55745fabd11a7e2845722b9485e9414 /sway/commands/exec_always.c | |
parent | Revert "Make the LIBDIR path configurable" (diff) | |
download | sway-b592351eeff55a0a95f9b65d403fcfda9cf02957.tar.gz sway-b592351eeff55a0a95f9b65d403fcfda9cf02957.tar.zst sway-b592351eeff55a0a95f9b65d403fcfda9cf02957.zip |
Revert "exec_always: Search for executables in /usr/lib/sway"
This reverts commit 7709340727fe2834f87b43aeeaef878694d5acd6.
Diffstat (limited to 'sway/commands/exec_always.c')
-rw-r--r-- | sway/commands/exec_always.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 16bbcb61..af4e4965 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c | |||
@@ -51,41 +51,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { | |||
51 | if ((pid = fork()) == 0) { | 51 | if ((pid = fork()) == 0) { |
52 | // Fork child process again | 52 | // Fork child process again |
53 | setsid(); | 53 | setsid(); |
54 | |||
55 | if ((*child = fork()) == 0) { | 54 | if ((*child = fork()) == 0) { |
56 | // Acquire the current PATH | ||
57 | char *path = getenv("PATH"); | ||
58 | const char *extra_path = ":/usr/lib/sway"; | ||
59 | const size_t extra_size = sizeof("/usr/lib/sway") + 1; | ||
60 | |||
61 | if (!path) { | ||
62 | size_t n = confstr(_CS_PATH, NULL, 0); | ||
63 | path = malloc(n + extra_size); | ||
64 | if (!path) { | ||
65 | return cmd_results_new(CMD_FAILURE, "exec_always", "Unable to allocate PATH"); | ||
66 | } | ||
67 | confstr(_CS_PATH, path, n); | ||
68 | |||
69 | } else { | ||
70 | size_t n = strlen(path) + 1; | ||
71 | char *tmp = malloc(n + extra_size); | ||
72 | if (!tmp) { | ||
73 | return cmd_results_new(CMD_FAILURE, "exec_always", "Unable to allocate PATH"); | ||
74 | } | ||
75 | |||
76 | strncpy(tmp, path, n); | ||
77 | path = tmp; | ||
78 | } | ||
79 | |||
80 | // Append /usr/lib/sway to PATH | ||
81 | strcat(path, extra_path); | ||
82 | if (setenv("PATH", path, 1) == -1) { | ||
83 | free(path); | ||
84 | return cmd_results_new(CMD_FAILURE, "exec_always", "Unable to set PATH"); | ||
85 | } | ||
86 | free(path); | ||
87 | |||
88 | // Execute the command | ||
89 | execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); | 55 | execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); |
90 | // Not reached | 56 | // Not reached |
91 | } | 57 | } |