From eec2e1d3b16ba40c85483badcc7809277274ce5d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 4 Feb 2021 17:56:28 +0100 Subject: [PATCH] xwayland: check executable exists on init Instead of walking PATH like a previous proposal [1], this one checks that the Xwayland path specified in the pkg-config file exists. I think this is a reasonable compromise: - Users that don't have Xwayland installed system-wide won't get a bogus DISPLAY env variable set up. - Users that have WLR_XWAYLAND set won't be affected by this check. - Users that have Xwayland installed system-wide and a different Xwayland in their PATH still get their custom Xwayland. - Users that don't have Xwayland installed system-wide but have it somewhere else in PATH are left out. But this is pretty niche, and they can just set WLR_XWAYLAND. [1]: https://github.com/swaywm/wlroots/pull/2314 --- include/meson.build | 2 ++ include/xwayland/meson.build | 12 ++++++++++++ xwayland/server.c | 6 ++++++ 3 files changed, 20 insertions(+) create mode 100644 include/xwayland/meson.build diff --git a/include/meson.build b/include/meson.build index 30b9f2fe..c72eada5 100644 --- a/include/meson.build +++ b/include/meson.build @@ -6,6 +6,8 @@ if not features.get('x11-backend') endif if not features.get('xwayland') exclude_files += 'xwayland.h' +else + subdir('xwayland') endif if not features.get('xdg-foreign') exclude_files += [ diff --git a/include/xwayland/meson.build b/include/xwayland/meson.build new file mode 100644 index 00000000..16712083 --- /dev/null +++ b/include/xwayland/meson.build @@ -0,0 +1,12 @@ +if xwayland.found() + xwayland_path = xwayland.get_pkgconfig_variable('xwayland') +else + xwayland_path = xwayland_prog.full_path() +endif + +xwayland_config_data = configuration_data() +xwayland_config_data.set_quoted('XWAYLAND_PATH', xwayland_path) +configure_file( + output: 'config.h', + configuration: xwayland_config_data, +) diff --git a/xwayland/server.c b/xwayland/server.c index 6a0c9fc3..f5c6b060 100644 --- a/xwayland/server.c +++ b/xwayland/server.c @@ -16,6 +16,7 @@ #include #include "sockets.h" #include "util/signal.h" +#include "xwayland/config.h" static void safe_close(int fd) { if (fd >= 0) { @@ -442,6 +443,11 @@ void wlr_xwayland_server_destroy(struct wlr_xwayland_server *server) { struct wlr_xwayland_server *wlr_xwayland_server_create( struct wl_display *wl_display, struct wlr_xwayland_server_options *options) { + if (!getenv("WLR_XWAYLAND") && access(XWAYLAND_PATH, X_OK) != 0) { + wlr_log(WLR_ERROR, "Cannot find Xwayland binary \"%s\"", XWAYLAND_PATH); + return NULL; + } + struct wlr_xwayland_server *server = calloc(1, sizeof(struct wlr_xwayland_server)); if (!server) {