module-access: make access.allowed an array

Reformat the config file a little
This commit is contained in:
Wim Taymans 2021-02-02 17:44:28 +01:00
parent ab4223601f
commit b8ef0fc5bb
2 changed files with 48 additions and 25 deletions

View file

@ -47,13 +47,13 @@ modules = {
# If ifexists is given, the module is ignoed when it is not found. # If ifexists is given, the module is ignoed when it is not found.
# If nofail is given, module initialization failures are ignored. # If nofail is given, module initialization failures are ignored.
# #
libpipewire-module-rtkit = { "#args" = { nice.level = -11 libpipewire-module-rtkit = {
rt.prio = 20 "#args" = { nice.level = -11
rt.time.soft = 200000 rt.prio = 20
rt.time.hard = 200000 rt.time.soft = 200000
} rt.time.hard = 200000 }
"flags" = "ifexists|nofail" "flags" = "ifexists|nofail"
} }
libpipewire-module-protocol-native = null libpipewire-module-protocol-native = null
libpipewire-module-profiler = null libpipewire-module-profiler = null
libpipewire-module-metadata = null libpipewire-module-metadata = null
@ -62,7 +62,18 @@ modules = {
libpipewire-module-client-node = null libpipewire-module-client-node = null
libpipewire-module-client-device = null libpipewire-module-client-device = null
libpipewire-module-portal = null libpipewire-module-portal = null
libpipewire-module-access = { "#args" = { access.allowed = @media_session_path@ access.force = flatpak" } } libpipewire-module-access = {
"#args" = {
# access.allowed to list an array of paths of allowed
# apps.
access.allowed = [
@media_session_path@
]
# anything not in the above lists gets assigned the
# access.force permission.
access.force = flatpak
}
}
libpipewire-module-adapter = null libpipewire-module-adapter = null
libpipewire-module-link-factory = null libpipewire-module-link-factory = null
libpipewire-module-session-manager = null libpipewire-module-session-manager = null
@ -84,11 +95,12 @@ objects = {
# A default dummy driver. This handles nodes marked with the "node.always-driver" # A default dummy driver. This handles nodes marked with the "node.always-driver"
# property when no other driver is currently active. JACK clients need this. # property when no other driver is currently active. JACK clients need this.
spa-node-factory = { args = { factory.name = support.node.driver spa-node-factory = {
node.name = Dummy-Driver args = { factory.name = support.node.driver
priority.driver = 8000 node.name = Dummy-Driver
} priority.driver = 8000
} }
}
} }
exec = { exec = {

View file

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#include <spa/utils/result.h> #include <spa/utils/result.h>
#include <spa/utils/json.h>
#include <pipewire/impl.h> #include <pipewire/impl.h>
#include <pipewire/private.h> #include <pipewire/private.h>
@ -62,29 +63,39 @@ struct impl {
static int check_cmdline(struct pw_impl_client *client, int pid, const char *str) static int check_cmdline(struct pw_impl_client *client, int pid, const char *str)
{ {
char path[2048]; char path[2048], key[1024];
ssize_t len; ssize_t len;
int fd; int fd, res;
struct spa_json it[2];
sprintf(path, "/proc/%u/cmdline", pid); sprintf(path, "/proc/%u/cmdline", pid);
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0) if (fd < 0) {
return -errno; res = -errno;
goto exit;
}
if ((len = read(fd, path, sizeof(path)-1)) < 0) { if ((len = read(fd, path, sizeof(path)-1)) < 0) {
close(fd); res = -errno;
return -errno; goto exit_close;
} }
path[len] = '\0'; path[len] = '\0';
if (strcmp(path, str) == 0) { spa_json_init(&it[0], str, strlen(str));
close(fd); if ((res = spa_json_enter_array(&it[0], &it[1])) <= 0)
return 1; goto exit_close;
}
while (spa_json_get_string(&it[1], key, sizeof(key)) > 0) {
if (strcmp(path, key) == 0) {
res = 1;
goto exit_close;
}
}
res = 0;
exit_close:
close(fd); close(fd);
return 0; exit:
return res;
} }
static int check_flatpak(struct pw_impl_client *client, int pid) static int check_flatpak(struct pw_impl_client *client, int pid)