Skip to content

Commit

Permalink
Camera: use an empty app id in access dialog in case of empty app info
Browse files Browse the repository at this point in the history
Sending an app id that doesn't resolve to valid app info (e.g. a desktop
file is not found) will automatically reject camera request, because the
backend is not able to verify whether the app (based on app id) runs in
the background. This happens for example when you start Firefox in GNOME
using Alt + F2 shortcut, where we get firefox" as app id from cgroups
and since it doesn't find opened application window for "firefox", it
automatically rejects the request. Using an empty id fixes this problem.
  • Loading branch information
grulja committed Nov 12, 2024
1 parent cb02780 commit 4da5500
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ query_permission_sync (Request *request)
{
Permission permission;
const char *app_id;
const char *permission_query_app_id;
gboolean allowed;

app_id = (const char *)g_object_get_data (G_OBJECT (request), "app-id");
permission_query_app_id = app_id;

permission = get_permission_sync (app_id, PERMISSION_TABLE, PERMISSION_DEVICE_CAMERA);
if (permission == PERMISSION_ASK || permission == PERMISSION_UNSET)
Expand Down Expand Up @@ -110,6 +112,8 @@ query_permission_sync (Request *request)
{
title = g_strdup (_("Allow app to Use the Camera?"));
body = g_strdup (_("An app wants to access camera devices."));
if (xdp_app_info_is_host (request->app_info))
permission_query_app_id = "";
}

impl_request = xdp_dbus_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (access_impl)),
Expand All @@ -126,7 +130,7 @@ query_permission_sync (Request *request)

if (!xdp_dbus_impl_access_call_access_dialog_sync (access_impl,
request->id,
app_id,
permission_query_app_id,
"",
title,
"",
Expand Down

0 comments on commit 4da5500

Please sign in to comment.