path: root/dbus/dbus-sysdeps-unix.c
diff options
authorLennart Poettering <>2011-03-11 01:58:39 (GMT)
committerSimon McVittie <>2011-04-27 16:54:38 (GMT)
commit66e52541d5bdd4927a5c702963749760643313f4 (patch)
treeea62aa14a9fd3dc93d04064fe9098a02fd44f705 /dbus/dbus-sysdeps-unix.c
parent9c690c8b4f85efc44b3c31fd5007e308992e393b (diff)
machine-id: fall back to reading /etc/machine-id if D-Bus machine ID is not available
Newer systemd-based systems support a global machine ID with the same metrics as the D-Bus machine ID, but more powerful semantics (for example on ro media) in /etc/machine-id. If the D-Bus machine ID cannot be read, fall back to the systemd machine ID. This is a first step towards allowing D-Bus to be started up during early boot where /var is not available. [plus a whitespace fix -smcv] Reviewed-by: Simon McVittie <> Reviewed-by: Colin Walters <> Bug:
Diffstat (limited to 'dbus/dbus-sysdeps-unix.c')
1 files changed, 12 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index e9ea253..bb066ce 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -3349,8 +3349,19 @@ _dbus_read_local_machine_uuid (DBusGUID *machine_id,
DBusError *error)
DBusString filename;
+ dbus_bool_t b;
_dbus_string_init_const (&filename, DBUS_MACHINE_UUID_FILE);
- return _dbus_read_uuid_file (&filename, machine_id, create_if_not_found, error);
+ b = _dbus_read_uuid_file (&filename, machine_id, create_if_not_found, error);
+ if (b)
+ return TRUE;
+ dbus_error_free (error);
+ /* Fallback to the system machine ID */
+ _dbus_string_init_const (&filename, "/etc/machine-id");
+ return _dbus_read_uuid_file (&filename, machine_id, FALSE, error);