From ade6d658855f3f41987b33a511cf690dd21969b2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 1 Jul 2019 12:39:50 +0100 Subject: [PATCH] Don't register polkit agent if we cannot connect to system bus This works around an old polkit client library bug which would cause a segfault in this situation. The bug was fixed long ago in upstream polkit, but is still present in Debian 10 'buster', Ubuntu 19.04 'disco' and all older releases, due to Debian/Ubuntu using a branch of polkit to avoid the mozjs dependency. It should finally get fixed in Debian 11 and Ubuntu 19.10. Signed-off-by: Simon McVittie Bug-Debian: https://bugs.debian.org/923046 Closes: #2997 Approved by: matthiasclasen (cherry picked from commit 75b5b7c76357f7f0fa6465dc49359cee62e9cd87) (cherry picked from commit 62cb645171570b2a749934dc45dd62aa8c80c107) Closes: #3115 Approved by: alexlarsson --- app/flatpak-main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/flatpak-main.c b/app/flatpak-main.c index 6ac953da..d9f52822 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -532,6 +532,15 @@ install_polkit_agent (void) #ifdef USE_SYSTEM_HELPER PolkitAgentListener *listener = NULL; g_autoptr(GError) local_error = NULL; + g_autoptr(GDBusConnection) bus = NULL; + + bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &local_error); + + if (bus == NULL) + { + g_debug ("Unable to connect to system bus: %s", local_error->message); + return NULL; + } /* Install a polkit agent as fallback, in case we're running on a console */ listener = flatpak_polkit_agent_text_listener_new (NULL, &local_error);