permissions: pass pw_permission struct around

Use a pw_permission struct to express permissions of object.
Improve client permissions, add/remove globals when permissions
are changed.
This commit is contained in:
Wim Taymans 2018-11-05 15:02:08 +01:00
parent f994b7eb70
commit eb0a561f8c
13 changed files with 282 additions and 320 deletions

View file

@ -509,21 +509,18 @@ static void on_state_changed(void *_data, enum pw_remote_state old, enum pw_remo
case PW_REMOTE_STATE_CONNECTED:
{
struct spa_dict_item items[5];
int i = 0;
struct pw_permission permissions[2];
/* set specific permissions on all existing objects without permissions */
items[i++] = SPA_DICT_ITEM_INIT(PW_CORE_PROXY_PERMISSIONS_EXISTING, "r--");
/* set default permission for new objects and objects without
* specific permissions */
items[i++] = SPA_DICT_ITEM_INIT(PW_CORE_PROXY_PERMISSIONS_DEFAULT, "---");
/* an example, set specific permissions on one object, this is the
* core object, we already have a binding to it that is not affected
* by the removal of X permissions, only future bindings. */
items[i++] = SPA_DICT_ITEM_INIT(PW_CORE_PROXY_PERMISSIONS_GLOBAL, "0:rw-");
* core object. */
permissions[0].id = 0;
permissions[0].permissions = PW_PERM_R | PW_PERM_X;
/* remove WX from all other objects */
permissions[1].id = SPA_ID_INVALID;
permissions[1].permissions = PW_PERM_R;
pw_core_proxy_permissions(pw_remote_get_core_proxy(data->remote),
&SPA_DICT_INIT(items, i));
2, permissions);
make_node(data);
break;

View file

@ -700,7 +700,7 @@ handle_client(struct impl *impl, uint32_t id, uint32_t parent_id,
{
struct pw_proxy *p;
struct client *client;
struct spa_dict_item items[2];
struct pw_permission perms[2];
const char *str;
p = pw_registry_proxy_bind(impl->registry_proxy,
@ -727,10 +727,9 @@ handle_client(struct impl *impl, uint32_t id, uint32_t parent_id,
return 0;
if (strcmp(str, "restricted") == 0) {
items[0].key = PW_CORE_PROXY_PERMISSIONS_DEFAULT;
items[0].value = "rwx";
perms[0] = PW_PERMISSION_INIT(-1, PW_PERM_RWX);
pw_client_proxy_update_permissions((struct pw_client_proxy*)p,
&SPA_DICT_INIT(items, 1));
1, perms);
}
return 0;
}