summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2019-06-28 12:18:10 +0200
committerWim Taymans <wtaymans@redhat.com>2019-06-28 12:18:10 +0200
commit5833b7b2a7a1b9f0a1eb4c2f3d74a7c7e2e51ed8 (patch)
tree3b4695be2048fcdb4707223c2bdbed54f0604d6c /src
parent57879cc80166149bb20818267c8a90d3aba2b8ff (diff)
client: remove recursive permissions checks
Don't let permissions of an object influence the child permissions, this is not so easy to manage and needs some more thought. The result is now that it's possible to see a reference to a (parent) id that is not visible, but that's ok.
Diffstat (limited to 'src')
-rw-r--r--src/pipewire/client.c3
-rw-r--r--src/pipewire/global.c45
2 files changed, 14 insertions, 34 deletions
diff --git a/src/pipewire/client.c b/src/pipewire/client.c
index aad21846..2011eee3 100644
--- a/src/pipewire/client.c
+++ b/src/pipewire/client.c
@@ -102,8 +102,7 @@ static uint32_t
client_permission_func(struct pw_global *global,
struct pw_client *client, void *data)
{
- struct pw_permission *p;
- p = find_permission(client, global->id);
+ struct pw_permission *p = find_permission(client, global->id);
return p->permissions;
}
diff --git a/src/pipewire/global.c b/src/pipewire/global.c
index 44bfbf6d..fc9c8a51 100644
--- a/src/pipewire/global.c
+++ b/src/pipewire/global.c
@@ -41,29 +41,13 @@ struct impl {
};
/** \endcond */
-
-static inline uint32_t get_permissions(struct pw_global *global, struct pw_client *client, bool recurse)
+SPA_EXPORT
+uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *client)
{
- uint32_t perms;
-
if (client->permission_func == NULL)
return PW_PERM_RWX;
- perms = client->permission_func(global, client, client->permission_data);
-
- if (recurse) {
- while (global->parent != NULL && global != global->parent) {
- global = global->parent;
- perms &= client->permission_func(global, client, client->permission_data);
- }
- }
- return perms;
-}
-
-SPA_EXPORT
-uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_client *client)
-{
- return get_permissions(global, client, true);
+ return client->permission_func(global, client, client->permission_data);
}
/** Create a new global
@@ -329,29 +313,25 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_client *cli
{
struct pw_core *core = global->core;
struct pw_resource *resource, *t;
- struct pw_global *g;
- uint32_t perms;
+ bool do_hide, do_show;
- pw_global_emit_permissions_changed(global, client, old_permissions, new_permissions);
+ do_hide = PW_PERM_IS_R(old_permissions) && !PW_PERM_IS_R(new_permissions);
+ do_show = !PW_PERM_IS_R(old_permissions) && PW_PERM_IS_R(new_permissions);
- spa_list_for_each(g, &global->child_list, child_link) {
- if (g == global)
- continue;
- perms = get_permissions(g, client, false);
- pw_global_update_permissions(g, client,
- perms & old_permissions,
- perms & new_permissions);
- }
+ pw_log_debug("client %p: permissions changed %d %08x -> %08x", client,
+ global->id, old_permissions, new_permissions);
+
+ pw_global_emit_permissions_changed(global, client, old_permissions, new_permissions);
spa_list_for_each(resource, &core->registry_resource_list, link) {
if (resource->client != client)
continue;
- if (PW_PERM_IS_R(old_permissions) && !PW_PERM_IS_R(new_permissions)) {
+ if (do_hide) {
pw_log_debug("client %p: hide global %d", client, global->id);
pw_registry_resource_global_remove(resource, global->id);
}
- else if (!PW_PERM_IS_R(old_permissions) && PW_PERM_IS_R(new_permissions)) {
+ else if (do_show) {
pw_log_debug("client %p: show global %d", client, global->id);
pw_registry_resource_global(resource,
global->id,
@@ -363,6 +343,7 @@ int pw_global_update_permissions(struct pw_global *global, struct pw_client *cli
&global->properties->dict : NULL);
}
}
+
spa_list_for_each_safe(resource, t, &global->resource_list, link) {
if (resource->client != client)
continue;