[mutter] wayland/client: Restore the NOFILE limit



commit 8305c7bd0639f3ac28043a6ed9a95b34dede5b32
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Jan 18 17:57:38 2022 +0100

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2235>

 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 dfae1eda6d..69c7b83335 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]