aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Arkadiusz Hiler <arek@hiler.eu>2018-09-30 15:11:24 +0300
committerLibravatar Arkadiusz Hiler <arek@hiler.eu>2018-09-30 15:37:01 +0300
commiteed0bc3ebd15bf94a28ca019ab656a3a0bc0d258 (patch)
tree63e09dad69399fe4470830b3103301a97ce0ab7f
parentMerge pull request #2726 from RyanDwyer/overhaul-gaps (diff)
downloadsway-eed0bc3ebd15bf94a28ca019ab656a3a0bc0d258.tar.gz
sway-eed0bc3ebd15bf94a28ca019ab656a3a0bc0d258.tar.zst
sway-eed0bc3ebd15bf94a28ca019ab656a3a0bc0d258.zip
Add support for installing binaries with DT_RPATH
It's better to use DT_RPATH dynamic section of the elf binary to store the paths of libraries to load instead of overwriting LD_LIBRARY_PATH for the whole environment, causing surprises. This solution is much more transparent and perfectly suitable for running contained installations of wayland/wlroots/sway. The code unsetting the LD_LIBRARY_PATH/LD_PRELOAD was also deleted as it's a placebo security at best - we should trust the execution path that leads us to running sway, and it's way too late to care about those variables since we already started executing our compositor, thus we would be compromised anyway.
-rw-r--r--meson.build11
-rw-r--r--meson_options.txt3
-rw-r--r--sway/main.c8
-rw-r--r--sway/meson.build1
-rw-r--r--swaybar/meson.build1
-rw-r--r--swaybg/meson.build1
-rw-r--r--swayidle/meson.build1
-rw-r--r--swaylock/meson.build1
-rw-r--r--swaymsg/meson.build1
-rw-r--r--swaynag/meson.build1
10 files changed, 19 insertions, 10 deletions
diff --git a/meson.build b/meson.build
index 080709fa..1e7ce281 100644
--- a/meson.build
+++ b/meson.build
@@ -128,7 +128,16 @@ else
128endif 128endif
129add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') 129add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
130 130
131add_project_arguments('-D_LD_LIBRARY_PATH="@0@"'.format(get_option('ld-library-path')), language: 'c') 131if get_option('use_rpath')
132 if get_option('custom_rpath') == ''
133 # default to platform specific libdir, one level up from the binary
134 rpathdir = join_paths('$ORIGIN', '..', '$LIB')
135 else
136 rpathdir = get_option('custom_rpath')
137 endif
138else
139 rpathdir = ''
140endif
132 141
133sway_inc = include_directories('include') 142sway_inc = include_directories('include')
134 143
diff --git a/meson_options.txt b/meson_options.txt
index 50d646fd..2db852fc 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,6 @@
1option('sway-version', type : 'string', description: 'The version string reported in `sway --version`.') 1option('sway-version', type : 'string', description: 'The version string reported in `sway --version`.')
2option('ld-library-path', type: 'string', value: '', description: 'The LD_LIBRARY_PATH environment variable.') 2option('use_rpath', type: 'boolean', value: false, description: 'install binaries with rpath set')
3option('custom_rpath', type: 'string', value: '', description: 'override rpath with a custom one')
3option('default-wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.') 4option('default-wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.')
4option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.') 5option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
5option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.') 6option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
diff --git a/sway/main.c b/sway/main.c
index 50b05b21..dea4a31c 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -241,14 +241,6 @@ int main(int argc, char **argv) {
241 " --get-socketpath Gets the IPC socket path and prints it, then exits.\n" 241 " --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
242 "\n"; 242 "\n";
243 243
244 // Security:
245 unsetenv("LD_PRELOAD");
246#ifdef _LD_LIBRARY_PATH
247 setenv("LD_LIBRARY_PATH", _LD_LIBRARY_PATH, 1);
248#else
249 unsetenv("LD_LIBRARY_PATH");
250#endif
251
252 int c; 244 int c;
253 while (1) { 245 while (1) {
254 int option_index = 0; 246 int option_index = 0;
diff --git a/sway/meson.build b/sway/meson.build
index b6394ecb..6eb9a9d7 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -187,5 +187,6 @@ executable(
187 include_directories: [sway_inc], 187 include_directories: [sway_inc],
188 dependencies: sway_deps, 188 dependencies: sway_deps,
189 link_with: [lib_sway_common], 189 link_with: [lib_sway_common],
190 install_rpath : rpathdir,
190 install: true 191 install: true
191) 192)
diff --git a/swaybar/meson.build b/swaybar/meson.build
index d65edb11..7a02a33f 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_rpath : rpathdir,
27 install: true 28 install: true
28) 29)
diff --git a/swaybg/meson.build b/swaybg/meson.build
index 8704de6d..095c5488 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_rpath : rpathdir,
17 install: true 18 install: true
18) 19)
diff --git a/swayidle/meson.build b/swayidle/meson.build
index f62545f8..6c3ac119 100644
--- a/swayidle/meson.build
+++ b/swayidle/meson.build
@@ -14,5 +14,6 @@ executable(
14 swayidle_deps, 14 swayidle_deps,
15 ], 15 ],
16 link_with: [lib_sway_common, lib_sway_client], 16 link_with: [lib_sway_common, lib_sway_client],
17 install_rpath : rpathdir,
17 install: true 18 install: true
18) 19)
diff --git a/swaylock/meson.build b/swaylock/meson.build
index 6c87d173..6605340b 100644
--- a/swaylock/meson.build
+++ b/swaylock/meson.build
@@ -33,6 +33,7 @@ executable('swaylock',
33 include_directories: [sway_inc], 33 include_directories: [sway_inc],
34 dependencies: dependencies, 34 dependencies: dependencies,
35 link_with: [lib_sway_common, lib_sway_client], 35 link_with: [lib_sway_common, lib_sway_client],
36 install_rpath : rpathdir,
36 install: true 37 install: true
37) 38)
38 39
diff --git a/swaymsg/meson.build b/swaymsg/meson.build
index 8638b838..7318349d 100644
--- a/swaymsg/meson.build
+++ b/swaymsg/meson.build
@@ -4,5 +4,6 @@ executable(
4 include_directories: [sway_inc], 4 include_directories: [sway_inc],
5 dependencies: [jsonc, wlroots], 5 dependencies: [jsonc, wlroots],
6 link_with: [lib_sway_common], 6 link_with: [lib_sway_common],
7 install_rpath : rpathdir,
7 install: true 8 install: true
8) 9)
diff --git a/swaynag/meson.build b/swaynag/meson.build
index 2ba3ed95..223a0bc7 100644
--- a/swaynag/meson.build
+++ b/swaynag/meson.build
@@ -19,5 +19,6 @@ executable(
19 wlroots, 19 wlroots,
20 ], 20 ],
21 link_with: [lib_sway_common, lib_sway_client], 21 link_with: [lib_sway_common, lib_sway_client],
22 install_rpath : rpathdir,
22 install: true 23 install: true
23) 24)