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>
This commit is contained in:
Olivier Fourdan 2022-01-18 17:57:38 +01:00
parent acded0648c
commit 8305c7bd06

View File

@ -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);