From 8305c7bd0639f3ac28043a6ed9a95b34dede5b32 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 18 Jan 2022 17:57:38 +0100 Subject: [PATCH] wayland/client: Restore the NOFILE limit Make sure the restore the original NOFILE limit prior to run the trusted Wayland client so it does not inherit from the raised value. Part-of: --- src/wayland/meta-wayland-client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wayland/meta-wayland-client.c b/src/wayland/meta-wayland-client.c index dfae1eda6..69c7b8333 100644 --- a/src/wayland/meta-wayland-client.c +++ b/src/wayland/meta-wayland-client.c @@ -92,6 +92,15 @@ process_died (GObject *source, client->process_running = FALSE; } +static void +child_setup (gpointer user_data) +{ + MetaDisplay *display = user_data; + MetaContext *context = meta_display_get_context (display); + + meta_context_restore_rlimit_nofile (context, NULL); +} + /** * meta_wayland_client_new: * @launcher: (not nullable): a GSubprocessLauncher to use to launch the subprocess @@ -196,6 +205,8 @@ meta_wayland_client_spawnv (MetaWaylandClient *client, compositor = meta_wayland_compositor_get_default (); g_subprocess_launcher_take_fd (client->launcher, client_fd[1], 3); g_subprocess_launcher_setenv (client->launcher, "WAYLAND_SOCKET", "3", TRUE); + g_subprocess_launcher_set_child_setup (client->launcher, + child_setup, display, NULL); wayland_client = wl_client_create (compositor->wayland_display, client_fd[0]); subprocess = g_subprocess_launcher_spawnv (client->launcher, argv, error); g_clear_object (&client->launcher);