From 9532c8d333ea0121212a8dd162e537f1f4d68b15 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 11 Mar 2024 14:56:41 +0100 Subject: [PATCH] dir: Reload DBus daemon config to ensure services get picked up This is best effort. There is a 2s timeout and if something fails everything continues on. This is called from flatpak_dir_run_triggers because it gets called whenever we might have changes to the exported service files. Fixes #3342 Signed-off-by: Sebastian Wick --- common/flatpak-dir.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index d030399d..3a788469 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -7057,6 +7057,28 @@ out: return ret; } +static void +maybe_reload_dbus_config (GCancellable *cancellable) +{ + g_autoptr(GDBusConnection) session_bus = NULL; + + session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, NULL); + if (!session_bus) + return; + + g_dbus_connection_call_sync (session_bus, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + "ReloadConfig", + NULL, + NULL, + G_DBUS_CALL_FLAGS_NONE, + 2000, + cancellable, + NULL); +} + gboolean flatpak_dir_run_triggers (FlatpakDir *self, GCancellable *cancellable, @@ -7069,6 +7091,8 @@ flatpak_dir_run_triggers (FlatpakDir *self, GError *temp_error = NULL; const char *triggerspath; + maybe_reload_dbus_config (cancellable); + if (flatpak_dir_use_system_helper (self, NULL)) { const char *installation = flatpak_dir_get_id (self);