Skip to content

Commit 08007ff

Browse files
committed
Add support for Snaps to use portals
Validates that pids are owned by Snaps, allowing them to be mapped and passed through to a portal interface; Snaps were previously denied pid mapping. Initially created to allow GameMode to use the portal dbus from within a snap: FeralInteractive/gamemode#385
1 parent 753fba1 commit 08007ff

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/xdp-utils.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,29 @@ app_info_map_pids (XdpAppInfo *app_info,
21512151
g_return_val_if_fail (app_info != NULL, FALSE);
21522152
g_return_val_if_fail (pids != NULL, FALSE);
21532153

2154-
if (app_info->kind != XDP_APP_INFO_KIND_FLATPAK)
2154+
if (app_info->kind == XDP_APP_INFO_KIND_SNAP)
2155+
{
2156+
for (int i = 0; i < n_pids; i++)
2157+
{
2158+
g_autoptr(GError) local_error = NULL;
2159+
XdpAppInfo *info = xdp_get_app_info_from_pid (pids[i], &local_error);
2160+
if (!info)
2161+
{
2162+
g_propagate_prefixed_error (error, g_steal_pointer (&local_error),
2163+
"Can't find app for pid %i: ", pids[i]);
2164+
return FALSE;
2165+
}
2166+
2167+
if (info->kind != app_info->kind || g_strcmp0 (info->id, app_info->id) != 0)
2168+
{
2169+
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
2170+
"App info from pid does not match.");
2171+
return FALSE;
2172+
}
2173+
}
2174+
return TRUE;
2175+
}
2176+
else if (app_info->kind != XDP_APP_INFO_KIND_FLATPAK)
21552177
{
21562178
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
21572179
"Mapping pids is not supported.");

0 commit comments

Comments
 (0)