mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-15 04:23:21 +00:00
Allow overriding HwId data from the config file
To use this on a immutable system like ChromeOS you can create a file in /var/lib/fwupd/daemon.conf which is used as an override.
This commit is contained in:
parent
2c72b24978
commit
4f3e2c3a57
@ -48,3 +48,12 @@ IgnorePower=false
|
|||||||
|
|
||||||
# Only support installing firmware signed with a trusted key
|
# Only support installing firmware signed with a trusted key
|
||||||
OnlyTrusted=true
|
OnlyTrusted=true
|
||||||
|
|
||||||
|
# these are only required when the SMBIOS or Device Tree data is invalid or missing
|
||||||
|
#Manufacturer=
|
||||||
|
#ProductName=
|
||||||
|
#ProductSku=
|
||||||
|
#Family=
|
||||||
|
#EnclosureKind=
|
||||||
|
#BaseboardProduct=
|
||||||
|
#BaseboardManufacturer=
|
||||||
|
@ -351,6 +351,41 @@ fu_hwids_convert_integer_cb(FuSmbios *smbios, guint8 type, guint8 offset, GError
|
|||||||
return g_strdup_printf("%x", tmp);
|
return g_strdup_printf("%x", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
fu_hwids_setup_overrides(FuHwids *self, GError **error)
|
||||||
|
{
|
||||||
|
g_autofree gchar *localstatedir = fu_common_get_path(FU_PATH_KIND_LOCALSTATEDIR_PKG);
|
||||||
|
g_autofree gchar *sysconfigdir = fu_common_get_path(FU_PATH_KIND_SYSCONFDIR_PKG);
|
||||||
|
g_autoptr(GKeyFile) kf = g_key_file_new();
|
||||||
|
g_autoptr(GPtrArray) fns = g_ptr_array_new_with_free_func(g_free);
|
||||||
|
g_autoptr(GPtrArray) keys = fu_hwids_get_keys(self);
|
||||||
|
|
||||||
|
/* per-system configuration and optional overrides */
|
||||||
|
g_ptr_array_add(fns, g_build_filename(sysconfigdir, "daemon.conf", NULL));
|
||||||
|
g_ptr_array_add(fns, g_build_filename(localstatedir, "daemon.conf", NULL));
|
||||||
|
for (guint i = 0; i < fns->len; i++) {
|
||||||
|
const gchar *fn = g_ptr_array_index(fns, i);
|
||||||
|
if (g_file_test(fn, G_FILE_TEST_EXISTS)) {
|
||||||
|
g_debug("loading HwId overrides from %s", fn);
|
||||||
|
if (!g_key_file_load_from_file(kf, fn, G_KEY_FILE_NONE, error))
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
g_debug("not loading HwId overrides from %s", fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* all keys are optional */
|
||||||
|
for (guint i = 0; i < keys->len; i++) {
|
||||||
|
const gchar *key = g_ptr_array_index(keys, i);
|
||||||
|
g_autofree gchar *value = g_key_file_get_string(kf, "fwupd", key, NULL);
|
||||||
|
if (value != NULL)
|
||||||
|
fu_hwids_add_smbios_override(self, key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* success */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fu_hwids_setup:
|
* fu_hwids_setup:
|
||||||
* @self: a #FuHwids
|
* @self: a #FuHwids
|
||||||
@ -429,6 +464,10 @@ fu_hwids_setup(FuHwids *self, FuSmbios *smbios, GError **error)
|
|||||||
g_return_val_if_fail(FU_IS_SMBIOS(smbios) || smbios == NULL, FALSE);
|
g_return_val_if_fail(FU_IS_SMBIOS(smbios) || smbios == NULL, FALSE);
|
||||||
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
||||||
|
|
||||||
|
/* override using a config file */
|
||||||
|
if (!fu_hwids_setup_overrides(self, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
/* get all DMI data */
|
/* get all DMI data */
|
||||||
for (guint i = 0; map[i].key != NULL; i++) {
|
for (guint i = 0; map[i].key != NULL; i++) {
|
||||||
const gchar *contents_hdr = NULL;
|
const gchar *contents_hdr = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user