mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
permissions: use current_client for security checks
Don't pass around the client object but keep track of the current client in the core object. This way we don't need to add a client argument to functions and can check security when needed.
This commit is contained in:
parent
ab099d09dd
commit
ff17fb68b5
10 changed files with 32 additions and 21 deletions
|
|
@ -168,11 +168,14 @@ process_messages(struct client_data *data)
|
|||
{
|
||||
struct pw_protocol_native_connection *conn = data->connection;
|
||||
struct pw_client *client = data->client;
|
||||
struct pw_core *core = client->core;
|
||||
uint8_t opcode;
|
||||
uint32_t id;
|
||||
uint32_t size;
|
||||
void *message;
|
||||
|
||||
core->current_client = client;
|
||||
|
||||
while (pw_protocol_native_connection_get_next(conn, &opcode, &id, &message, &size)) {
|
||||
struct pw_resource *resource;
|
||||
const struct pw_protocol_native_demarshal *demarshal;
|
||||
|
|
@ -222,18 +225,20 @@ process_messages(struct client_data *data)
|
|||
if (demarshal[opcode].func(resource, message, size) < 0)
|
||||
goto invalid_message;
|
||||
}
|
||||
done:
|
||||
core->current_client = NULL;
|
||||
return;
|
||||
|
||||
invalid_method:
|
||||
pw_log_error("protocol-native %p: invalid method %u on resource %u",
|
||||
client->protocol, opcode, id);
|
||||
pw_client_destroy(client);
|
||||
return;
|
||||
goto done;
|
||||
invalid_message:
|
||||
pw_log_error("protocol-native %p: invalid message received %u %u",
|
||||
client->protocol, id, opcode);
|
||||
pw_client_destroy(client);
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue