diff options
author | Alexandre Rostovtsev <tetromino@gentoo.org> | 2011-11-16 15:05:46 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-11-17 23:09:50 -0500 |
commit | dc89b51c2d71088c014ec94572629aabf143310e (patch) | |
tree | 17a2fbf704c1ebe9144d2acbe1b0f8f5c38311eb /gio/gdbusprivate.c | |
parent | 8d9f600aeab76277abfad0ee924954297a1c06d9 (diff) |
_g_dbus_get_machine_id(): check /etc/machine-id too
machine-id can be in /etc or in /var/lib/dbus.
[amended with slightly revised error handling -smcv]
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=663928
Diffstat (limited to 'gio/gdbusprivate.c')
-rw-r--r-- | gio/gdbusprivate.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index 55ac883ce..9149aab78 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -1983,17 +1983,26 @@ gchar * _g_dbus_get_machine_id (GError **error) { gchar *ret; + GError *first_error; /* TODO: use PACKAGE_LOCALSTATEDIR ? */ ret = NULL; + first_error = NULL; if (!g_file_get_contents ("/var/lib/dbus/machine-id", &ret, NULL, - error)) + &first_error) && + !g_file_get_contents ("/etc/machine-id", + &ret, + NULL, + NULL)) { - g_prefix_error (error, _("Unable to load /var/lib/dbus/machine-id: ")); + g_propagate_prefixed_error (error, first_error, + _("Unable to load /var/lib/dbus/machine-id or /etc/machine-id: ")); } else { + /* ignore the error from the first try, if any */ + g_clear_error (&first_error); /* TODO: validate value */ g_strstrip (ret); } |