Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

camera: fix permission check in OpenPipeWireRemote #1572

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ query_permission_sync (XdpRequest *request)
const char *app_id;
gboolean allowed;

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");

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 Expand Up @@ -190,6 +186,16 @@ handle_access_camera_in_thread_func (GTask *task,
}
}

static const char *
app_id_from_app_info (XdpAppInfo *app_info)
{
/* Automatically grant camera access to unsandboxed apps. */
if (xdp_app_info_is_host (app_info))
return "";

return xdp_app_info_get_id (app_info);
}

static gboolean
handle_access_camera (XdpDbusCamera *object,
GDBusMethodInvocation *invocation,
Expand All @@ -211,9 +217,7 @@ handle_access_camera (XdpDbusCamera *object,

REQUEST_AUTOLOCK (request);

app_id = xdp_app_info_get_id (request->app_info);


app_id = app_id_from_app_info (request->app_info);
g_object_set_data_full (G_OBJECT (request), "app-id", g_strdup (app_id), g_free);

xdp_request_export (request, g_dbus_method_invocation_get_connection (invocation));
Expand Down Expand Up @@ -288,7 +292,7 @@ handle_open_pipewire_remote (XdpDbusCamera *object,
}

app_info = xdp_invocation_lookup_app_info_sync (invocation, NULL, &error);
app_id = xdp_app_info_get_id (app_info);
app_id = app_id_from_app_info (app_info);
permission = xdp_get_permission_sync (app_id, PERMISSION_TABLE, PERMISSION_DEVICE_CAMERA);
if (permission != XDP_PERMISSION_YES)
{
Expand Down
Loading