Bug 101570

Summary: On systemd systems, symlink dbus machine ID to /etc/machine-id
Product: dbus Reporter: Simon McVittie <smcv>
Component: coreAssignee: Simon McVittie <smcv>
Status: RESOLVED FIXED QA Contact: D-Bus Maintainers <dbus>
Severity: enhancement    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
Whiteboard: review+
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 101354    
Attachments: Install a systemd tmpfiles.d snippet to create /var/lib/dbus/machine-id
Install a systemd tmpfiles.d snippet to create /var/lib/dbus/machine-id

Description Simon McVittie 2017-06-23 16:22:35 UTC
Created attachment 132166 [details] [review]
Install a systemd tmpfiles.d snippet to create  /var/lib/dbus/machine-id

On systemd systems, /etc/machine-id is guaranteed to exist and has
the same format as the D-Bus machine ID. The major D-Bus implementations
read /etc/machine-id if it exists, but some less up-to-date
implementations still only read /var/lib/dbus/machine-id. We can be
nice to those implementations by ensuring /var/lib/dbus/machine-id
is a symlink; this way, the two files can never get out of sync.

---

We do this in Debian already, as a local packaging change. It supersedes this Ubuntu patch:

dbus (1.8.12-1ubuntu4) vivid; urgency=medium

  * debian/patches/ensure-dbus-machine-id.patch:
    - ensure that we have /var/lib/dbus/machine-id on user's system as some
      third-parties application relies on that file. It will only copy
      /etc/machine-id the file is not present already.

 -- Didier Roche <didrocks@ubuntu.com>   Thu, 19 Mar 2015 15:19:02 +0100

https://launchpadlibrarian.net/200646138/dbus_1.8.12-1ubuntu3_1.8.12-1ubuntu4.diff.gz

which ran dbus-uuidgen in the systemd unit (I preferred to use tmpfiles).

I did this in the Bug #101354 branch because in that branch, I also create ${runstatedir}/dbus/containers/ owned by messagebus in the tmpfiles snippet, so that the system bus can put its sockets there. If I try to do both things in the tmpfiles snippet without a dependency relationship, they'll conflict.
Comment 1 Simon McVittie 2017-06-23 16:23:47 UTC
Comment on attachment 132166 [details] [review]
Install a systemd tmpfiles.d snippet to create  /var/lib/dbus/machine-id

Review of attachment 132166 [details] [review]:
-----------------------------------------------------------------

::: bus/Makefile.am
@@ +319,4 @@
>  	systemd-user/dbus.service.in \
>  	systemd-user/dbus.socket.in \
>  	sysusers.d/dbus.conf.in
> +	tmpfiles.d/dbus.conf.in

This is clearly wrong - needs more backslashes.
Comment 2 Simon McVittie 2017-06-26 19:06:15 UTC
Created attachment 132263 [details] [review]
Install a systemd tmpfiles.d snippet to create  /var/lib/dbus/machine-id

On systemd systems, /etc/machine-id is guaranteed to exist and has
the same format as the D-Bus machine ID. The major D-Bus implementations
read /etc/machine-id if it exists, but some less up-to-date
implementations still only read /var/lib/dbus/machine-id. We can be
nice to those implementations by ensuring /var/lib/dbus/machine-id
is a symlink; this way, the two files can never get out of sync.

---

Correct Makefile syntax
Comment 3 Philip Withnall 2017-06-27 19:11:06 UTC
Comment on attachment 132263 [details] [review]
Install a systemd tmpfiles.d snippet to create  /var/lib/dbus/machine-id

Review of attachment 132263 [details] [review]:
-----------------------------------------------------------------

r+
Comment 4 Simon McVittie 2017-06-29 13:02:26 UTC
Thanks, fixed in git for 1.11.14.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.