[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#745840: live-build: please truncate /etc/machine-id instead of deleting it



On 25/04/14 20:39, Daniel Baumann wrote:
> instead of truncating, would also 'echo "" > /etc/machine-id' work? this
> has the advantage to not break if people are using git (as git cannot
> track empty files).

git can track empty files fine. I was fairly sure, so I tried it, and it
works - also, Google finds mailing list and stackoverflow threads that
discuss empty files in git. I think you're thinking of empty
*directories*, which git doesn't track (because it doesn't track
directories at all)?

I think a 0-byte file is probably a little less likely to break
third-party software than the 1-byte file containing '\n', so I'd prefer
that; but if you feel strongly about it, the 1-byte version doesn't seem
to make any difference for systemd, dbus and GDBus.

What systemd and dbus actually check is that the file is 32 hex digits
followed by '\n', with arbitrary bytes after the \n ignored (systemd),
or 32 hex digits with optional arbitrary whitespace before and after
(dbus), so a file containing 0 bytes, or a file containing one byte
'\n', are equally invalid; so either works from that point of view.

GDBus in GLib doesn't validate /etc/machine-id at all, so it considers
either 0-byte or 1-byte to be valid (!) - I'll open a bug upstream.
However, it will get a valid machine ID as long as either systemd is pid
1 (it would bind-mount a transient machine ID over the top before any
GLib code got a chance to run), or the dbus sysvinit script or Upstart
job has run dbus-uuidgen --ensure (because GDBus prefers the D-Bus
machine ID over the systemd machine ID), or both.

    S


Reply to: