mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-15 07:00:05 -05:00
link: check permissions
When creating a link between two nodes, check if the owner of a node (when it is a client) can see the other node.
This commit is contained in:
parent
07ff967285
commit
23d0b9e5e2
1 changed files with 28 additions and 0 deletions
|
|
@ -1171,6 +1171,28 @@ static void try_unlink_controls(struct impl *impl, struct pw_port *output, struc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
check_permission(struct pw_core *core,
|
||||||
|
struct pw_port *output,
|
||||||
|
struct pw_port *input,
|
||||||
|
struct pw_properties *properties)
|
||||||
|
{
|
||||||
|
struct pw_node *input_node, *output_node;
|
||||||
|
struct pw_client *client;
|
||||||
|
|
||||||
|
input_node = input->node;
|
||||||
|
output_node = output->node;
|
||||||
|
|
||||||
|
if ((client = output_node->global->owner) != NULL &&
|
||||||
|
!PW_PERM_IS_R(pw_global_get_permissions(input_node->global, client)))
|
||||||
|
return -EPERM;
|
||||||
|
|
||||||
|
if ((client = input_node->global->owner) != NULL &&
|
||||||
|
!PW_PERM_IS_R(pw_global_get_permissions(output_node->global, client)))
|
||||||
|
return -EPERM;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
struct pw_link *pw_link_new(struct pw_core *core,
|
struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
struct pw_port *output,
|
struct pw_port *output,
|
||||||
|
|
@ -1195,6 +1217,9 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
if (pw_link_find(output, input))
|
if (pw_link_find(output, input))
|
||||||
goto link_exists;
|
goto link_exists;
|
||||||
|
|
||||||
|
if (check_permission(core, output, input, properties) < 0)
|
||||||
|
goto link_not_allowed;
|
||||||
|
|
||||||
input_node = input->node;
|
input_node = input->node;
|
||||||
output_node = output->node;
|
output_node = output->node;
|
||||||
|
|
||||||
|
|
@ -1291,6 +1316,9 @@ struct pw_link *pw_link_new(struct pw_core *core,
|
||||||
link_exists:
|
link_exists:
|
||||||
asprintf(error, "link already exists");
|
asprintf(error, "link already exists");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
link_not_allowed:
|
||||||
|
asprintf(error, "link not allowed");
|
||||||
|
return NULL;
|
||||||
no_mem:
|
no_mem:
|
||||||
asprintf(error, "no memory");
|
asprintf(error, "no memory");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue