Use more fine grained access control

Make it possible to add more permissions to an object than just visible
or not. Pass these permissions to the client. This way we can make a
difference between being able to see and read, modify or query an
object. More permissions can be added later when needed. Because the
permissions is set on the resource by the access control module, the
implementations can check if the right permission is set before doing
anything.
This commit is contained in:
Wim Taymans 2017-08-01 17:09:57 +02:00
parent c59bc457d4
commit 4f08dbcd24
14 changed files with 110 additions and 59 deletions

View file

@ -529,7 +529,7 @@ static bool core_demarshal_update_types_server(void *object, void *data, size_t
return true;
}
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id,
static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_id, uint32_t permissions,
uint32_t type, uint32_t version)
{
struct pw_resource *resource = object;
@ -541,6 +541,7 @@ static void registry_marshal_global(void *object, uint32_t id, uint32_t parent_i
spa_pod_builder_struct(b, &f,
SPA_POD_TYPE_INT, id,
SPA_POD_TYPE_INT, parent_id,
SPA_POD_TYPE_INT, permissions,
SPA_POD_TYPE_ID, type,
SPA_POD_TYPE_INT, version);
@ -827,18 +828,19 @@ static bool registry_demarshal_global(void *object, void *data, size_t size)
{
struct pw_proxy *proxy = object;
struct spa_pod_iter it;
uint32_t id, parent_id, type, version;
uint32_t id, parent_id, permissions, type, version;
if (!spa_pod_iter_struct(&it, data, size) ||
!pw_pod_remap_data(SPA_POD_TYPE_STRUCT, data, size, &proxy->remote->types) ||
!spa_pod_iter_get(&it,
SPA_POD_TYPE_INT, &id,
SPA_POD_TYPE_INT, &parent_id,
SPA_POD_TYPE_INT, &permissions,
SPA_POD_TYPE_ID, &type,
SPA_POD_TYPE_INT, &version, 0))
return false;
pw_proxy_notify(proxy, struct pw_registry_events, global, id, parent_id, type, version);
pw_proxy_notify(proxy, struct pw_registry_events, global, id, parent_id, permissions, type, version);
return true;
}