mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 04:56:14 +01:00
_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
This commit is contained in:
parent
8d9f600aea
commit
dc89b51c2d
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user