trivial: Move getting the secure boot status to the common file

This commit is contained in:
Richard Hughes 2018-06-22 15:42:15 +01:00
parent 2b1fcfd662
commit 6b8235660b
4 changed files with 22 additions and 11 deletions

View File

@ -16,6 +16,7 @@
#include "fu-plugin.h"
#include "fu-plugin-vfuncs.h"
#include "fu-uefi-common.h"
#include "fu-uefi-device.h"
#ifndef HAVE_FWUP_GET_ESP_MOUNTPOINT
@ -603,19 +604,9 @@ fu_plugin_uefi_coldplug_resource (FuPlugin *plugin, fwup_resource *re)
static void
fu_plugin_uefi_test_secure_boot (FuPlugin *plugin)
{
const efi_guid_t guid = EFI_GLOBAL_GUID;
const gchar *result_str = "Disabled";
g_autofree guint8 *data = NULL;
gsize data_size = 0;
guint32 attributes = 0;
gint rc;
rc = efi_get_variable (guid, "SecureBoot", &data, &data_size, &attributes);
if (rc < 0)
return;
if (data_size >= 1 && data[0] & 1)
if (fu_uefi_secure_boot_enabled ())
result_str = "Enabled";
g_debug ("SecureBoot is: %s", result_str);
fu_plugin_add_report_metadata (plugin, "SecureBoot", result_str);
}

View File

@ -7,8 +7,26 @@
#include "config.h"
#include <efivar.h>
#include "fu-uefi-common.h"
gboolean
fu_uefi_secure_boot_enabled (void)
{
gint rc;
gsize data_size = 0;
guint32 attributes = 0;
g_autofree guint8 *data = NULL;
rc = efi_get_variable (efi_guid_global, "SecureBoot", &data, &data_size, &attributes);
if (rc < 0)
return FALSE;
if (data_size >= 1 && data[0] & 1)
return TRUE;
return FALSE;
}
static gint
fu_uefi_strcmp_sort_cb (gconstpointer a, gconstpointer b)
{

View File

@ -13,6 +13,7 @@
G_BEGIN_DECLS
gboolean fu_uefi_secure_boot_enabled (void);
GPtrArray *fu_uefi_get_esrt_entry_paths (const gchar *esrt_path,
GError **error);
guint64 fu_uefi_read_file_as_uint64 (const gchar *path,

View File

@ -50,6 +50,7 @@ if get_option('tests')
],
dependencies : [
plugin_deps,
fwup,
],
link_with : [
fwupd,