Bug 77941 - `dbus-uuidgen --ensure` should try to make /var/lib/dbus-machine-id match /etc/machine-id
Summary: `dbus-uuidgen --ensure` should try to make /var/lib/dbus-machine-id match /et...
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact:
URL:
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2014-04-25 17:59 UTC by Simon McVittie
Modified: 2014-04-28 14:49 UTC (History)
4 users (show)

See Also:
i915 platform:
i915 features:


Attachments
[1/2] _dbus_write_uuid_file: factor out function to write a known UUID (2.39 KB, patch)
2014-04-25 17:59 UTC, Simon McVittie
Details | Splinter Review
[2/2] Try to read /etc/machine-id before inventing a new /var/lib/dbus/machine-id (2.50 KB, patch)
2014-04-25 18:02 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2014-04-25 17:59:23 UTC
Steps to reproduce:

* install systemd on a system without dbus
* run systemd-machine-id-setup if not already run by maintainer scripts
* install dbus
* run dbus-uuidgen --ensure if not already run by maintainer scripts

(In a minimal Debian chroot: apt-get install --no-install-recommends systemd; apt-get install dbus. *.postinst run the relevant binaries automatically)

Expected result:

* /etc/machine-id contains 32 hex digits + "\n"
* /var/lib/dbus/machine-id contains exactly the same thing

Actual result:

* /etc/machine-id contains 32 hex digits + "\n"
* /var/lib/dbus/machine-id contains a different 32 hex digits + "\n"

If you do it the other way round (install dbus, run dbus-uuidgen --ensure, install systemd, run systemd-machine-id-setup) then it works as expected: we generate a D-Bus machine ID, then systemd-machine-id-setup just copies it.

Patches in a moment.
Comment 1 Simon McVittie 2014-04-25 17:59:54 UTC
Created attachment 97973 [details] [review]
[1/2] _dbus_write_uuid_file: factor out function to write a  known UUID
Comment 2 Simon McVittie 2014-04-25 18:02:17 UTC
Created attachment 97974 [details] [review]
[2/2] Try to read /etc/machine-id before inventing a new  /var/lib/dbus/machine-id

It's least confusing if the two files have the same contents. systemd
already knows how to pick up our /var/lib/dbus/machine-id if it exists
and /etc/machine-id doesn't, but the converse is not currently true.
We should make it true, so that it doesn't matter what order
systemd-machine-id-setup and "dbus-uuidgen --ensure" were
invoked in.

In Debian, systemd currently Recommends dbus, so "dbus-uuidgen --ensure"
will *usually* - but not always! - run first, and the two files will
match. However, if you install systemd without dbus, and then install
dbus later, there will be a mismatch. With this change, it doesn't
matter which one is installed first: whichever one happens to come
first, it will generate the machine ID, and then the other one will
copy it.
Comment 3 Lennart Poettering 2014-04-28 07:30:00 UTC
looks good to me!
Comment 4 Simon McVittie 2014-04-28 14:49:31 UTC
Fixed in git for 1.8.2, 1.9.0


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.