mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
context: clean up permission check
This commit is contained in:
parent
2fe9c37f11
commit
0bb3de0dca
1 changed files with 11 additions and 6 deletions
|
|
@ -455,6 +455,14 @@ int pw_context_update_properties(struct pw_context *context, const struct spa_di
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool global_can_read(struct pw_context *context, struct pw_global *global)
|
||||||
|
{
|
||||||
|
if (context->current_client &&
|
||||||
|
!PW_PERM_IS_R(pw_global_get_permissions(global, context->current_client)))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
SPA_EXPORT
|
SPA_EXPORT
|
||||||
int pw_context_for_each_global(struct pw_context *context,
|
int pw_context_for_each_global(struct pw_context *context,
|
||||||
int (*callback) (void *data, struct pw_global *global),
|
int (*callback) (void *data, struct pw_global *global),
|
||||||
|
|
@ -464,8 +472,7 @@ int pw_context_for_each_global(struct pw_context *context,
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
spa_list_for_each_safe(g, t, &context->global_list, link) {
|
spa_list_for_each_safe(g, t, &context->global_list, link) {
|
||||||
if (context->current_client &&
|
if (!global_can_read(context, g))
|
||||||
!PW_PERM_IS_R(pw_global_get_permissions(g, context->current_client)))
|
|
||||||
continue;
|
continue;
|
||||||
if ((res = callback(data, g)) != 0)
|
if ((res = callback(data, g)) != 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -484,8 +491,7 @@ struct pw_global *pw_context_find_global(struct pw_context *context, uint32_t id
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->current_client &&
|
if (!global_can_read(context, global)) {
|
||||||
!PW_PERM_IS_R(pw_global_get_permissions(global, context->current_client))) {
|
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -528,8 +534,7 @@ struct pw_impl_port *pw_context_find_port(struct pw_context *context,
|
||||||
if (other_port->node == n)
|
if (other_port->node == n)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (context->current_client &&
|
if (!global_can_read(context, n->global))
|
||||||
!PW_PERM_IS_R(pw_global_get_permissions(n->global, context->current_client)))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pw_log_debug(NAME" %p: node id:%d", context, n->global->id);
|
pw_log_debug(NAME" %p: node id:%d", context, n->global->id);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue