From 87e864b39f4211818820aa81098a497862981d5f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 22 Jun 2023 16:26:00 +0200 Subject: Hide xwayland_shell_v1 from regular clients Regular clients are not allowed to use this interface. wlroots already sends a protocol error if a non-Xwayland client tries to use this interface, but let's remove all temptation by hiding it completely. --- sway/server.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sway/server.c b/sway/server.c index cc4719d7..1fa16fd1 100644 --- a/sway/server.c +++ b/sway/server.c @@ -47,6 +47,7 @@ #include "sway/tree/root.h" #if HAVE_XWAYLAND +#include #include "sway/xwayland.h" #endif @@ -71,11 +72,25 @@ static void handle_drm_lease_request(struct wl_listener *listener, void *data) { } #endif +static bool filter_global(const struct wl_client *client, + const struct wl_global *global, void *data) { +#if HAVE_XWAYLAND + struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland; + if (global == xwayland->shell_v1->global) { + return xwayland->server != NULL && client == xwayland->server->client; + } +#endif + + return true; +} + bool server_init(struct sway_server *server) { sway_log(SWAY_DEBUG, "Initializing Wayland server"); server->wl_display = wl_display_create(); server->wl_event_loop = wl_display_get_event_loop(server->wl_display); + wl_display_set_global_filter(server->wl_display, filter_global, NULL); + server->backend = wlr_backend_autocreate(server->wl_display, &server->session); if (!server->backend) { sway_log(SWAY_ERROR, "Unable to create backend"); -- cgit v1.2.3-54-g00ecf