From 9c56eb051f7fc6b261e8ee8ac27a3199869316a1 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 15 May 2024 09:48:55 +0200 Subject: [PATCH] Server: fix filtering of newly created globals Fixes: https://codeberg.org/river/river/issues/1068 (cherry picked from commit b5a80c7b9b34a42b2546d8724498b0b6d59f6cec) --- river/Server.zig | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/river/Server.zig b/river/Server.zig index e1fda5f..895f1cc 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -289,21 +289,17 @@ fn allowlist(server: *Server, global: *const wl.Global) bool { if (server.drm) |drm| if (global == drm.global) return true; if (server.linux_dmabuf) |linux_dmabuf| if (global == linux_dmabuf.global) return true; - { - var it = server.root.all_outputs.iterator(.forward); - while (it.next()) |output| { - if (global == output.wlr_output.global) return true; - } - } - - { - var it = server.input_manager.seats.first; - while (it) |node| : (it = node.next) { - if (global == node.data.wlr_seat.global) return true; - } - } - - return global == hackGlobal(server.shm) or + // We must use the getInterface() approach for dynamically created globals + // such as wl_output and wl_seat since the wl_global_create() function will + // advertise the global to clients and invoke this filter before returning + // the new global pointer. + // + // For other globals I like the current pointer comparison approach as it + // should catch river accidentally exposing multiple copies of e.g. wl_shm + // with an assertion failure. + return global.getInterface() == wl.Output.getInterface() or + global.getInterface() == wl.Seat.getInterface() or + global == hackGlobal(server.shm) or global == hackGlobal(server.single_pixel_buffer_manager) or global == server.viewporter.global or global == server.fractional_scale_manager.global or