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 be7f2f4
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 @@ -83,6 +83,7 @@ query_permission_sync (Request *request)
permission = get_permission_sync (app_id, PERMISSION_TABLE, PERMISSION_DEVICE_CAMERA);
if (permission == PERMISSION_ASK || permission == PERMISSION_UNSET)
{
const char *permission_query_app_id = app_id;
g_auto(GVariantBuilder) opt_builder =
G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
g_autofree char *title = NULL;
Expand Down Expand Up @@ -110,6 +111,9 @@ 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 be7f2f4

Please sign in to comment.