diff mbox series

[meta-multimedia] module-protocol-native: Fix socket activation

Message ID 20260309063956.1548385-1-mohammad.rafi.shaik@oss.qualcomm.com
State New
Headers show
Series [meta-multimedia] module-protocol-native: Fix socket activation | expand

Commit Message

Mohammad Rafi Shaik March 9, 2026, 6:39 a.m. UTC
From: Sairamreddy Bojja <sbojja@qti.qualcomm.com>

Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
the function that uses it is called more than once and it was not unset
when sd_listen_fds() was used.

Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c
Signed-off-by: Sairamreddy Bojja <sbojja@qti.qualcomm.com>
Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
---
 ...rotocol-native-Fix-socket-activation.patch | 86 +++++++++++++++++++
 .../pipewire/pipewire_1.6.0.bb                |  1 +
 2 files changed, 87 insertions(+)
 create mode 100644 meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch

Comments

Anuj Mittal March 9, 2026, 8:11 a.m. UTC | #1
Hi,

On Mon, Mar 9, 2026 at 2:56 PM Mohammad Rafi Shaik via
lists.openembedded.org
<mohammad.rafi.shaik=oss.qualcomm.com@lists.openembedded.org> wrote:
>
> From: Sairamreddy Bojja <sbojja@qti.qualcomm.com>
>
> Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
> the function that uses it is called more than once and it was not unset
> when sd_listen_fds() was used.

Please explain the change being proposed for meta-multimedia.

Change commit message to start with recipe-name:

