mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-07 19:57:56 +00:00
Fall back to /var/lib/dbus/machine-id when required
Fixes https://github.com/fwupd/fwupd/issues/1365
This commit is contained in:
parent
cee877dfc4
commit
a45994cb4a
@ -313,12 +313,31 @@ fwupd_build_user_agent (const gchar *package_name, const gchar *package_version)
|
|||||||
gchar *
|
gchar *
|
||||||
fwupd_build_machine_id (const gchar *salt, GError **error)
|
fwupd_build_machine_id (const gchar *salt, GError **error)
|
||||||
{
|
{
|
||||||
|
const gchar *fn = NULL;
|
||||||
g_autofree gchar *buf = NULL;
|
g_autofree gchar *buf = NULL;
|
||||||
|
g_auto(GStrv) fns = g_new0 (gchar *, 5);
|
||||||
g_autoptr(GChecksum) csum = NULL;
|
g_autoptr(GChecksum) csum = NULL;
|
||||||
gsize sz = 0;
|
gsize sz = 0;
|
||||||
|
|
||||||
/* this has to exist */
|
/* one of these has to exist */
|
||||||
if (!g_file_get_contents ("/etc/machine-id", &buf, &sz, error))
|
fns[0] = g_build_filename (SYSCONFDIR, "machine-id", NULL);
|
||||||
|
fns[1] = g_build_filename (LOCALSTATEDIR, "lib", "dbus", "machine-id", NULL);
|
||||||
|
fns[2] = g_strdup ("/etc/machine-id");
|
||||||
|
fns[3] = g_strdup ("/var/lib/dbus/machine-id");
|
||||||
|
for (guint i = 0; fns[i] != NULL; i++) {
|
||||||
|
if (g_file_test (fns[i], G_FILE_TEST_EXISTS)) {
|
||||||
|
fn = fns[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fn == NULL) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_READ,
|
||||||
|
"The machine-id is not present");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!g_file_get_contents (fn, &buf, &sz, error))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (sz == 0) {
|
if (sz == 0) {
|
||||||
g_set_error_literal (error,
|
g_set_error_literal (error,
|
||||||
|
Loading…
Reference in New Issue
Block a user