mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-05 09:59:44 +00:00
uefi: Do not enable the plugin if efivars are not available
If the user is using some super-old kernel or broken system we want to return early with an error rather than try to catch each way this can fail at runtime.
This commit is contained in:
parent
af5ec20004
commit
ae47a347e0
@ -605,13 +605,8 @@ fu_plugin_uefi_coldplug_resource (FuPlugin *plugin, fwup_resource *re)
|
||||
fu_device_set_version_lowest (dev, version_lowest);
|
||||
}
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_INTERNAL);
|
||||
if (g_file_test ("/sys/firmware/efi/efivars", G_FILE_TEST_IS_DIR) ||
|
||||
g_file_test ("/sys/firmware/efi/vars", G_FILE_TEST_IS_DIR)) {
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE);
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT);
|
||||
} else {
|
||||
g_warning ("Kernel support for EFI variables missing");
|
||||
}
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE);
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_NEEDS_REBOOT);
|
||||
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_REQUIRE_AC);
|
||||
if (uefi_type == FU_UEFI_DEVICE_KIND_DEVICE_FIRMWARE) {
|
||||
/* nothing better in the icon naming spec */
|
||||
@ -725,6 +720,29 @@ _efi_get_variable_exists (efi_guid_t guid, const char *name)
|
||||
return efi_get_variable_attributes (guid, name, &unused_attrs);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fu_plugin_uefi_check_efivars (GError **error)
|
||||
{
|
||||
g_autofree gchar *sysfsfwdir = NULL;
|
||||
g_autofree gchar *efivardir = NULL;
|
||||
g_autofree gchar *varsdir = NULL;
|
||||
|
||||
/* test if we have kernel EFI support */
|
||||
sysfsfwdir = fu_common_get_path (FU_PATH_KIND_SYSFSDIR_FW);
|
||||
efivardir = g_build_filename (sysfsfwdir, "efi", "efivars", NULL);
|
||||
varsdir = g_build_filename (sysfsfwdir, "efi", "vars", NULL);
|
||||
if (!g_file_test (efivardir, G_FILE_TEST_IS_DIR) &&
|
||||
!g_file_test (varsdir, G_FILE_TEST_IS_DIR)) {
|
||||
g_set_error_literal (error,
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"kernel support for EFI variables missing");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
fu_plugin_startup (FuPlugin *plugin, GError **error)
|
||||
{
|
||||
@ -740,6 +758,10 @@ fu_plugin_startup (FuPlugin *plugin, GError **error)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* are the EFI dirs set up so we can update each device */
|
||||
if (!fu_plugin_uefi_check_efivars (error))
|
||||
return FALSE;
|
||||
|
||||
/* load any overriden options */
|
||||
if (!fu_plugin_uefi_set_custom_mountpoint (plugin, error))
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user