From 77b432072f481a7d7edd94d307657b24d85cb350 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 22 Jun 2021 19:19:14 -0700 Subject: client-info: Check for `app-flatpak-` prefix in `get_xdg_id` Seems to be the correct prefix to check for as of https://github.com/flatpak/flatpak/commit/0c291cf1c9251a93a7bb893ee8e0371e588e05dc. (Which follows a change in https://github.com/flatpak/flatpak/commit/e481e3ea58e515e6e88673fac908be941c882569.) Seems to fix recognition of Flatpak apps on Pop!_OS 21.04 beta. Otherwise Flatpak apps are recognized as "system apps", and are always authorized without invoking the agent. --- src/gclue-client-info.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gclue-client-info.c b/src/gclue-client-info.c index d609b34..6a775bf 100644 --- a/src/gclue-client-info.c +++ b/src/gclue-client-info.c @@ -202,19 +202,24 @@ get_xdg_id (guint32 pid) g_autofree char *scope = NULL; const char *name; char *dash; + const char *prefix = NULL; if (!g_str_has_prefix (lines[i], "1:name=systemd:")) continue; scope = g_path_get_basename (unit); - if ((!g_str_has_prefix (scope, "xdg-app-") && - !g_str_has_prefix (scope, "flatpak-")) || - !g_str_has_suffix (scope, ".scope")) + + if (g_str_has_prefix (scope, "xdg-app-")) + prefix = "xdg-app-"; + else if (g_str_has_prefix (scope, "flatpak-")) + prefix = "flatpak-"; + else if (g_str_has_prefix (scope, "app-flatpak-")) + prefix = "app-flatpak-"; + + if (prefix == NULL || !g_str_has_suffix (scope, ".scope")) break; - /* strlen("flatpak-") == strlen("xdg-app-") - * so all is good here */ - name = scope + strlen("xdg-app-"); + name = scope + strlen(prefix); dash = strchr (name, '-'); if (dash == NULL) -- cgit v1.2.3