From 6cd99b04d438b1de9b25c7bd928e541609904db3 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 12 Nov 2024 10:25:33 +0100 Subject: [PATCH] Camera: use an empty app id for host apps 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. --- src/camera.c | 5 ++++- tests/camera.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/camera.c b/src/camera.c index 63396433e..4224a0a7b 100644 --- a/src/camera.c +++ b/src/camera.c @@ -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) diff --git a/tests/camera.c b/tests/camera.c index dafa8f964..c6193cb40 100644 --- a/tests/camera.c +++ b/tests/camera.c @@ -27,7 +27,7 @@ set_camera_permissions (const char *permission) "devices", TRUE, "camera", - appid, + "", permissions, NULL, &error);