Install a systemd tmpfiles.d snippet to create /var/lib/dbus/machine-id
authorSimon McVittie <smcv@collabora.com>
Tue, 20 Jun 2017 14:03:37 +0000 (15:03 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 28 Jun 2017 18:09:53 +0000 (19:09 +0100)
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.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101570

.gitignore
bus/Makefile.am
bus/tmpfiles.d/dbus.conf.in [new file with mode: 0644]
configure.ac

index 8d74682..6398e77 100644 (file)
@@ -37,6 +37,7 @@ config.h.in
 *.gcda
 *.gcno
 tags
+/bus/tmpfiles.d/dbus.conf
 /dbus-1.*/
 /dbus-1.*.tar.*
 /lcov.html/
index 6de6d0a..271887c 100644 (file)
@@ -2,6 +2,7 @@ dbusdatadir=$(datadir)/dbus-1
 legacydbusdatadir=$(sysconfdir)/dbus-1
 dbus_daemon_execdir = $(DBUS_DAEMONDIR)
 # Always lib, even if ${libdir} is lib64 or lib/x86_64-linux-gnu
+systemdtmpfilesdir = $(prefix)/lib/tmpfiles.d
 systemdsysusersdir = $(prefix)/lib/sysusers.d
 
 DBUS_BUS_LIBS = \
@@ -317,7 +318,8 @@ SCRIPT_IN_FILES += \
        dbus.socket.in \
        systemd-user/dbus.service.in \
        systemd-user/dbus.socket.in \
-       sysusers.d/dbus.conf.in
+       sysusers.d/dbus.conf.in \
+       tmpfiles.d/dbus.conf.in \
        $(NULL)
 
 systemdsystemunit_DATA = \
@@ -326,6 +328,10 @@ systemdsystemunit_DATA = \
 
 nodist_systemdsysusers_DATA = \
        sysusers.d/dbus.conf
+
+nodist_systemdtmpfiles_DATA = \
+       tmpfiles.d/dbus.conf \
+       $(NULL)
 endif
 
 if DBUS_ENABLE_USER_SESSION
diff --git a/bus/tmpfiles.d/dbus.conf.in b/bus/tmpfiles.d/dbus.conf.in
new file mode 100644 (file)
index 0000000..754f022
--- /dev/null
@@ -0,0 +1,5 @@
+# Fields: type; path; mode; uid; gid; age; argument (symlink target)
+
+# Make ${localstatedir}/lib/dbus/machine-id a symlink to /etc/machine-id
+# if it does not already exist
+L @EXPANDED_LOCALSTATEDIR@/lib/dbus/machine-id - - - - /etc/machine-id
index 1561c94..60e31f6 100644 (file)
@@ -1883,6 +1883,7 @@ bus/dbus.socket
 bus/systemd-user/dbus.service
 bus/systemd-user/dbus.socket
 bus/sysusers.d/dbus.conf
+bus/tmpfiles.d/dbus.conf
 Makefile
 dbus/Makefile
 bus/Makefile