[glib] Make dbus activation sandbox-aware
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Make dbus activation sandbox-aware
- Date: Mon, 29 May 2017 21:58:47 +0000 (UTC)
commit d3b4f7c9f6be6894538fa7b172aad43b9031e983
Author: Matthias Clasen <mclasen redhat com>
Date: Sat May 6 14:22:38 2017 -0400
Make dbus activation sandbox-aware
When we call org.freedesktop.Application.Open to activate
an application and pass file uris, the application may not
be able to see the files due to a flatpak sandbox.
Flatpak puts the flatpak app-id in the X-Flatpak key in
desktop files that it exports, so we can easily recognize
applications that may be affected by this.
In this case, call the document portal to export the files
and pass the resulting uri's instead of the original ones.
https://bugzilla.gnome.org/show_bug.cgi?id=783130
gio/gdesktopappinfo.c | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index b2f3865..e9fa038 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -48,6 +48,10 @@
#include "gappinfoprivate.h"
#include "glocalfilemonitor.h"
+#ifdef G_OS_UNIX
+#include "gdocumentportal.h"
+#endif
+
/**
* SECTION:gdesktopappinfo
* @title: GDesktopAppInfo
@@ -2835,17 +2839,15 @@ g_desktop_app_info_make_platform_data (GDesktopAppInfo *info,
return g_variant_builder_end (&builder);
}
-static gboolean
-g_desktop_app_info_launch_uris_with_dbus (GDesktopAppInfo *info,
- GDBusConnection *session_bus,
- GList *uris,
- GAppLaunchContext *launch_context)
+static void
+launch_uris_with_dbus (GDesktopAppInfo *info,
+ GDBusConnection *session_bus,
+ GList *uris,
+ GAppLaunchContext *launch_context)
{
GVariantBuilder builder;
gchar *object_path;
- g_return_val_if_fail (info != NULL, FALSE);
-
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
if (uris)
@@ -2869,6 +2871,33 @@ g_desktop_app_info_launch_uris_with_dbus (GDesktopAppInfo *info,
uris ? "Open" : "Activate", g_variant_builder_end (&builder),
NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
g_free (object_path);
+}
+
+static gboolean
+g_desktop_app_info_launch_uris_with_dbus (GDesktopAppInfo *info,
+ GDBusConnection *session_bus,
+ GList *uris,
+ GAppLaunchContext *launch_context)
+{
+ GList *ruris = uris;
+ g_autofree char *app_id = NULL;
+
+ g_return_val_if_fail (info != NULL, FALSE);
+
+#ifdef G_OS_UNIX
+ app_id = g_desktop_app_info_get_string (info, "X-Flatpak");
+ if (app_id && *app_id)
+ {
+ ruris = g_document_portal_add_documents (uris, app_id, NULL);
+ if (ruris == NULL)
+ ruris = uris;
+ }
+#endif
+
+ launch_uris_with_dbus (info, session_bus, ruris, launch_context);
+
+ if (ruris != uris)
+ g_list_free_full (ruris, g_free);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]