summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-05-06 14:22:38 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-05-29 17:57:39 -0400
commitd3b4f7c9f6be6894538fa7b172aad43b9031e983 (patch)
tree7ae61d3c316ae981f976379b4711df09ce336a68
parent60a1cc9facaa29414213066fddf8507575f6ff3f (diff)
downloadglib-d3b4f7c9f6be6894538fa7b172aad43b9031e983.tar.gz
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
-rw-r--r--gio/gdesktopappinfo.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index b2f38651c..e9fa038c3 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;
}