From f4eefa7e0400d210eaee3b04c218a81ca2bf6bca Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 26 Nov 2015 19:14:50 +0100 Subject: [PATCH] Create xdg-app-info file in user runtime dir with effective state This shows the name of the app, the runtime in use and the permissions that the app has. This is useful for a client to know if e.g. it needs to use a portal of some sort. --- app/xdg-app-builtins-run.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/xdg-app-builtins-run.c b/app/xdg-app-builtins-run.c index f01277dc..3f18d7dd 100644 --- a/app/xdg-app-builtins-run.c +++ b/app/xdg-app-builtins-run.c @@ -176,6 +176,33 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError ** xdg_app_context_merge (app_context, arg_context); + { + g_autofree char *tmp_path = NULL; + g_autofree char *path = NULL; + int fd; + + fd = g_file_open_tmp ("xdg-app-context-XXXXXX", &tmp_path, NULL); + if (fd >= 0) + { + g_autoptr(GKeyFile) keyfile = NULL; + + close (fd); + + keyfile = g_key_file_new (); + + g_key_file_set_string (keyfile, "Application", "name", app); + g_key_file_set_string (keyfile, "Application", "runtime", runtime_ref); + + xdg_app_context_save_metadata (app_context, keyfile); + + if (!g_key_file_save_to_file (keyfile, tmp_path, error)) + return FALSE; + + g_ptr_array_add (argv_array, g_strdup ("-M")); + g_ptr_array_add (argv_array, g_strdup_printf ("/run/user/%d/xdg-app-info=%s", getuid(), tmp_path)); + } + } + if (!xdg_app_run_add_extension_args (argv_array, runtime_metakey, runtime_ref, cancellable, error)) return FALSE;