>
> Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c
> Signed-off-by: Sairamreddy Bojja <sbojja@qti.qualcomm.com>
> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
> ---
>  ...rotocol-native-Fix-socket-activation.patch | 86 +++++++++++++++++++
>  .../pipewire/pipewire_1.6.0.bb                |  1 +
>  2 files changed, 87 insertions(+)
>  create mode 100644 meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
>
> diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
> new file mode 100644
> index 0000000000..c345067932
> --- /dev/null
> +++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
> @@ -0,0 +1,86 @@
> +From f4e174870eb8cbe60c922d3bf181f3eb2347523c Mon Sep 17 00:00:00 2001
> +From: Jonas Holmberg <jonashg@axis.com>
> +Date: Mon, 2 Mar 2026 10:28:26 +0100
> +Subject: [PATCH] module-protocol-native: Fix socket activation
> +
> +Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
> +the function that uses it is called more than once and it was not unset
> +when sd_listen_fds() was used.
> +
> +Fixes #5140
> +Upstream-Status: Backport
> +[https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c]
> +---
> + src/modules/module-protocol-native.c       |  2 +-
> + src/modules/module-protocol-pulse/server.c |  2 +-
> + src/modules/network-utils.h                | 14 +++++---------
> + 3 files changed, 7 insertions(+), 11 deletions(-)
> +
> +diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c
> +index 2be92a847..98a43829b 100644
> +--- a/src/modules/module-protocol-native.c
> ++++ b/src/modules/module-protocol-native.c
> +@@ -907,7 +907,7 @@ static int add_socket(struct pw_protocol *protocol, struct server *s, struct soc
> +       bool activated = false;
> +
> +       {
> +-              int i, n = listen_fd();
> ++              int i, n = listen_fds();
> +               for (i = 0; i < n; ++i) {
> +                       if (is_socket_unix(LISTEN_FDS_START + i, SOCK_STREAM,
> +                                               s->addr.sun_path) > 0) {
> +diff --git a/src/modules/module-protocol-pulse/server.c b/src/modules/module-protocol-pulse/server.c
> +index aeab710b0..637757dfd 100644
> +--- a/src/modules/module-protocol-pulse/server.c
> ++++ b/src/modules/module-protocol-pulse/server.c
> +@@ -576,7 +576,7 @@ static bool is_stale_socket(int fd, const struct sockaddr_un *addr_un)
> +
> + static int check_socket_activation(const char *path)
> + {
> +-      const int n = listen_fd();
> ++      const int n = listen_fds();
> +
> +       for (int i = 0; i < n; i++) {
> +               const int fd = LISTEN_FDS_START + i;
> +diff --git a/src/modules/network-utils.h b/src/modules/network-utils.h
> +index a89b7d3bd..6ff80dd7a 100644
> +--- a/src/modules/network-utils.h
> ++++ b/src/modules/network-utils.h
> +@@ -143,7 +143,7 @@ static inline bool pw_net_addr_is_any(struct sockaddr_storage *addr)
> +
> + /* Returns the number of file descriptors passed for socket activation.
> +  * Returns 0 if none, -1 on error. */
> +-static inline int listen_fd(void)
> ++static inline int listen_fds(void)
> + {
> +       uint32_t n;
> +       int i, flags;
> +@@ -161,8 +161,6 @@ static inline int listen_fd(void)
> +                       return -1;
> +       }
> +
> +-      unsetenv("LISTEN_FDS");
> +-
> +       return (int)n;
> + }
> +
> +@@ -192,12 +190,10 @@ static inline int is_socket_unix(int fd, int type, const char *path)
> +               if (addr.sun_family != AF_UNIX)
> +                       return 0;
> +               size_t length = strlen(path);
> +-              if (length > 0) {
> +-                      if (len < offsetof(struct sockaddr_un, sun_path) + length)
> +-                              return 0;
> +-                      if (memcmp(addr.sun_path, path, length) != 0)
> +-                              return 0;
> +-              }
> ++              if (len < offsetof(struct sockaddr_un, sun_path) + length + 1)
> ++                      return 0;
> ++              if (memcmp(addr.sun_path, path, length + 1) != 0)
> ++                      return 0;
> +       }
> +
> +       return 1;
> +--
> +2.34.1
> +
> diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
> index dea1a169d0..742720ef60 100644
> --- a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
> +++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
> @@ -15,6 +15,7 @@ DEPENDS = "dbus ncurses"
>  SRCREV = "700cea78dbe7564131d51b21a7795e2567ee048a"
>  BRANCH = "${@oe.utils.trim_version('${PV}', 2)}"
>  SRC_URI = "git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=${BRANCH};protocol=https;tag=${PV}"
> +SRC_URI += "file://0001-module-protocol-native-Fix-socket-activation.patch"
>
>
>  inherit meson pkgconfig systemd gettext useradd
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#124955): https://lists.openembedded.org/g/openembedded-devel/message/124955
> Mute This Topic: https://lists.openembedded.org/mt/118217162/3616702
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [anuj.mittal@oss.qualcomm.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Mohammad Rafi Shaik March 9, 2026, 8:39 a.m. UTC | #2
On 3/9/2026 1:41 PM, Anuj Mittal wrote:
> Hi,
> 
> On Mon, Mar 9, 2026 at 2:56 PM Mohammad Rafi Shaik via
> lists.openembedded.org
> <mohammad.rafi.shaik=oss.qualcomm.com@lists.openembedded.org> wrote:
>>
>> From: Sairamreddy Bojja <sbojja@qti.qualcomm.com>
>>
>> Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
>> the function that uses it is called more than once and it was not unset
>> when sd_listen_fds() was used.
> 
> Please explain the change being proposed for meta-multimedia.
> 

This backport is required to ensure correct PipeWire operation with 
systemd socket activation in Yocto images using meta-multimedia. No 
Yocto-specific behavior is introduced.

> Change commit message to start with recipe-name:
> 

ACK,

will update the commit message as suggested.

Best Regards,
Rafi

>>
>> Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c
>> Signed-off-by: Sairamreddy Bojja <sbojja@qti.qualcomm.com>
>> Signed-off-by: Mohammad Rafi Shaik <mohammad.rafi.shaik@oss.qualcomm.com>
>> ---
>>   ...rotocol-native-Fix-socket-activation.patch | 86 +++++++++++++++++++
>>   .../pipewire/pipewire_1.6.0.bb                |  1 +
>>   2 files changed, 87 insertions(+)
>>   create mode 100644 meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
>>
>> diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
>> new file mode 100644
>> index 0000000000..c345067932
>> --- /dev/null
>> +++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
>> @@ -0,0 +1,86 @@
>> +From f4e174870eb8cbe60c922d3bf181f3eb2347523c Mon Sep 17 00:00:00 2001
>> +From: Jonas Holmberg <jonashg@axis.com>
>> +Date: Mon, 2 Mar 2026 10:28:26 +0100
>> +Subject: [PATCH] module-protocol-native: Fix socket activation
>> +
>> +Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
>> +the function that uses it is called more than once and it was not unset
>> +when sd_listen_fds() was used.
>> +
>> +Fixes #5140
>> +Upstream-Status: Backport
>> +[https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c]
>> +---
>> + src/modules/module-protocol-native.c       |  2 +-
>> + src/modules/module-protocol-pulse/server.c |  2 +-
>> + src/modules/network-utils.h                | 14 +++++---------
>> + 3 files changed, 7 insertions(+), 11 deletions(-)
>> +
>> +diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c
>> +index 2be92a847..98a43829b 100644
>> +--- a/src/modules/module-protocol-native.c
>> ++++ b/src/modules/module-protocol-native.c
>> +@@ -907,7 +907,7 @@ static int add_socket(struct pw_protocol *protocol, struct server *s, struct soc
>> +       bool activated = false;
>> +
>> +       {
>> +-              int i, n = listen_fd();
>> ++              int i, n = listen_fds();
>> +               for (i = 0; i < n; ++i) {
>> +                       if (is_socket_unix(LISTEN_FDS_START + i, SOCK_STREAM,
>> +                                               s->addr.sun_path) > 0) {
>> +diff --git a/src/modules/module-protocol-pulse/server.c b/src/modules/module-protocol-pulse/server.c
>> +index aeab710b0..637757dfd 100644
>> +--- a/src/modules/module-protocol-pulse/server.c
>> ++++ b/src/modules/module-protocol-pulse/server.c
>> +@@ -576,7 +576,7 @@ static bool is_stale_socket(int fd, const struct sockaddr_un *addr_un)
>> +
>> + static int check_socket_activation(const char *path)
>> + {
>> +-      const int n = listen_fd();
>> ++      const int n = listen_fds();
>> +
>> +       for (int i = 0; i < n; i++) {
>> +               const int fd = LISTEN_FDS_START + i;
>> +diff --git a/src/modules/network-utils.h b/src/modules/network-utils.h
>> +index a89b7d3bd..6ff80dd7a 100644
>> +--- a/src/modules/network-utils.h
>> ++++ b/src/modules/network-utils.h
>> +@@ -143,7 +143,7 @@ static inline bool pw_net_addr_is_any(struct sockaddr_storage *addr)
>> +
>> + /* Returns the number of file descriptors passed for socket activation.
>> +  * Returns 0 if none, -1 on error. */
>> +-static inline int listen_fd(void)
>> ++static inline int listen_fds(void)
>> + {
>> +       uint32_t n;
>> +       int i, flags;
>> +@@ -161,8 +161,6 @@ static inline int listen_fd(void)
>> +                       return -1;
>> +       }
>> +
>> +-      unsetenv("LISTEN_FDS");
>> +-
>> +       return (int)n;
>> + }
>> +
>> +@@ -192,12 +190,10 @@ static inline int is_socket_unix(int fd, int type, const char *path)
>> +               if (addr.sun_family != AF_UNIX)
>> +                       return 0;
>> +               size_t length = strlen(path);
>> +-              if (length > 0) {
>> +-                      if (len < offsetof(struct sockaddr_un, sun_path) + length)
>> +-                              return 0;
>> +-                      if (memcmp(addr.sun_path, path, length) != 0)
>> +-                              return 0;
>> +-              }
>> ++              if (len < offsetof(struct sockaddr_un, sun_path) + length + 1)
>> ++                      return 0;
>> ++              if (memcmp(addr.sun_path, path, length + 1) != 0)
>> ++                      return 0;
>> +       }
>> +
>> +       return 1;
>> +--
>> +2.34.1
>> +
>> diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
>> index dea1a169d0..742720ef60 100644
>> --- a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
>> +++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
>> @@ -15,6 +15,7 @@ DEPENDS = "dbus ncurses"
>>   SRCREV = "700cea78dbe7564131d51b21a7795e2567ee048a"
>>   BRANCH = "${@oe.utils.trim_version('${PV}', 2)}"
>>   SRC_URI = "git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=${BRANCH};protocol=https;tag=${PV}"
>> +SRC_URI += "file://0001-module-protocol-native-Fix-socket-activation.patch"
>>
>>
>>   inherit meson pkgconfig systemd gettext useradd
>> --
>> 2.34.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#124955): https://lists.openembedded.org/g/openembedded-devel/message/124955
>> Mute This Topic: https://lists.openembedded.org/mt/118217162/3616702
>> Group Owner: openembedded-devel+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [anuj.mittal@oss.qualcomm.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
diff mbox series

Patch

diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
new file mode 100644
index 0000000000..c345067932
--- /dev/null
+++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire/0001-module-protocol-native-Fix-socket-activation.patch
@@ -0,0 +1,86 @@ 
+From f4e174870eb8cbe60c922d3bf181f3eb2347523c Mon Sep 17 00:00:00 2001
+From: Jonas Holmberg <jonashg@axis.com>
+Date: Mon, 2 Mar 2026 10:28:26 +0100
+Subject: [PATCH] module-protocol-native: Fix socket activation
+
+Fix path comparison in is_socket_unix() and don't unset LISTEN_FDS since
+the function that uses it is called more than once and it was not unset
+when sd_listen_fds() was used.
+
+Fixes #5140
+Upstream-Status: Backport
+[https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/f4e174870eb8cbe60c922d3bf181f3eb2347523c]
+---
+ src/modules/module-protocol-native.c       |  2 +-
+ src/modules/module-protocol-pulse/server.c |  2 +-
+ src/modules/network-utils.h                | 14 +++++---------
+ 3 files changed, 7 insertions(+), 11 deletions(-)
+
+diff --git a/src/modules/module-protocol-native.c b/src/modules/module-protocol-native.c
+index 2be92a847..98a43829b 100644
+--- a/src/modules/module-protocol-native.c
++++ b/src/modules/module-protocol-native.c
+@@ -907,7 +907,7 @@ static int add_socket(struct pw_protocol *protocol, struct server *s, struct soc
+ 	bool activated = false;
+ 
+ 	{
+-		int i, n = listen_fd();
++		int i, n = listen_fds();
+ 		for (i = 0; i < n; ++i) {
+ 			if (is_socket_unix(LISTEN_FDS_START + i, SOCK_STREAM,
+ 						s->addr.sun_path) > 0) {
+diff --git a/src/modules/module-protocol-pulse/server.c b/src/modules/module-protocol-pulse/server.c
+index aeab710b0..637757dfd 100644
+--- a/src/modules/module-protocol-pulse/server.c
++++ b/src/modules/module-protocol-pulse/server.c
+@@ -576,7 +576,7 @@ static bool is_stale_socket(int fd, const struct sockaddr_un *addr_un)
+ 
+ static int check_socket_activation(const char *path)
+ {
+-	const int n = listen_fd();
++	const int n = listen_fds();
+ 
+ 	for (int i = 0; i < n; i++) {
+ 		const int fd = LISTEN_FDS_START + i;
+diff --git a/src/modules/network-utils.h b/src/modules/network-utils.h
+index a89b7d3bd..6ff80dd7a 100644
+--- a/src/modules/network-utils.h
++++ b/src/modules/network-utils.h
+@@ -143,7 +143,7 @@ static inline bool pw_net_addr_is_any(struct sockaddr_storage *addr)
+ 
+ /* Returns the number of file descriptors passed for socket activation.
+  * Returns 0 if none, -1 on error. */
+-static inline int listen_fd(void)
++static inline int listen_fds(void)
+ {
+ 	uint32_t n;
+ 	int i, flags;
+@@ -161,8 +161,6 @@ static inline int listen_fd(void)
+ 			return -1;
+ 	}
+ 
+-	unsetenv("LISTEN_FDS");
+-
+ 	return (int)n;
+ }
+ 
+@@ -192,12 +190,10 @@ static inline int is_socket_unix(int fd, int type, const char *path)
+ 		if (addr.sun_family != AF_UNIX)
+ 			return 0;
+ 		size_t length = strlen(path);
+-		if (length > 0) {
+-			if (len < offsetof(struct sockaddr_un, sun_path) + length)
+-				return 0;
+-			if (memcmp(addr.sun_path, path, length) != 0)
+-				return 0;
+-		}
++		if (len < offsetof(struct sockaddr_un, sun_path) + length + 1)
++			return 0;
++		if (memcmp(addr.sun_path, path, length + 1) != 0)
++			return 0;
+ 	}
+ 
+ 	return 1;
+-- 
+2.34.1
+
diff --git a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
index dea1a169d0..742720ef60 100644
--- a/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
+++ b/meta-multimedia/recipes-multimedia/pipewire/pipewire_1.6.0.bb
@@ -15,6 +15,7 @@  DEPENDS = "dbus ncurses"
 SRCREV = "700cea78dbe7564131d51b21a7795e2567ee048a"
 BRANCH = "${@oe.utils.trim_version('${PV}', 2)}"
 SRC_URI = "git://gitlab.freedesktop.org/pipewire/pipewire.git;branch=${BRANCH};protocol=https;tag=${PV}"
+SRC_URI += "file://0001-module-protocol-native-Fix-socket-activation.patch"
 
 
 inherit meson pkgconfig systemd gettext useradd