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 <sebastian.wick@redhat.com>
This commit is contained in:
Sebastian Wick
2024-03-11 14:56:41 +01:00
committed by Simon McVittie
parent 56438bf542
commit 9532c8d333

View File

@@ -7057,6 +7057,28 @@ out:
return ret; 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 gboolean
flatpak_dir_run_triggers (FlatpakDir *self, flatpak_dir_run_triggers (FlatpakDir *self,
GCancellable *cancellable, GCancellable *cancellable,
@@ -7069,6 +7091,8 @@ flatpak_dir_run_triggers (FlatpakDir *self,
GError *temp_error = NULL; GError *temp_error = NULL;
const char *triggerspath; const char *triggerspath;
maybe_reload_dbus_config (cancellable);
if (flatpak_dir_use_system_helper (self, NULL)) if (flatpak_dir_use_system_helper (self, NULL))
{ {
const char *installation = flatpak_dir_get_id (self); const char *installation = flatpak_dir_get_id (self);