From 180494ca41518a649eb96ae06ccd9d382aec3aad Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 19 Nov 2019 16:08:25 +0100 Subject: [PATCH] run: Don't install polkit agent for enter/run/build Neither of these ever need a polkit agent, and run/build are somewhat performance sensitive and we don't want to connect to dbus unnecessarily. For enter this is critical though, as the dbus connection starts a thread which is not compatible with the setns syscall. --- app/flatpak-main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/flatpak-main.c b/app/flatpak-main.c index c50657f7..07828e9f 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -745,7 +745,12 @@ flatpak_run (int argc, check_environment (); - polkit_agent = install_polkit_agent (); + /* Don't talk to dbus in enter, as it must be thread-free to setns, also + skip run/build for performance reasons (no need to connect to dbus). */ + if (g_strcmp0 (command->name, "enter") != 0 && + g_strcmp0 (command->name, "run") != 0 && + g_strcmp0 (command->name, "build") != 0) + polkit_agent = install_polkit_agent (); if (!command->fn (argc, argv, cancellable, &error)) goto out;