Skip to contentSkip to conversation

bluez5: install /var/lib/bluetooth directory

PATCH In review Yi Zhao 4 participants 9 messages Apr 8, 2022 – Apr 14, 2022 1 message not in the archive

lore
Share & tools
lore

Yi Zhao

author
#0 lore raw

PATCH 1/1 bluez5: install /var/lib/bluetooth directory

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
 meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +2 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
 	# Patch python tools to use Python 3; they should be source compatible, but
 	# still refer to Python 2 in the shebang
 	sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
+
+	install -d ${D}${localstatedir}/lib/bluetooth
 }
 
 PACKAGES =+ "${PN}-testtools ${PN}-obex ${PN}-noinst-tools"
Signature · 1 line
2.25.1
#1 lore raw

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 18 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++
  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644

meta/recipes-connectivity/bluez5/bluez5.inc do_install:append() { · line 106

Quoted 5 lines
meta/recipes-connectivity/bluez5/bluez5.inc +2 -0
@@ -102,6 +102,8 @@ do_install:append() {
  	# Patch python tools to use Python 3; they should be source compatible, but
  	# still refer to Python 2 in the shebang
  	sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
+
+	install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

author
#2 lore raw
Quoted 27 lines · Stefan Herbrechtsmeier

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 20 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++

  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
       # Patch python tools to use Python 3; they should be source compatible, but
       # still refer to Python 2 in the shebang
Quoted 3 lines

      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* +
+    install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

Quoted 1 line

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

Thanks Stefank, but the ReadWritePaths= is set by bluez:

https://github.com/bluez/bluez/commit/442d211b5f30f00d5ddd69b43385a03c1428ac45

//Yi

#3 lore raw

Am 08.04.2022 um 11:23 schrieb Yi Zhao:

Quoted 29 lines · Stefan Herbrechtsmeier
Quoted 27 lines

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 20 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++

  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
       # Patch python tools to use Python 3; they should be source compatible, but
       # still refer to Python 2 in the shebang
Quoted 3 lines

      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* +
+    install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

Quoted 7 lines
Quoted 2 lines

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

Thanks Stefank, but the ReadWritePaths= is set by bluez:

https://github.com/bluez/bluez/commit/442d211b5f30f00d5ddd69b43385a03c1428ac45

And who creates the directory before the patch?

The systemd solution to create a state directory is StateDirectory= (or tmpfiles.d for older versions of systemd). Systemd supports stateless system [1] and therefore every service must work with an empty /var/lib.

This patch hide a bug in bluez and the problem should be fixed in bluez.

[1] https://0pointer.net/blog/projects/stateless.html

author
#4 lore raw
Quoted 34 lines · Stefan Herbrechtsmeier

Am 08.04.2022 um 11:23 schrieb Yi Zhao:

Quoted 33 lines · Stefan Herbrechtsmeier
Quoted 29 lines

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 20 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++

  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
       # Patch python tools to use Python 3; they should be source compatible, but
       # still refer to Python 2 in the shebang
Quoted 3 lines

      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* +
+    install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

Quoted 6 lines
Quoted 4 lines

Thanks Stefank, but the ReadWritePaths= is set by bluez:

https://github.com/bluez/bluez/commit/442d211b5f30f00d5ddd69b43385a03c1428ac45

And who creates the directory before the patch?

There is no need this directory before the patch. The service can startup without this directory.

Quoted 2 lines

The systemd solution to create a state directory is StateDirectory= (or tmpfiles.d for older versions of systemd). Systemd supports stateless system [1] and therefore every service must work with an empty /var/lib.

I'll try adding StateDirecotry to service unit file to  see if this can solve the problem.  Thanks.

//Yi

Quoted 4 lines

This patch hide a bug in bluez and the problem should be fixed in bluez.

[1] https://0pointer.net/blog/projects/stateless.html

#5 lore raw

also had this issue and found out, that the bluetooth service did come up, once bluetooth was enabled

My fix was to edit like this

ReadWritePaths=:/var/lib/bluetooth

The colon ensures that the service won't fail if the directory doesn't exist

Am 08.04.22 um 13:01 schrieb Yi Zhao:

Quoted 68 lines · Stefan Herbrechtsmeier
Quoted 34 lines

Am 08.04.2022 um 11:23 schrieb Yi Zhao:

Quoted 33 lines · Stefan Herbrechtsmeier
Quoted 29 lines

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 20 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++

  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
       # Patch python tools to use Python 3; they should be source compatible, but
       # still refer to Python 2 in the shebang
Quoted 3 lines

      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* +
+    install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

Quoted 6 lines
Quoted 4 lines

Thanks Stefank, but the ReadWritePaths= is set by bluez:

https://github.com/bluez/bluez/commit/442d211b5f30f00d5ddd69b43385a03c1428ac45

And who creates the directory before the patch?

There is no need this directory before the patch. The service can startup without this directory.

Quoted 2 lines

The systemd solution to create a state directory is StateDirectory= (or tmpfiles.d for older versions of systemd). Systemd supports stateless system [1] and therefore every service must work with an empty /var/lib.

I'll try adding StateDirecotry to service unit file to  see if this can solve the problem.  Thanks.

//Yi

Quoted 4 lines

This patch hide a bug in bluez and the problem should be fixed in bluez.

[1] https://0pointer.net/blog/projects/stateless.html

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#164159): https://lists.openembedded.org/g/openembedded-core/message/164159
Mute This Topic: https://lists.openembedded.org/mt/90331367/3618223
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

Am 08.04.2022 um 22:03 schrieb Markus Volk via lists.openembedded.org:

Quoted 7 lines

also had this issue and found out, that the bluetooth service did come up, once bluetooth was enabled

My fix was to edit like this

ReadWritePaths=:/var/lib/bluetooth

The colon ensures that the service won't fail if the directory doesn't exist

Regarding the documentation the ReadOnlyPaths and ReadWritePaths makes not sense because ProtectSystem=full mounts /usr, boot loader and /etc directories read-only.

Have somebody report the problem to the bluez project?

Regards
Stefan

Quoted 75 lines

Am 08.04.22 um 13:01 schrieb Yi Zhao:

Quoted 47 lines · Stefan Herbrechtsmeier
Quoted 34 lines

Am 08.04.2022 um 11:23 schrieb Yi Zhao:

Quoted 33 lines · Stefan Herbrechtsmeier
Quoted 29 lines

Am 08.04.2022 um 10:15 schrieb Yi Zhao via lists.openembedded.org:

Quoted 20 lines

There is a bluetooth service startup failure:
bluetooth.service: Failed at step NAMESPACE spawning /usr/libexec/bluetooth/bluetoothd: No such file or directory bluetooth.service: Failed to set up mount namespacing: /run/systemd/unit-root/var/lib/bluetooth: No such file or directory

This is because the directory /var/lib/bluetooth has been listed in ReadWritePaths= in the service unit file but does not exist. We need to create it before service startup.

---
  meta/recipes-connectivity/bluez5/bluez5.inc | 2 ++

  1 file changed, 2 insertions(+)
meta/recipes-connectivity/bluez5/bluez5.inc +0 -0
index 79d4645ca8..ee2cdbcc59 100644
@@ -102,6 +102,8 @@ do_install:append() {
       # Patch python tools to use Python 3; they should be source compatible, but
       # still refer to Python 2 in the shebang
Quoted 3 lines

      sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/* +
+    install -d ${D}${localstatedir}/lib/bluetooth

Please use systemd StateDirectory= [1]. Maybe it is reasonable to replace the ReadWritePaths= with StateDirectory=.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#RuntimeDirectory=

Quoted 6 lines
Quoted 4 lines

Thanks Stefank, but the ReadWritePaths= is set by bluez:

https://github.com/bluez/bluez/commit/442d211b5f30f00d5ddd69b43385a03c1428ac45

And who creates the directory before the patch?

There is no need this directory before the patch. The service can startup without this directory.

Quoted 1 line
Quoted 15 lines
Quoted 1 line

The systemd solution to create a state directory is StateDirectory= (or tmpfiles.d for older versions of systemd). Systemd supports stateless system [1] and therefore every service must work with an empty /var/lib.

I'll try adding StateDirecotry to service unit file to  see if this can solve the problem.  Thanks.

//Yi

Quoted 4 lines

This patch hide a bug in bluez and the problem should be fixed in bluez.

[1] https://0pointer.net/blog/projects/stateless.html

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#164177): https://lists.openembedded.org/g/openembedded-core/message/164177
Mute This Topic: https://lists.openembedded.org/mt/90331367/6374899
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Hi,

Am 11.04.2022 um 09:17 schrieb Stefan Herbrechtsmeier via lists.openembedded.org:

Quoted 5 lines

Am 08.04.2022 um 22:03 schrieb Markus Volk via lists.openembedded.org:

Quoted 4 lines

also had this issue and found out, that the bluetooth service did come up, once bluetooth was enabled

My fix was to edit like this

Quoted 7 lines
Quoted 3 lines

ReadWritePaths=:/var/lib/bluetooth

The colon ensures that the service won't fail if the directory doesn't exist

Regarding the documentation the ReadOnlyPaths and ReadWritePaths makes not sense because ProtectSystem=full mounts /usr, boot loader and /etc directories read-only.

Have somebody report the problem to the bluez project?

I have open an issue:
https://github.com/bluez/bluez/issues/329

I will post a patch when we come to a solution.

Regards
Stefan

#9 lore raw
Quoted 19 lines · Stefan Herbrechtsmeier

Hi,

Am 11.04.2022 um 09:17 schrieb Stefan Herbrechtsmeier via lists.openembedded.org:

Quoted 15 lines

Am 08.04.2022 um 22:03 schrieb Markus Volk via lists.openembedded.org:

Quoted 9 lines

also had this issue and found out, that the bluetooth service did come up, once bluetooth was enabled

My fix was to edit like this

ReadWritePaths=:/var/lib/bluetooth

The colon ensures that the service won't fail if the directory doesn't exist

Regarding the documentation the ReadOnlyPaths and ReadWritePaths makes not sense because ProtectSystem=full mounts /usr, boot loader and /etc directories read-only.

Quoted 6 lines
Quoted 1 line

Have somebody report the problem to the bluez project?

I have open an issue:
https://github.com/bluez/bluez/issues/329

I will post a patch when we come to a solution.

We have a slight challenge in that I'd like to build 4.0 rc2 but I think there will be complaints if this is left broken.

I'm going to post a version of your patch and hope that improves things. If anyone knows of issues with that patch please let me know ASAP.

Cheers,

Richard