media-session: give more permissions to Manager flatpaks

If a flatpak app has the Manager media.category set, assign more
permissions to it for now. We should later check with the
permission store if this is really allowed.
This commit is contained in:
Wim Taymans 2021-02-04 11:53:03 +01:00
parent d85862af71
commit 1581b6cfce
2 changed files with 15 additions and 5 deletions

View file

@ -67,16 +67,26 @@ static void object_update(void *data)
if (client->obj->obj.avail & SM_CLIENT_CHANGE_MASK_INFO &&
!client->active) {
struct pw_permission permissions[1];
uint32_t perms;
if (client->obj->info == NULL || client->obj->info->props == NULL ||
(str = spa_dict_lookup(client->obj->info->props, PW_KEY_ACCESS)) == NULL ||
strcmp(str, "flatpak") != 0)
return;
/* limited access for now */
pw_log_info(NAME" %p: flatpak client %d granted RX permissions"
, impl, client->id);
permissions[0] = PW_PERMISSION_INIT(PW_ID_ANY, PW_PERM_R | PW_PERM_X);
if ((str = spa_dict_lookup(client->obj->info->props, PW_KEY_MEDIA_CATEGORY)) != NULL &&
(strcmp(str, "Manager") == 0)) {
/* FIXME, use permission store to check if this app is allowed to
* be a manager app */
perms = PW_PERM_ALL;
} else {
/* limited access for everything else */
perms = PW_PERM_R | PW_PERM_X;
}
pw_log_info(NAME" %p: flatpak client %d granted 0x%08x permissions"
, impl, client->id, perms);
permissions[0] = PW_PERMISSION_INIT(PW_ID_ANY, perms);
pw_client_update_permissions(client->obj->obj.proxy,
1, permissions);
client->active = true;

View file

@ -246,7 +246,7 @@ extern "C" {
#define PW_KEY_MEDIA_TYPE "media.type" /**< Media type, one of
* Audio, Video, Midi */
#define PW_KEY_MEDIA_CATEGORY "media.category" /**< Media Category:
* Playback, Capture, Duplex, Monitor */
* Playback, Capture, Duplex, Monitor, Manager */
#define PW_KEY_MEDIA_ROLE "media.role" /**< Role: Movie, Music, Camera,
* Screen, Communication, Game,
* Notification, DSP, Production,