'Machine ID' underspecified?

Thomas Kluyver thomas at kluyver.me.uk
Sat Dec 5 15:34:31 UTC 2020


The standard org.freedesktop.DBus.Peer interface (https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-peer ) defines a GetMachineId method. The spec says that this returns a UUID which "must be the same for all processes on a single system at least until that system next reboots."

libdbus handles calls to this method automatically, so if you're using that, you're covered. However, the spec doesn't define how other implementations can get a machine ID. It seems clear from the description that implementations can't just come up with their own way to make a suitable ID - they need to match the reference implementation (assuming they're talking on the standard message buses).

I looked into the code for the reference implementation. On Unix, it gets the ID from a compile-time configurable file (/var/lib/dbus/machine-id on my system) with a hardcoded fallback to /etc/machine-id:

https://gitlab.freedesktop.org/dbus/dbus/-/blob/2ef39181cfe1443c349500740855bf86f195f540/dbus/dbus-sysdeps-unix.c#L4257-4274

On Windows it appears to use a Windows API call GetCurrentHwProfileA to get a GUID representing the 'hardware profile', and reformat it into the UUID format D-Bus needs:

https://gitlab.freedesktop.org/dbus/dbus/-/blob/2ef39181cfe1443c349500740855bf86f195f540/dbus/dbus-sysdeps-win.c#L2820

Should this be described in the spec? Or is there a reason to leave it out? Can other implementations look for a file at /var/lib/dbus/machine-id on Unix systems, or does this location vary between distros?

Thanks,
Thomas


More information about the dbus mailing list