diff options
-rw-r--r-- | meson.build | 9 | ||||
-rw-r--r-- | security.d/00-defaults.in | 6 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 38 | ||||
-rw-r--r-- | swaybar/meson.build | 3 | ||||
-rw-r--r-- | swaybg/meson.build | 3 |
5 files changed, 54 insertions, 5 deletions
diff --git a/meson.build b/meson.build index bf266e5f..e40dc33c 100644 --- a/meson.build +++ b/meson.build | |||
@@ -19,6 +19,14 @@ is_freebsd = host_machine.system().startswith('freebsd') | |||
19 | datadir = get_option('datadir') | 19 | datadir = get_option('datadir') |
20 | sysconfdir = get_option('sysconfdir') | 20 | sysconfdir = get_option('sysconfdir') |
21 | prefix = get_option('prefix') | 21 | prefix = get_option('prefix') |
22 | libexecdir = get_option('libexecdir') | ||
23 | |||
24 | if libexecdir == '' | ||
25 | libexecdir = 'lib' | ||
26 | endif | ||
27 | sway_libexecdir = join_paths(prefix, libexecdir, 'sway') | ||
28 | add_project_arguments('-DSWAY_LIBEXECDIR="/@0@"'.format(sway_libexecdir), language : 'c') | ||
29 | |||
22 | 30 | ||
23 | jsonc = dependency('json-c', version: '>=0.13') | 31 | jsonc = dependency('json-c', version: '>=0.13') |
24 | pcre = dependency('libpcre') | 32 | pcre = dependency('libpcre') |
@@ -113,6 +121,7 @@ config = configuration_data() | |||
113 | config.set('sysconfdir', join_paths(prefix, sysconfdir)) | 121 | config.set('sysconfdir', join_paths(prefix, sysconfdir)) |
114 | config.set('datadir', join_paths(prefix, datadir)) | 122 | config.set('datadir', join_paths(prefix, datadir)) |
115 | config.set('prefix', prefix) | 123 | config.set('prefix', prefix) |
124 | config.set('sway_libexecdir', sway_libexecdir) | ||
116 | 125 | ||
117 | configure_file( | 126 | configure_file( |
118 | configuration: config, | 127 | configuration: config, |
diff --git a/security.d/00-defaults.in b/security.d/00-defaults.in index e4626477..b5ae1149 100644 --- a/security.d/00-defaults.in +++ b/security.d/00-defaults.in | |||
@@ -11,9 +11,9 @@ | |||
11 | # Configures enabled compositor features for specific programs | 11 | # Configures enabled compositor features for specific programs |
12 | permit * fullscreen keyboard mouse | 12 | permit * fullscreen keyboard mouse |
13 | permit @prefix@/bin/swaylock lock | 13 | permit @prefix@/bin/swaylock lock |
14 | permit @prefix@/bin/swaybg background | ||
15 | permit @prefix@/bin/swaygrab screenshot | 14 | permit @prefix@/bin/swaygrab screenshot |
16 | permit @prefix@/bin/swaybar panel | 15 | permit @sway_libexecdir@/swaybg background |
16 | permit @sway_libexecdir@/swaybar panel | ||
17 | 17 | ||
18 | # Configures enabled IPC features for specific programs | 18 | # Configures enabled IPC features for specific programs |
19 | ipc @prefix@/bin/swaymsg { | 19 | ipc @prefix@/bin/swaymsg { |
@@ -24,7 +24,7 @@ ipc @prefix@/bin/swaymsg { | |||
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
27 | ipc @prefix@/bin/swaybar { | 27 | ipc @sway_libexecdir@/swaybar { |
28 | bar-config enabled | 28 | bar-config enabled |
29 | outputs enabled | 29 | outputs enabled |
30 | workspaces enabled | 30 | workspaces enabled |
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index af4e4965..b3078640 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "log.h" | 11 | #include "log.h" |
12 | #include "stringop.h" | 12 | #include "stringop.h" |
13 | 13 | ||
14 | |||
14 | struct cmd_results *cmd_exec_always(int argc, char **argv) { | 15 | struct cmd_results *cmd_exec_always(int argc, char **argv) { |
15 | struct cmd_results *error = NULL; | 16 | struct cmd_results *error = NULL; |
16 | if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); | 17 | if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); |
@@ -51,7 +52,44 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { | |||
51 | if ((pid = fork()) == 0) { | 52 | if ((pid = fork()) == 0) { |
52 | // Fork child process again | 53 | // Fork child process again |
53 | setsid(); | 54 | setsid(); |
55 | |||
54 | if ((*child = fork()) == 0) { | 56 | if ((*child = fork()) == 0) { |
57 | // Acquire the current PATH | ||
58 | char *path = getenv("PATH"); | ||
59 | const char *extra_path = ":" SWAY_LIBEXECDIR; | ||
60 | const size_t extra_size = sizeof(SWAY_LIBEXECDIR) + 1; | ||
61 | |||
62 | if (!path) { | ||
63 | size_t n = confstr(_CS_PATH, NULL, 0); | ||
64 | path = malloc(n + extra_size); | ||
65 | if (!path) { | ||
66 | wlr_log(L_ERROR, "exec_always: Unable to allocate PATH"); | ||
67 | exit(EXIT_FAILURE); | ||
68 | } | ||
69 | confstr(_CS_PATH, path, n); | ||
70 | |||
71 | } else { | ||
72 | size_t n = strlen(path) + 1; | ||
73 | char *tmp = malloc(n + extra_size); | ||
74 | if (!tmp) { | ||
75 | wlr_log(L_ERROR, "exec_always: Unable to allocate PATH"); | ||
76 | exit(EXIT_FAILURE); | ||
77 | } | ||
78 | |||
79 | strncpy(tmp, path, n); | ||
80 | path = tmp; | ||
81 | } | ||
82 | |||
83 | // Append /usr/lib/sway to PATH | ||
84 | strcat(path, extra_path); | ||
85 | if (!setenv("PATH", path, 1)) { | ||
86 | free(path); | ||
87 | wlr_log(L_ERROR, "exec_always: Unable to set PATH"); | ||
88 | exit(EXIT_FAILURE); | ||
89 | } | ||
90 | free(path); | ||
91 | |||
92 | // Execute the command | ||
55 | execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); | 93 | execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); |
56 | // Not reached | 94 | // Not reached |
57 | } | 95 | } |
diff --git a/swaybar/meson.build b/swaybar/meson.build index d65edb11..41c81a88 100644 --- a/swaybar/meson.build +++ b/swaybar/meson.build | |||
@@ -24,5 +24,6 @@ executable( | |||
24 | wlroots, | 24 | wlroots, |
25 | ], | 25 | ], |
26 | link_with: [lib_sway_common, lib_sway_client], | 26 | link_with: [lib_sway_common, lib_sway_client], |
27 | install: true | 27 | install: true, |
28 | install_dir: sway_libexecdir | ||
28 | ) | 29 | ) |
diff --git a/swaybg/meson.build b/swaybg/meson.build index 8704de6d..716178d2 100644 --- a/swaybg/meson.build +++ b/swaybg/meson.build | |||
@@ -14,5 +14,6 @@ executable( | |||
14 | wlroots, | 14 | wlroots, |
15 | ], | 15 | ], |
16 | link_with: [lib_sway_common, lib_sway_client], | 16 | link_with: [lib_sway_common, lib_sway_client], |
17 | install: true | 17 | install: true, |
18 | install_dir: sway_libexecdir | ||
18 | ) | 19 | ) |