From bb120a070f9d0167c2e584e1f4eb00b5b0b7d5f6 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 7 Oct 2023 12:37:10 +0300 Subject: [PATCH] pipewire: add PW_KEY_SEC_SOCKET and set it in protocol Add client key PW_KEY_SEC_SOCKET that indicates which socket the client used to connect to the server. This can be used by other modules as an access control mechanism. --- src/modules/module-protocol-native.c | 2 ++ src/pipewire/impl-client.c | 1 + src/pipewire/keys.h | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c index 2c49b490f..4ebb9bb7d 100644 --- a/src/modules/module-protocol-native.c +++ b/src/modules/module-protocol-native.c @@ -578,6 +578,8 @@ static struct client_data *client_new(struct server *s, int fd) if (props == NULL) goto exit; + pw_properties_set(props, PW_KEY_SEC_SOCKET, s->socket_info.name); + #if defined(__linux__) len = sizeof(ucred); if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) { diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 53e7b7c82..ae5a1b1f4 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -524,6 +524,7 @@ int pw_impl_client_register(struct pw_impl_client *client, PW_KEY_SEC_UID, PW_KEY_SEC_GID, PW_KEY_SEC_LABEL, + PW_KEY_SEC_SOCKET, NULL }; diff --git a/src/pipewire/keys.h b/src/pipewire/keys.h index a1df91be1..630e416b4 100644 --- a/src/pipewire/keys.h +++ b/src/pipewire/keys.h @@ -38,6 +38,8 @@ extern "C" { #define PW_KEY_SEC_GID "pipewire.sec.gid" /**< client gid, set by protocol*/ #define PW_KEY_SEC_LABEL "pipewire.sec.label" /**< client security label, set by protocol*/ +#define PW_KEY_SEC_SOCKET "pipewire.sec.socket" /**< client socket name, set by protocol */ + #define PW_KEY_LIBRARY_NAME_SYSTEM "library.name.system" /**< name of the system library to use */ #define PW_KEY_LIBRARY_NAME_LOOP "library.name.loop" /**< name of the loop library to use */ #define PW_KEY_LIBRARY_NAME_DBUS "library.name.dbus" /**< name of the dbus library to use */