Skip to content

Commit

Permalink
Camera: use an empty app id for host apps
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. Same will happen if the app id resolves to an app where
our app was started from. This happens for example when you start apps
in GNOME using Alt + F2, where we get invalid app id from cgroups and
since it doesn't find opened application window for this app, it will
automatically reject the request. Using an empty id fixes this problem.
  • Loading branch information
grulja authored and jadahl committed Dec 3, 2024
1 parent 6b684ea commit 6cd99b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ query_permission_sync (XdpRequest *request)
const char *app_id;
gboolean allowed;

app_id = (const char *)g_object_get_data (G_OBJECT (request), "app-id");
if (xdp_app_info_is_host (request->app_info))
app_id = "";
else
app_id = (const char *)g_object_get_data (G_OBJECT (request), "app-id");

permission = xdp_get_permission_sync (app_id, PERMISSION_TABLE, PERMISSION_DEVICE_CAMERA);
if (permission == XDP_PERMISSION_ASK || permission == XDP_PERMISSION_UNSET)
Expand Down
2 changes: 1 addition & 1 deletion tests/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set_camera_permissions (const char *permission)
"devices",
TRUE,
"camera",
appid,
"",
permissions,
NULL,
&error);
Expand Down

0 comments on commit 6cd99b0

Please sign in to comment.