trivial: Use 'priv' for plugin private data to be consistent

This commit is contained in:
Richard Hughes 2022-06-25 11:53:03 +01:00 committed by Mario Limonciello
parent f5c7f2b789
commit b8be6daf1f
15 changed files with 330 additions and 330 deletions

View File

@ -113,13 +113,13 @@ static guint16
fu_dell_get_system_id(FuPlugin *plugin) fu_dell_get_system_id(FuPlugin *plugin)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *system_id_str = NULL; const gchar *system_id_str = NULL;
guint16 system_id = 0; guint16 system_id = 0;
gchar *endptr = NULL; gchar *endptr = NULL;
/* don't care for test suite */ /* don't care for test suite */
if (data->smi_obj->fake_smbios) if (priv->smi_obj->fake_smbios)
return 0; return 0;
system_id_str = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_SKU); system_id_str = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_SKU);
@ -214,24 +214,24 @@ fu_plugin_dell_inject_fake_data(FuPlugin *plugin,
guint8 *buf, guint8 *buf,
gboolean can_switch_modes) gboolean can_switch_modes)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (!data->smi_obj->fake_smbios) if (!priv->smi_obj->fake_smbios)
return; return;
for (guint i = 0; i < 4; i++) for (guint i = 0; i < 4; i++)
data->smi_obj->output[i] = output[i]; priv->smi_obj->output[i] = output[i];
data->fake_vid = vid; priv->fake_vid = vid;
data->fake_pid = pid; priv->fake_pid = pid;
data->smi_obj->fake_buffer = buf; priv->smi_obj->fake_buffer = buf;
data->can_switch_modes = TRUE; priv->can_switch_modes = TRUE;
} }
static gboolean static gboolean
fu_plugin_dell_capsule_supported(FuPlugin *plugin) fu_plugin_dell_capsule_supported(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
return data->smi_obj->fake_smbios || data->capsule_supported; return priv->smi_obj->fake_smbios || priv->capsule_supported;
} }
static gboolean static gboolean
@ -291,7 +291,7 @@ fu_plugin_dock_node(FuPlugin *plugin,
gboolean gboolean
fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **error) fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
FwupdVersionFormat version_format = FWUPD_VERSION_FORMAT_DELL_BIOS; FwupdVersionFormat version_format = FWUPD_VERSION_FORMAT_DELL_BIOS;
guint16 pid; guint16 pid;
guint16 vid; guint16 vid;
@ -315,13 +315,13 @@ fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError *
/* don't look up immediately if a dock is connected as that would /* don't look up immediately if a dock is connected as that would
mean a SMI on every USB device that showed up on the system */ mean a SMI on every USB device that showed up on the system */
if (!data->smi_obj->fake_smbios) { if (!priv->smi_obj->fake_smbios) {
vid = fu_usb_device_get_vid(FU_USB_DEVICE(device)); vid = fu_usb_device_get_vid(FU_USB_DEVICE(device));
pid = fu_usb_device_get_pid(FU_USB_DEVICE(device)); pid = fu_usb_device_get_pid(FU_USB_DEVICE(device));
platform = fu_device_get_physical_id(FU_DEVICE(device)); platform = fu_device_get_physical_id(FU_DEVICE(device));
} else { } else {
vid = data->fake_vid; vid = priv->fake_vid;
pid = data->fake_pid; pid = priv->fake_pid;
platform = "fake"; platform = "fake";
} }
@ -337,7 +337,7 @@ fu_plugin_dell_backend_device_added(FuPlugin *plugin, FuDevice *device, GError *
} }
buf.buf = NULL; buf.buf = NULL;
if (!fu_dell_query_dock(data->smi_obj, &buf)) { if (!fu_dell_query_dock(priv->smi_obj, &buf)) {
g_debug("no dock detected"); g_debug("no dock detected");
return TRUE; return TRUE;
} }
@ -670,7 +670,7 @@ gboolean
fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error) fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *tpm_mode; const gchar *tpm_mode;
const gchar *tpm_mode_alt; const gchar *tpm_mode_alt;
guint16 system_id = 0; guint16 system_id = 0;
@ -688,12 +688,12 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error)
g_autoptr(FuDevice) dev = NULL; g_autoptr(FuDevice) dev = NULL;
g_autoptr(GError) error_tss = NULL; g_autoptr(GError) error_tss = NULL;
fu_dell_clear_smi(data->smi_obj); fu_dell_clear_smi(priv->smi_obj);
out = (struct tpm_status *)data->smi_obj->output; out = (struct tpm_status *)priv->smi_obj->output;
/* execute TPM Status Query */ /* execute TPM Status Query */
data->smi_obj->input[0] = DACI_FLASH_ARG_TPM; priv->smi_obj->input[0] = DACI_FLASH_ARG_TPM;
if (!fu_dell_execute_simple_smi(data->smi_obj, if (!fu_dell_execute_simple_smi(priv->smi_obj,
DACI_FLASH_INTERFACE_CLASS, DACI_FLASH_INTERFACE_CLASS,
DACI_FLASH_INTERFACE_SELECT)) DACI_FLASH_INTERFACE_SELECT))
return FALSE; return FALSE;
@ -707,7 +707,7 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error)
/* HW version is output in second /input/ arg /* HW version is output in second /input/ arg
* it may be relevant as next gen TPM is enabled * it may be relevant as next gen TPM is enabled
*/ */
g_debug("TPM HW version: 0x%x", data->smi_obj->input[1]); g_debug("TPM HW version: 0x%x", priv->smi_obj->input[1]);
g_debug("TPM Status: 0x%x", out->status); g_debug("TPM Status: 0x%x", out->status);
/* test TPM enabled (Bit 0) */ /* test TPM enabled (Bit 0) */
@ -729,8 +729,8 @@ fu_plugin_dell_detect_tpm(FuPlugin *plugin, GError **error)
} }
system_id = fu_dell_get_system_id(plugin); system_id = fu_dell_get_system_id(plugin);
if (data->smi_obj->fake_smbios) if (priv->smi_obj->fake_smbios)
can_switch_modes = data->can_switch_modes; can_switch_modes = priv->can_switch_modes;
else if (system_id == 0) else if (system_id == 0)
return FALSE; return FALSE;
@ -871,18 +871,18 @@ fu_plugin_dell_load(FuContext *ctx)
static void static void
fu_plugin_dell_init(FuPlugin *plugin) fu_plugin_dell_init(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData));
data->smi_obj = g_malloc0(sizeof(FuDellSmiObj)); priv->smi_obj = g_malloc0(sizeof(FuDellSmiObj));
if (g_getenv("FWUPD_DELL_VERBOSE") != NULL) if (g_getenv("FWUPD_DELL_VERBOSE") != NULL)
(void)g_setenv("LIBSMBIOS_C_DEBUG_OUTPUT_ALL", "1", TRUE); (void)g_setenv("LIBSMBIOS_C_DEBUG_OUTPUT_ALL", "1", TRUE);
else else
(void)g_setenv("TSS2_LOG", "esys+none,tcti+none", FALSE); (void)g_setenv("TSS2_LOG", "esys+none,tcti+none", FALSE);
if (fu_dell_supported(plugin)) if (fu_dell_supported(plugin))
data->smi_obj->smi = dell_smi_factory(DELL_SMI_DEFAULTS); priv->smi_obj->smi = dell_smi_factory(DELL_SMI_DEFAULTS);
data->smi_obj->fake_smbios = FALSE; priv->smi_obj->fake_smbios = FALSE;
if (g_getenv("FWUPD_DELL_FAKE_SMBIOS") != NULL) if (g_getenv("FWUPD_DELL_FAKE_SMBIOS") != NULL)
data->smi_obj->fake_smbios = TRUE; priv->smi_obj->fake_smbios = TRUE;
/* make sure that UEFI plugin is ready to receive devices */ /* make sure that UEFI plugin is ready to receive devices */
fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "uefi_capsule"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "uefi_capsule");
@ -894,20 +894,20 @@ fu_plugin_dell_init(FuPlugin *plugin)
static void static void
fu_plugin_dell_destroy(FuPlugin *plugin) fu_plugin_dell_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->smi_obj->smi) if (priv->smi_obj->smi)
dell_smi_obj_free(data->smi_obj->smi); dell_smi_obj_free(priv->smi_obj->smi);
g_free(data->smi_obj); g_free(priv->smi_obj);
} }
static gboolean static gboolean
fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *sysfsfwdir = NULL; g_autofree gchar *sysfsfwdir = NULL;
g_autofree gchar *esrtdir = NULL; g_autofree gchar *esrtdir = NULL;
if (data->smi_obj->fake_smbios) { if (priv->smi_obj->fake_smbios) {
g_debug("Called with fake SMBIOS implementation. " g_debug("Called with fake SMBIOS implementation. "
"We're ignoring test for SBMIOS table and ESRT. " "We're ignoring test for SBMIOS table and ESRT. "
"Individual calls will need to be properly staged."); "Individual calls will need to be properly staged.");
@ -922,7 +922,7 @@ fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
return FALSE; return FALSE;
} }
if (data->smi_obj->smi == NULL) { if (priv->smi_obj->smi == NULL) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_INTERNAL, FWUPD_ERROR_INTERNAL,
@ -938,7 +938,7 @@ fu_plugin_dell_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
sysfsfwdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_FW); sysfsfwdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_FW);
esrtdir = g_build_filename(sysfsfwdir, "efi", "esrt", NULL); esrtdir = g_build_filename(sysfsfwdir, "efi", "esrt", NULL);
if (g_file_test(esrtdir, G_FILE_TEST_EXISTS)) if (g_file_test(esrtdir, G_FILE_TEST_EXISTS))
data->capsule_supported = TRUE; priv->capsule_supported = TRUE;
/* capsules not supported */ /* capsules not supported */
if (!fu_plugin_dell_capsule_supported(plugin)) { if (!fu_plugin_dell_capsule_supported(plugin)) {

View File

@ -35,12 +35,12 @@ fu_plugin_flashrom_init(FuPlugin *plugin)
static void static void
fu_plugin_flashrom_destroy(FuPlugin *plugin) fu_plugin_flashrom_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->flashctx != NULL) if (priv->flashctx != NULL)
flashrom_flash_release(data->flashctx); flashrom_flash_release(priv->flashctx);
if (data->flashprog != NULL) if (priv->flashprog != NULL)
flashrom_programmer_shutdown(data->flashprog); flashrom_programmer_shutdown(priv->flashprog);
g_free(data->guid); g_free(priv->guid);
} }
static int static int
@ -169,13 +169,13 @@ fu_plugin_flashrom_add_device(FuPlugin *plugin,
GError **error) GError **error)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *dmi_vendor; const gchar *dmi_vendor;
const gchar *product = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME); const gchar *product = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_PRODUCT_NAME);
const gchar *vendor = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER); const gchar *vendor = fu_context_get_hwid_value(ctx, FU_HWIDS_KEY_MANUFACTURER);
const gchar *region_str = fu_ifd_region_to_string(region); const gchar *region_str = fu_ifd_region_to_string(region);
g_autofree gchar *name = g_strdup_printf("%s (%s)", product, region_str); g_autofree gchar *name = g_strdup_printf("%s (%s)", product, region_str);
g_autoptr(FuDevice) device = fu_flashrom_device_new(ctx, data->flashctx, region); g_autoptr(FuDevice) device = fu_flashrom_device_new(ctx, priv->flashctx, region);
fu_device_set_name(device, name); fu_device_set_name(device, name);
fu_device_set_vendor(device, vendor); fu_device_set_vendor(device, vendor);
@ -218,7 +218,7 @@ static void
fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device) fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device)
{ {
g_autoptr(FuDevice) me_device = NULL; g_autoptr(FuDevice) me_device = NULL;
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *me_region_str = fu_ifd_region_to_string(FU_IFD_REGION_ME); const gchar *me_region_str = fu_ifd_region_to_string(FU_IFD_REGION_ME);
/* we're only interested in a device from intel-spi plugin that corresponds to ME /* we're only interested in a device from intel-spi plugin that corresponds to ME
@ -228,7 +228,7 @@ fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device)
if (g_strcmp0(fu_device_get_logical_id(device), me_region_str) != 0) if (g_strcmp0(fu_device_get_logical_id(device), me_region_str) != 0)
return; return;
me_device = fu_plugin_flashrom_add_device(plugin, data->guid, FU_IFD_REGION_ME, NULL); me_device = fu_plugin_flashrom_add_device(plugin, priv->guid, FU_IFD_REGION_ME, NULL);
if (me_device == NULL) if (me_device == NULL)
return; return;
@ -240,9 +240,9 @@ fu_plugin_flashrom_device_registered(FuPlugin *plugin, FuDevice *device)
static gboolean static gboolean
fu_plugin_flashrom_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_flashrom_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FuDevice) device = g_autoptr(FuDevice) device =
fu_plugin_flashrom_add_device(plugin, data->guid, FU_IFD_REGION_BIOS, error); fu_plugin_flashrom_add_device(plugin, priv->guid, FU_IFD_REGION_BIOS, error);
return (device != NULL); return (device != NULL);
} }
@ -270,7 +270,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro
{ {
gint rc; gint rc;
const gchar *guid; const gchar *guid;
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
/* progress */ /* progress */
fu_progress_set_id(progress, G_STRLOC); fu_progress_set_id(progress, G_STRLOC);
@ -283,7 +283,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro
return FALSE; return FALSE;
fu_progress_step_done(progress); fu_progress_step_done(progress);
data->guid = g_strdup(guid); priv->guid = g_strdup(guid);
if (flashrom_init(SELFCHECK_TRUE)) { if (flashrom_init(SELFCHECK_TRUE)) {
g_set_error_literal(error, g_set_error_literal(error,
@ -295,7 +295,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro
flashrom_set_log_callback(fu_plugin_flashrom_debug_cb); flashrom_set_log_callback(fu_plugin_flashrom_debug_cb);
fu_progress_step_done(progress); fu_progress_step_done(progress);
if (flashrom_programmer_init(&data->flashprog, "internal", NULL)) { if (flashrom_programmer_init(&priv->flashprog, "internal", NULL)) {
g_set_error_literal(error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -303,7 +303,7 @@ fu_plugin_flashrom_startup(FuPlugin *plugin, FuProgress *progress, GError **erro
return FALSE; return FALSE;
} }
rc = flashrom_flash_probe(&data->flashctx, data->flashprog, NULL); rc = flashrom_flash_probe(&priv->flashctx, priv->flashprog, NULL);
if (rc == 3) { if (rc == 3) {
g_set_error_literal(error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,

View File

@ -23,8 +23,8 @@ fu_plugin_gpio_load(FuContext *ctx)
static void static void
fu_plugin_gpio_init(FuPlugin *plugin) fu_plugin_gpio_init(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData));
data->current_logical_ids = g_ptr_array_new_with_free_func(g_free); priv->current_logical_ids = g_ptr_array_new_with_free_func(g_free);
fu_plugin_add_udev_subsystem(plugin, "gpio"); fu_plugin_add_udev_subsystem(plugin, "gpio");
fu_plugin_add_device_gtype(plugin, FU_TYPE_GPIO_DEVICE); fu_plugin_add_device_gtype(plugin, FU_TYPE_GPIO_DEVICE);
} }
@ -32,8 +32,8 @@ fu_plugin_gpio_init(FuPlugin *plugin)
static void static void
fu_plugin_gpio_destroy(FuPlugin *plugin) fu_plugin_gpio_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_ptr_array_unref(data->current_logical_ids); g_ptr_array_unref(priv->current_logical_ids);
} }
static gboolean static gboolean
@ -58,7 +58,7 @@ fu_plugin_gpio_parse_level(const gchar *str, gboolean *ret, GError **error)
static gboolean static gboolean
fu_plugin_gpio_process_quirk(FuPlugin *self, const gchar *str, GError **error) fu_plugin_gpio_process_quirk(FuPlugin *self, const gchar *str, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(self); FuPluginData *priv = fu_plugin_get_data(self);
gboolean value = FALSE; gboolean value = FALSE;
FuDevice *device_tmp; FuDevice *device_tmp;
g_auto(GStrv) split = g_strsplit(str, ",", -1); g_auto(GStrv) split = g_strsplit(str, ",", -1);
@ -93,7 +93,7 @@ fu_plugin_gpio_process_quirk(FuPlugin *self, const gchar *str, GError **error)
} }
/* success */ /* success */
g_ptr_array_add(data->current_logical_ids, g_strdup(fu_device_get_logical_id(device_tmp))); g_ptr_array_add(priv->current_logical_ids, g_strdup(fu_device_get_logical_id(device_tmp)));
return TRUE; return TRUE;
} }
@ -126,13 +126,13 @@ fu_plugin_gpio_cleanup(FuPlugin *self,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(self); FuPluginData *priv = fu_plugin_get_data(self);
g_autoptr(GPtrArray) current_logical_ids = NULL; g_autoptr(GPtrArray) current_logical_ids = NULL;
/* deep copy to local to clear transaction array */ /* deep copy to local to clear transaction array */
current_logical_ids = current_logical_ids =
g_ptr_array_copy(data->current_logical_ids, (GCopyFunc)g_strdup, NULL); g_ptr_array_copy(priv->current_logical_ids, (GCopyFunc)g_strdup, NULL);
g_ptr_array_set_size(data->current_logical_ids, 0); g_ptr_array_set_size(priv->current_logical_ids, 0);
/* close the fds we opened during ->prepare */ /* close the fds we opened during ->prepare */
for (guint i = 0; i < current_logical_ids->len; i++) { for (guint i = 0; i < current_logical_ids->len; i++) {

View File

@ -37,7 +37,7 @@ fu_plugin_iommu_backend_device_added(FuPlugin *plugin, FuDevice *device, GError
static void static void
fu_plugin_iommu_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_iommu_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
/* create attr */ /* create attr */
@ -46,7 +46,7 @@ fu_plugin_iommu_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin));
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
if (!data->has_iommu) { if (!priv->has_iommu) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND);
return; return;
} }

View File

@ -31,12 +31,12 @@ fu_plugin_linux_lockdown_init(FuPlugin *plugin)
static void static void
fu_plugin_linux_lockdown_destroy(FuPlugin *plugin) fu_plugin_linux_lockdown_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->file != NULL) if (priv->file != NULL)
g_object_unref(data->file); g_object_unref(priv->file);
if (data->monitor != NULL) { if (priv->monitor != NULL) {
g_file_monitor_cancel(data->monitor); g_file_monitor_cancel(priv->monitor);
g_object_unref(data->monitor); g_object_unref(priv->monitor);
} }
} }
@ -57,27 +57,27 @@ fu_plugin_linux_lockdown_to_string(FuPluginLinuxLockdown lockdown)
static void static void
fu_plugin_linux_lockdown_rescan(FuPlugin *plugin) fu_plugin_linux_lockdown_rescan(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gsize bufsz = 0; gsize bufsz = 0;
g_autofree gchar *buf = NULL; g_autofree gchar *buf = NULL;
/* load file */ /* load file */
if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, NULL)) { if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, NULL)) {
data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INVALID; priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INVALID;
} else if (g_strstr_len(buf, bufsz, "[none]") != NULL) { } else if (g_strstr_len(buf, bufsz, "[none]") != NULL) {
data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_NONE; priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_NONE;
} else if (g_strstr_len(buf, bufsz, "[integrity]") != NULL) { } else if (g_strstr_len(buf, bufsz, "[integrity]") != NULL) {
data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INTEGRITY; priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_INTEGRITY;
} else if (g_strstr_len(buf, bufsz, "[confidentiality]") != NULL) { } else if (g_strstr_len(buf, bufsz, "[confidentiality]") != NULL) {
data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_CONFIDENTIALITY; priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_CONFIDENTIALITY;
} else { } else {
data->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN; priv->lockdown = FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN;
} }
/* update metadata */ /* update metadata */
fu_plugin_add_report_metadata(plugin, fu_plugin_add_report_metadata(plugin,
"LinuxLockdown", "LinuxLockdown",
fu_plugin_linux_lockdown_to_string(data->lockdown)); fu_plugin_linux_lockdown_to_string(priv->lockdown));
} }
static void static void
@ -96,7 +96,7 @@ fu_plugin_linux_lockdown_changed_cb(GFileMonitor *monitor,
static gboolean static gboolean
fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *path = NULL; g_autofree gchar *path = NULL;
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
@ -109,11 +109,11 @@ fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError
"Kernel doesn't offer lockdown support."); "Kernel doesn't offer lockdown support.");
return FALSE; return FALSE;
} }
data->file = g_file_new_for_path(fn); priv->file = g_file_new_for_path(fn);
data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error);
if (data->monitor == NULL) if (priv->monitor == NULL)
return FALSE; return FALSE;
g_signal_connect(G_FILE_MONITOR(data->monitor), g_signal_connect(G_FILE_MONITOR(priv->monitor),
"changed", "changed",
G_CALLBACK(fu_plugin_linux_lockdown_changed_cb), G_CALLBACK(fu_plugin_linux_lockdown_changed_cb),
plugin); plugin);
@ -124,7 +124,7 @@ fu_plugin_linux_lockdown_startup(FuPlugin *plugin, FuProgress *progress, GError
static void static void
fu_plugin_linux_lockdown_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_linux_lockdown_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
/* create attr */ /* create attr */
@ -133,17 +133,17 @@ fu_plugin_linux_lockdown_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *a
fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE); fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_RUNTIME_ISSUE);
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN) { if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_UNKNOWN) {
fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA); fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_MISSING_DATA);
return; return;
} }
/* load file */ /* load file */
if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_INVALID) { if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_INVALID) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID);
return; return;
} }
if (data->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_NONE) { if (priv->lockdown == FU_PLUGIN_LINUX_LOCKDOWN_NONE) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED);
return; return;
} }

View File

@ -24,12 +24,12 @@ fu_plugin_linux_swap_init(FuPlugin *plugin)
static void static void
fu_plugin_linux_swap_destroy(FuPlugin *plugin) fu_plugin_linux_swap_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->file != NULL) if (priv->file != NULL)
g_object_unref(data->file); g_object_unref(priv->file);
if (data->monitor != NULL) { if (priv->monitor != NULL) {
g_file_monitor_cancel(data->monitor); g_file_monitor_cancel(priv->monitor);
g_object_unref(data->monitor); g_object_unref(priv->monitor);
} }
} }
@ -48,7 +48,7 @@ fu_plugin_linux_swap_changed_cb(GFileMonitor *monitor,
static gboolean static gboolean
fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
g_autofree gchar *procfs = NULL; g_autofree gchar *procfs = NULL;
@ -61,11 +61,11 @@ fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **er
"Kernel doesn't offer swap support."); "Kernel doesn't offer swap support.");
return FALSE; return FALSE;
} }
data->file = g_file_new_for_path(fn); priv->file = g_file_new_for_path(fn);
data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error);
if (data->monitor == NULL) if (priv->monitor == NULL)
return FALSE; return FALSE;
g_signal_connect(G_FILE_MONITOR(data->monitor), g_signal_connect(G_FILE_MONITOR(priv->monitor),
"changed", "changed",
G_CALLBACK(fu_plugin_linux_swap_changed_cb), G_CALLBACK(fu_plugin_linux_swap_changed_cb),
plugin); plugin);
@ -75,14 +75,14 @@ fu_plugin_linux_swap_startup(FuPlugin *plugin, FuProgress *progress, GError **er
static void static void
fu_plugin_linux_swap_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_linux_swap_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gsize bufsz = 0; gsize bufsz = 0;
g_autofree gchar *buf = NULL; g_autofree gchar *buf = NULL;
g_autoptr(FuLinuxSwap) swap = NULL; g_autoptr(FuLinuxSwap) swap = NULL;
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
if (data->file == NULL) if (priv->file == NULL)
return; return;
/* create attr */ /* create attr */
@ -92,15 +92,15 @@ fu_plugin_linux_swap_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
/* load list of swaps */ /* load list of swaps */
if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, &error_local)) { if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, &error_local)) {
g_autofree gchar *fn = g_file_get_path(data->file); g_autofree gchar *fn = g_file_get_path(priv->file);
g_warning("could not open %s: %s", fn, error_local->message); g_warning("could not open %s: %s", fn, error_local->message);
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID);
return; return;
} }
swap = fu_linux_swap_new(buf, bufsz, &error_local); swap = fu_linux_swap_new(buf, bufsz, &error_local);
if (swap == NULL) { if (swap == NULL) {
g_autofree gchar *fn = g_file_get_path(data->file); g_autofree gchar *fn = g_file_get_path(priv->file);
g_warning("could not parse %s: %s", fn, error_local->message); g_warning("could not parse %s: %s", fn, error_local->message);
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID);
return; return;

View File

@ -22,12 +22,12 @@ fu_plugin_linux_tainted_init(FuPlugin *plugin)
static void static void
fu_plugin_linux_tainted_destroy(FuPlugin *plugin) fu_plugin_linux_tainted_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->file != NULL) if (priv->file != NULL)
g_object_unref(data->file); g_object_unref(priv->file);
if (data->monitor != NULL) { if (priv->monitor != NULL) {
g_file_monitor_cancel(data->monitor); g_file_monitor_cancel(priv->monitor);
g_object_unref(data->monitor); g_object_unref(priv->monitor);
} }
} }
@ -46,17 +46,17 @@ fu_plugin_linux_tainted_changed_cb(GFileMonitor *monitor,
static gboolean static gboolean
fu_plugin_linux_tainted_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_linux_tainted_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
g_autofree gchar *procfs = NULL; g_autofree gchar *procfs = NULL;
procfs = fu_path_from_kind(FU_PATH_KIND_PROCFS); procfs = fu_path_from_kind(FU_PATH_KIND_PROCFS);
fn = g_build_filename(procfs, "sys", "kernel", "tainted", NULL); fn = g_build_filename(procfs, "sys", "kernel", "tainted", NULL);
data->file = g_file_new_for_path(fn); priv->file = g_file_new_for_path(fn);
data->monitor = g_file_monitor(data->file, G_FILE_MONITOR_NONE, NULL, error); priv->monitor = g_file_monitor(priv->file, G_FILE_MONITOR_NONE, NULL, error);
if (data->monitor == NULL) if (priv->monitor == NULL)
return FALSE; return FALSE;
g_signal_connect(G_FILE_MONITOR(data->monitor), g_signal_connect(G_FILE_MONITOR(priv->monitor),
"changed", "changed",
G_CALLBACK(fu_plugin_linux_tainted_changed_cb), G_CALLBACK(fu_plugin_linux_tainted_changed_cb),
plugin); plugin);
@ -66,7 +66,7 @@ fu_plugin_linux_tainted_startup(FuPlugin *plugin, FuProgress *progress, GError *
static void static void
fu_plugin_linux_tainted_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_linux_tainted_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gsize bufsz = 0; gsize bufsz = 0;
g_autofree gchar *buf = NULL; g_autofree gchar *buf = NULL;
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
@ -79,8 +79,8 @@ fu_plugin_linux_tainted_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *at
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
/* load file */ /* load file */
if (!g_file_load_contents(data->file, NULL, &buf, &bufsz, NULL, &error_local)) { if (!g_file_load_contents(priv->file, NULL, &buf, &bufsz, NULL, &error_local)) {
g_autofree gchar *fn = g_file_get_path(data->file); g_autofree gchar *fn = g_file_get_path(priv->file);
g_warning("could not open %s: %s", fn, error_local->message); g_warning("could not open %s: %s", fn, error_local->message);
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID);
return; return;

View File

@ -25,20 +25,20 @@ fu_plugin_logind_init(FuPlugin *plugin)
static void static void
fu_plugin_logind_destroy(FuPlugin *plugin) fu_plugin_logind_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->logind_fd != 0) if (priv->logind_fd != 0)
g_close(data->logind_fd, NULL); g_close(priv->logind_fd, NULL);
if (data->logind_proxy != NULL) if (priv->logind_proxy != NULL)
g_object_unref(data->logind_proxy); g_object_unref(priv->logind_proxy);
} }
static gboolean static gboolean
fu_plugin_logind_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_logind_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *name_owner = NULL; g_autofree gchar *name_owner = NULL;
data->logind_proxy = g_dbus_proxy_new_for_bus_sync( priv->logind_proxy = g_dbus_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM, G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
NULL, NULL,
@ -47,17 +47,17 @@ fu_plugin_logind_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
"org.freedesktop.login1.Manager", "org.freedesktop.login1.Manager",
NULL, NULL,
error); error);
if (data->logind_proxy == NULL) { if (priv->logind_proxy == NULL) {
g_prefix_error(error, "failed to connect to logind: "); g_prefix_error(error, "failed to connect to logind: ");
return FALSE; return FALSE;
} }
name_owner = g_dbus_proxy_get_name_owner(data->logind_proxy); name_owner = g_dbus_proxy_get_name_owner(priv->logind_proxy);
if (name_owner == NULL) { if (name_owner == NULL) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"no owner for %s", "no owner for %s",
g_dbus_proxy_get_name(data->logind_proxy)); g_dbus_proxy_get_name(priv->logind_proxy));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -70,7 +70,7 @@ fu_plugin_logind_prepare(FuPlugin *plugin,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
g_autoptr(GUnixFDList) out_fd_list = NULL; g_autoptr(GUnixFDList) out_fd_list = NULL;
g_autoptr(GVariant) res = NULL; g_autoptr(GVariant) res = NULL;
@ -78,18 +78,18 @@ fu_plugin_logind_prepare(FuPlugin *plugin,
"handle-hibernate-key:handle-lid-switch"; "handle-hibernate-key:handle-lid-switch";
/* already inhibited */ /* already inhibited */
if (data->logind_fd != 0) if (priv->logind_fd != 0)
return TRUE; return TRUE;
/* not yet connected */ /* not yet connected */
if (data->logind_proxy == NULL) { if (priv->logind_proxy == NULL) {
g_warning("no logind connection to use"); g_warning("no logind connection to use");
return TRUE; return TRUE;
} }
/* block shutdown and idle */ /* block shutdown and idle */
res = g_dbus_proxy_call_with_unix_fd_list_sync( res = g_dbus_proxy_call_with_unix_fd_list_sync(
data->logind_proxy, priv->logind_proxy,
"Inhibit", "Inhibit",
g_variant_new("(ssss)", what, PACKAGE_NAME, "Firmware Update in Progress", "block"), g_variant_new("(ssss)", what, PACKAGE_NAME, "Firmware Update in Progress", "block"),
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
@ -108,8 +108,8 @@ fu_plugin_logind_prepare(FuPlugin *plugin,
g_warning("invalid response from logind"); g_warning("invalid response from logind");
return TRUE; return TRUE;
} }
data->logind_fd = g_unix_fd_list_get(out_fd_list, 0, NULL); priv->logind_fd = g_unix_fd_list_get(out_fd_list, 0, NULL);
g_debug("opened logind fd %i", data->logind_fd); g_debug("opened logind fd %i", priv->logind_fd);
return TRUE; return TRUE;
} }
@ -120,13 +120,13 @@ fu_plugin_logind_cleanup(FuPlugin *plugin,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->logind_fd == 0) if (priv->logind_fd == 0)
return TRUE; return TRUE;
g_debug("closed logind fd %i", data->logind_fd); g_debug("closed logind fd %i", priv->logind_fd);
if (!g_close(data->logind_fd, error)) if (!g_close(priv->logind_fd, error))
return FALSE; return FALSE;
data->logind_fd = 0; priv->logind_fd = 0;
return TRUE; return TRUE;
} }

View File

@ -58,9 +58,9 @@ fu_plugin_pci_mei_init(FuPlugin *plugin)
static void static void
fu_plugin_pci_mei_destroy(FuPlugin *plugin) fu_plugin_pci_mei_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->pci_device != NULL) if (priv->pci_device != NULL)
g_object_unref(data->pci_device); g_object_unref(priv->pci_device);
} }
static FuMeiFamily static FuMeiFamily

View File

@ -59,9 +59,9 @@ fu_plugin_powerd_delete_suspend_file(GError **error)
static void static void
fu_plugin_powerd_destroy(FuPlugin *plugin) fu_plugin_powerd_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->proxy != NULL) if (priv->proxy != NULL)
g_object_unref(data->proxy); g_object_unref(priv->proxy);
} }
static void static void
@ -97,14 +97,14 @@ fu_plugin_powerd_proxy_changed_cb(GDBusProxy *proxy,
static gboolean static gboolean
fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *name_owner = NULL; g_autofree gchar *name_owner = NULL;
if (!fu_plugin_powerd_delete_suspend_file(error)) if (!fu_plugin_powerd_delete_suspend_file(error))
return FALSE; return FALSE;
/* establish proxy for method call to powerd */ /* establish proxy for method call to powerd */
data->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, priv->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
NULL, NULL,
"org.chromium.PowerManager", "org.chromium.PowerManager",
@ -113,22 +113,22 @@ fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
NULL, NULL,
error); error);
if (data->proxy == NULL) { if (priv->proxy == NULL) {
g_prefix_error(error, "failed to connect to powerd: "); g_prefix_error(error, "failed to connect to powerd: ");
return FALSE; return FALSE;
} }
name_owner = g_dbus_proxy_get_name_owner(data->proxy); name_owner = g_dbus_proxy_get_name_owner(priv->proxy);
if (name_owner == NULL) { if (name_owner == NULL) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"no service that owns the name for %s", "no service that owns the name for %s",
g_dbus_proxy_get_name(data->proxy)); g_dbus_proxy_get_name(priv->proxy));
return FALSE; return FALSE;
} }
fu_plugin_powerd_rescan(plugin, fu_plugin_powerd_rescan(plugin,
g_dbus_proxy_call_sync(data->proxy, g_dbus_proxy_call_sync(priv->proxy,
"GetBatteryState", "GetBatteryState",
NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
@ -136,7 +136,7 @@ fu_plugin_powerd_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
NULL, NULL,
G_SOURCE_REMOVE)); G_SOURCE_REMOVE));
g_signal_connect(G_DBUS_PROXY(data->proxy), g_signal_connect(G_DBUS_PROXY(priv->proxy),
"g-signal", "g-signal",
G_CALLBACK(fu_plugin_powerd_proxy_changed_cb), G_CALLBACK(fu_plugin_powerd_proxy_changed_cb),
plugin); plugin);

View File

@ -42,7 +42,7 @@ fu_common_generate_password(guint length)
static gboolean static gboolean
fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error) fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *password_new = fu_common_generate_password(15); g_autofree gchar *password_new = fu_common_generate_password(15);
g_autofree gchar *uri = NULL; g_autofree gchar *uri = NULL;
g_autoptr(FuRedfishRequest) request = NULL; g_autoptr(FuRedfishRequest) request = NULL;
@ -57,7 +57,7 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error)
} }
/* now use Redfish to change the temporary password to the actual password */ /* now use Redfish to change the temporary password to the actual password */
request = fu_redfish_backend_request_new(data->backend); request = fu_redfish_backend_request_new(priv->backend);
json_builder_begin_object(builder); json_builder_begin_object(builder);
json_builder_set_member_name(builder, "Password"); json_builder_set_member_name(builder, "Password");
json_builder_add_string_value(builder, password_new); json_builder_add_string_value(builder, password_new);
@ -69,7 +69,7 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error)
FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON, FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON,
error)) error))
return FALSE; return FALSE;
fu_redfish_backend_set_password(data->backend, password_new); fu_redfish_backend_set_password(priv->backend, password_new);
/* success */ /* success */
return fu_plugin_set_secure_config_value(plugin, "Password", password_new, error); return fu_plugin_set_secure_config_value(plugin, "Password", password_new, error);
@ -78,17 +78,17 @@ fu_plugin_redfish_change_expired(FuPlugin *plugin, GError **error)
static gboolean static gboolean
fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GPtrArray) devices = NULL; g_autoptr(GPtrArray) devices = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
/* get the list of devices */ /* get the list of devices */
if (!fu_backend_coldplug(FU_BACKEND(data->backend), progress, &error_local)) { if (!fu_backend_coldplug(FU_BACKEND(priv->backend), progress, &error_local)) {
/* did the user password expire? */ /* did the user password expire? */
if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_AUTH_EXPIRED)) { if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_AUTH_EXPIRED)) {
if (!fu_plugin_redfish_change_expired(plugin, error)) if (!fu_plugin_redfish_change_expired(plugin, error))
return FALSE; return FALSE;
if (!fu_backend_coldplug(FU_BACKEND(data->backend), progress, error)) { if (!fu_backend_coldplug(FU_BACKEND(priv->backend), progress, error)) {
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_AUTH_REQUIRED); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_AUTH_REQUIRED);
return FALSE; return FALSE;
} }
@ -97,7 +97,7 @@ fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **erro
return FALSE; return FALSE;
} }
} }
devices = fu_backend_get_devices(FU_BACKEND(data->backend)); devices = fu_backend_get_devices(FU_BACKEND(priv->backend));
for (guint i = 0; i < devices->len; i++) { for (guint i = 0; i < devices->len; i++) {
FuDevice *device = g_ptr_array_index(devices, i); FuDevice *device = g_ptr_array_index(devices, i);
if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "reset-required")) if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "reset-required"))
@ -116,7 +116,7 @@ fu_plugin_redfish_coldplug(FuPlugin *plugin, FuProgress *progress, GError **erro
static gboolean static gboolean
fu_redfish_plugin_discover_uefi_credentials(FuPlugin *plugin, GError **error) fu_redfish_plugin_discover_uefi_credentials(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gsize bufsz = 0; gsize bufsz = 0;
guint32 indications = 0x0; guint32 indications = 0x0;
g_autofree gchar *userpass_safe = NULL; g_autofree gchar *userpass_safe = NULL;
@ -161,15 +161,15 @@ fu_redfish_plugin_discover_uefi_credentials(FuPlugin *plugin, GError **error)
userpass_safe); userpass_safe);
return FALSE; return FALSE;
} }
fu_redfish_backend_set_username(data->backend, split[0]); fu_redfish_backend_set_username(priv->backend, split[0]);
fu_redfish_backend_set_password(data->backend, split[1]); fu_redfish_backend_set_password(priv->backend, split[1]);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_redfish_plugin_discover_smbios_table(FuPlugin *plugin, GError **error) fu_redfish_plugin_discover_smbios_table(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
const gchar *smbios_data_fn; const gchar *smbios_data_fn;
g_autoptr(FuRedfishSmbios) smbios = fu_redfish_smbios_new(); g_autoptr(FuRedfishSmbios) smbios = fu_redfish_smbios_new();
@ -192,27 +192,27 @@ fu_redfish_plugin_discover_smbios_table(FuPlugin *plugin, GError **error)
} }
/* success */ /* success */
g_set_object(&data->smbios, smbios); g_set_object(&priv->smbios, smbios);
return TRUE; return TRUE;
} }
static gboolean static gboolean
fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error) fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *hostname = NULL; g_autofree gchar *hostname = NULL;
g_autoptr(FuRedfishNetworkDevice) device = NULL; g_autoptr(FuRedfishNetworkDevice) device = NULL;
/* we have no data */ /* we have no data */
if (data->smbios == NULL) if (priv->smbios == NULL)
return TRUE; return TRUE;
/* get IP, falling back to hostname, then MAC, then VID:PID */ /* get IP, falling back to hostname, then MAC, then VID:PID */
hostname = g_strdup(fu_redfish_smbios_get_ip_addr(data->smbios)); hostname = g_strdup(fu_redfish_smbios_get_ip_addr(priv->smbios));
if (hostname == NULL) if (hostname == NULL)
hostname = g_strdup(fu_redfish_smbios_get_hostname(data->smbios)); hostname = g_strdup(fu_redfish_smbios_get_hostname(priv->smbios));
if (device == NULL) { if (device == NULL) {
const gchar *mac_addr = fu_redfish_smbios_get_mac_addr(data->smbios); const gchar *mac_addr = fu_redfish_smbios_get_mac_addr(priv->smbios);
if (mac_addr != NULL) { if (mac_addr != NULL) {
g_autoptr(GError) error_network = NULL; g_autoptr(GError) error_network = NULL;
device = fu_redfish_network_device_for_mac_addr(mac_addr, &error_network); device = fu_redfish_network_device_for_mac_addr(mac_addr, &error_network);
@ -221,8 +221,8 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error)
} }
} }
if (device == NULL) { if (device == NULL) {
guint16 vid = fu_redfish_smbios_get_vid(data->smbios); guint16 vid = fu_redfish_smbios_get_vid(priv->smbios);
guint16 pid = fu_redfish_smbios_get_pid(data->smbios); guint16 pid = fu_redfish_smbios_get_pid(priv->smbios);
if (vid != 0x0 && pid != 0x0) { if (vid != 0x0 && pid != 0x0) {
g_autoptr(GError) error_network = NULL; g_autoptr(GError) error_network = NULL;
device = fu_redfish_network_device_for_vid_pid(vid, pid, &error_network); device = fu_redfish_network_device_for_vid_pid(vid, pid, &error_network);
@ -255,8 +255,8 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error)
g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE, "no hostname"); g_set_error_literal(error, FWUPD_ERROR, FWUPD_ERROR_INVALID_FILE, "no hostname");
return FALSE; return FALSE;
} }
fu_redfish_backend_set_hostname(data->backend, hostname); fu_redfish_backend_set_hostname(priv->backend, hostname);
fu_redfish_backend_set_port(data->backend, fu_redfish_smbios_get_port(data->smbios)); fu_redfish_backend_set_port(priv->backend, fu_redfish_smbios_get_port(priv->smbios));
return TRUE; return TRUE;
} }
@ -265,7 +265,7 @@ fu_redfish_plugin_autoconnect_network_device(FuPlugin *plugin, GError **error)
static gboolean static gboolean
fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error) fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *username_fwupd = "fwupd"; const gchar *username_fwupd = "fwupd";
guint8 user_id = G_MAXUINT8; guint8 user_id = G_MAXUINT8;
g_autofree gchar *password_new = fu_common_generate_password(15); g_autofree gchar *password_new = fu_common_generate_password(15);
@ -315,14 +315,14 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
return FALSE; return FALSE;
if (!fu_ipmi_device_set_user_password(device, user_id, password_tmp, error)) if (!fu_ipmi_device_set_user_password(device, user_id, password_tmp, error))
return FALSE; return FALSE;
fu_redfish_backend_set_username(data->backend, username_fwupd); fu_redfish_backend_set_username(priv->backend, username_fwupd);
fu_redfish_backend_set_password(data->backend, password_tmp); fu_redfish_backend_set_password(priv->backend, password_tmp);
/* wait for Redfish to sync */ /* wait for Redfish to sync */
g_usleep(2 * G_USEC_PER_SEC); g_usleep(2 * G_USEC_PER_SEC);
/* now use Redfish to change the temporary password to the actual password */ /* now use Redfish to change the temporary password to the actual password */
request = fu_redfish_backend_request_new(data->backend); request = fu_redfish_backend_request_new(priv->backend);
uri = g_strdup_printf("/redfish/v1/AccountService/Accounts/%u", (guint)user_id - 1); uri = g_strdup_printf("/redfish/v1/AccountService/Accounts/%u", (guint)user_id - 1);
json_builder_begin_object(builder); json_builder_begin_object(builder);
json_builder_set_member_name(builder, "Password"); json_builder_set_member_name(builder, "Password");
@ -335,7 +335,7 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON, FU_REDFISH_REQUEST_PERFORM_FLAG_LOAD_JSON,
error)) error))
return FALSE; return FALSE;
fu_redfish_backend_set_password(data->backend, password_new); fu_redfish_backend_set_password(priv->backend, password_new);
/* success */ /* success */
if (!fu_plugin_set_secure_config_value(plugin, "UserUri", uri, error)) if (!fu_plugin_set_secure_config_value(plugin, "UserUri", uri, error))
@ -352,7 +352,7 @@ fu_redfish_plugin_ipmi_create_user(FuPlugin *plugin, GError **error)
static gboolean static gboolean
fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *ca_check_str = NULL; g_autofree gchar *ca_check_str = NULL;
g_autofree gchar *password = NULL; g_autofree gchar *password = NULL;
g_autofree gchar *redfish_uri = NULL; g_autofree gchar *redfish_uri = NULL;
@ -377,11 +377,11 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error
guint64 port = 0; guint64 port = 0;
if (g_str_has_prefix(redfish_uri, "https://")) { if (g_str_has_prefix(redfish_uri, "https://")) {
fu_redfish_backend_set_https(data->backend, TRUE); fu_redfish_backend_set_https(priv->backend, TRUE);
ip_str = redfish_uri + strlen("https://"); ip_str = redfish_uri + strlen("https://");
port = 443; port = 443;
} else if (g_str_has_prefix(redfish_uri, "http://")) { } else if (g_str_has_prefix(redfish_uri, "http://")) {
fu_redfish_backend_set_https(data->backend, FALSE); fu_redfish_backend_set_https(priv->backend, FALSE);
ip_str = redfish_uri + strlen("http://"); ip_str = redfish_uri + strlen("http://");
port = 80; port = 80;
} else { } else {
@ -393,7 +393,7 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error
} }
split = g_strsplit(ip_str, ":", 2); split = g_strsplit(ip_str, ":", 2);
fu_redfish_backend_set_hostname(data->backend, split[0]); fu_redfish_backend_set_hostname(priv->backend, split[0]);
if (g_strv_length(split) > 1) if (g_strv_length(split) > 1)
port = g_ascii_strtoull(split[1], NULL, 10); port = g_ascii_strtoull(split[1], NULL, 10);
if (port == 0 || port == G_MAXUINT64) { if (port == 0 || port == G_MAXUINT64) {
@ -403,25 +403,25 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error
"no valid port specified"); "no valid port specified");
return FALSE; return FALSE;
} }
fu_redfish_backend_set_port(data->backend, port); fu_redfish_backend_set_port(priv->backend, port);
} }
username = fu_plugin_get_config_value(plugin, "Username"); username = fu_plugin_get_config_value(plugin, "Username");
if (username != NULL) if (username != NULL)
fu_redfish_backend_set_username(data->backend, username); fu_redfish_backend_set_username(priv->backend, username);
password = fu_plugin_get_config_value(plugin, "Password"); password = fu_plugin_get_config_value(plugin, "Password");
if (password != NULL) if (password != NULL)
fu_redfish_backend_set_password(data->backend, password); fu_redfish_backend_set_password(priv->backend, password);
ca_check_str = fu_plugin_get_config_value(plugin, "CACheck"); ca_check_str = fu_plugin_get_config_value(plugin, "CACheck");
if (ca_check_str != NULL) { if (ca_check_str != NULL) {
gboolean ca_check = fu_plugin_get_config_value_boolean(plugin, "CACheck"); gboolean ca_check = fu_plugin_get_config_value_boolean(plugin, "CACheck");
fu_redfish_backend_set_cacheck(data->backend, ca_check); fu_redfish_backend_set_cacheck(priv->backend, ca_check);
} }
if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "wildcard-targets")) if (fu_context_has_hwid_flag(fu_plugin_get_context(plugin), "wildcard-targets"))
fu_redfish_backend_set_wildcard_targets(data->backend, TRUE); fu_redfish_backend_set_wildcard_targets(priv->backend, TRUE);
#ifdef HAVE_LINUX_IPMI_H #ifdef HAVE_LINUX_IPMI_H
/* we got neither a type 42 entry or config value, lets try IPMI */ /* we got neither a type 42 entry or config value, lets try IPMI */
if (fu_redfish_backend_get_username(data->backend) == NULL) { if (fu_redfish_backend_get_username(priv->backend) == NULL) {
if (!fu_plugin_get_config_value_boolean(plugin, "IpmiDisableCreateUser")) { if (!fu_plugin_get_config_value_boolean(plugin, "IpmiDisableCreateUser")) {
g_debug("attempting to create user using IPMI"); g_debug("attempting to create user using IPMI");
if (!fu_redfish_plugin_ipmi_create_user(plugin, error)) if (!fu_redfish_plugin_ipmi_create_user(plugin, error))
@ -430,20 +430,20 @@ fu_plugin_redfish_startup(FuPlugin *plugin, FuProgress *progress, GError **error
} }
#endif #endif
return fu_backend_setup(FU_BACKEND(data->backend), progress, error); return fu_backend_setup(FU_BACKEND(priv->backend), progress, error);
} }
static gboolean static gboolean
fu_plugin_redfish_cleanup_setup_cb(FuDevice *device, gpointer user_data, GError **error) fu_plugin_redfish_cleanup_setup_cb(FuDevice *device, gpointer user_data, GError **error)
{ {
FuPlugin *self = FU_PLUGIN(user_data); FuPlugin *self = FU_PLUGIN(user_data);
FuPluginData *data = fu_plugin_get_data(self); FuPluginData *priv = fu_plugin_get_data(self);
FuProgress *progress = fu_progress_new(G_STRLOC); FuProgress *progress = fu_progress_new(G_STRLOC);
/* the network adaptor might not autoconnect when coming back */ /* the network adaptor might not autoconnect when coming back */
if (!fu_redfish_plugin_autoconnect_network_device(self, error)) if (!fu_redfish_plugin_autoconnect_network_device(self, error))
return FALSE; return FALSE;
return fu_backend_setup(FU_BACKEND(data->backend), progress, error); return fu_backend_setup(FU_BACKEND(priv->backend), progress, error);
} }
static gboolean static gboolean
@ -463,10 +463,10 @@ fu_plugin_redfish_cleanup(FuPlugin *self,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(self); FuPluginData *priv = fu_plugin_get_data(self);
guint64 reset_timeout = 0; guint64 reset_timeout = 0;
g_autofree gchar *restart_timeout_str = NULL; g_autofree gchar *restart_timeout_str = NULL;
g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(data->backend); g_autoptr(FuRedfishRequest) request = fu_redfish_backend_request_new(priv->backend);
g_autoptr(JsonBuilder) builder = json_builder_new(); g_autoptr(JsonBuilder) builder = json_builder_new();
g_autoptr(GPtrArray) devices = NULL; g_autoptr(GPtrArray) devices = NULL;
@ -499,14 +499,14 @@ fu_plugin_redfish_cleanup(FuPlugin *self,
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* remove all the devices */ /* remove all the devices */
devices = fu_backend_get_devices(FU_BACKEND(data->backend)); devices = fu_backend_get_devices(FU_BACKEND(priv->backend));
for (guint i = 0; i < devices->len; i++) { for (guint i = 0; i < devices->len; i++) {
FuDevice *device_tmp = g_ptr_array_index(devices, i); FuDevice *device_tmp = g_ptr_array_index(devices, i);
fu_backend_device_removed(FU_BACKEND(data->backend), device_tmp); fu_backend_device_removed(FU_BACKEND(priv->backend), device_tmp);
} }
/* work around manager bugs... */ /* work around manager bugs... */
fu_backend_invalidate(FU_BACKEND(data->backend)); fu_backend_invalidate(FU_BACKEND(priv->backend));
if (fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device)) > 0) { if (fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device)) > 0) {
fu_progress_sleep(fu_progress_get_child(progress), fu_progress_sleep(fu_progress_get_child(progress),
fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device))); fu_redfish_device_get_reset_pre_delay(FU_REDFISH_DEVICE(device)));
@ -569,18 +569,18 @@ static void
fu_plugin_redfish_init(FuPlugin *plugin) fu_plugin_redfish_init(FuPlugin *plugin)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData));
data->backend = fu_redfish_backend_new(ctx); priv->backend = fu_redfish_backend_new(ctx);
fu_plugin_add_firmware_gtype(plugin, NULL, FU_TYPE_REDFISH_SMBIOS); fu_plugin_add_firmware_gtype(plugin, NULL, FU_TYPE_REDFISH_SMBIOS);
} }
static void static void
fu_plugin_redfish_destroy(FuPlugin *plugin) fu_plugin_redfish_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->smbios != NULL) if (priv->smbios != NULL)
g_object_unref(data->smbios); g_object_unref(priv->smbios);
g_object_unref(data->backend); g_object_unref(priv->backend);
} }
void void

View File

@ -24,14 +24,14 @@ fu_plugin_test_init(FuPlugin *plugin)
static void static void
fu_plugin_test_destroy(FuPlugin *plugin) fu_plugin_test_destroy(FuPlugin *plugin)
{ {
// FuPluginData *data = fu_plugin_get_data (plugin); // FuPluginData *priv = fu_plugin_get_data (plugin);
g_debug("destroy"); g_debug("destroy");
} }
static gboolean static gboolean
fu_plugin_test_load_xml(FuPlugin *plugin, const gchar *xml, GError **error) fu_plugin_test_load_xml(FuPlugin *plugin, const gchar *xml, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(XbBuilder) builder = xb_builder_new(); g_autoptr(XbBuilder) builder = xb_builder_new();
g_autoptr(XbBuilderSource) source = xb_builder_source_new(); g_autoptr(XbBuilderSource) source = xb_builder_source_new();
g_autoptr(XbNode) delay_decompress_ms = NULL; g_autoptr(XbNode) delay_decompress_ms = NULL;
@ -50,13 +50,13 @@ fu_plugin_test_load_xml(FuPlugin *plugin, const gchar *xml, GError **error)
/* parse markup */ /* parse markup */
delay_decompress_ms = xb_silo_query_first(silo, "config/delay_decompress_ms", NULL); delay_decompress_ms = xb_silo_query_first(silo, "config/delay_decompress_ms", NULL);
if (delay_decompress_ms != NULL) if (delay_decompress_ms != NULL)
data->delay_decompress_ms = xb_node_get_text_as_uint(delay_decompress_ms); priv->delay_decompress_ms = xb_node_get_text_as_uint(delay_decompress_ms);
delay_write_ms = xb_silo_query_first(silo, "config/delay_write_ms", NULL); delay_write_ms = xb_silo_query_first(silo, "config/delay_write_ms", NULL);
if (delay_write_ms != NULL) if (delay_write_ms != NULL)
data->delay_write_ms = xb_node_get_text_as_uint(delay_write_ms); priv->delay_write_ms = xb_node_get_text_as_uint(delay_write_ms);
delay_verify_ms = xb_silo_query_first(silo, "config/delay_verify_ms", NULL); delay_verify_ms = xb_silo_query_first(silo, "config/delay_verify_ms", NULL);
if (delay_verify_ms != NULL) if (delay_verify_ms != NULL)
data->delay_verify_ms = xb_node_get_text_as_uint(delay_verify_ms); priv->delay_verify_ms = xb_node_get_text_as_uint(delay_verify_ms);
/* success */ /* success */
return TRUE; return TRUE;
@ -211,7 +211,7 @@ fu_plugin_test_write_firmware(FuPlugin *plugin,
FwupdInstallFlags flags, FwupdInstallFlags flags,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *test = g_getenv("FWUPD_PLUGIN_TEST"); const gchar *test = g_getenv("FWUPD_PLUGIN_TEST");
gboolean requires_activation = g_strcmp0(test, "requires-activation") == 0; gboolean requires_activation = g_strcmp0(test, "requires-activation") == 0;
gboolean requires_reboot = g_strcmp0(test, "requires-reboot") == 0; gboolean requires_reboot = g_strcmp0(test, "requires-reboot") == 0;
@ -223,19 +223,19 @@ fu_plugin_test_write_firmware(FuPlugin *plugin,
return FALSE; return FALSE;
} }
fu_progress_set_status(progress, FWUPD_STATUS_DECOMPRESSING); fu_progress_set_status(progress, FWUPD_STATUS_DECOMPRESSING);
for (guint i = 0; i <= data->delay_decompress_ms; i++) { for (guint i = 0; i <= priv->delay_decompress_ms; i++) {
g_usleep(1000); g_usleep(1000);
fu_progress_set_percentage_full(progress, i, data->delay_decompress_ms); fu_progress_set_percentage_full(progress, i, priv->delay_decompress_ms);
} }
fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_WRITE); fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_WRITE);
for (guint i = 0; i <= data->delay_write_ms; i++) { for (guint i = 0; i <= priv->delay_write_ms; i++) {
g_usleep(1000); g_usleep(1000);
fu_progress_set_percentage_full(progress, i, data->delay_write_ms); fu_progress_set_percentage_full(progress, i, priv->delay_write_ms);
} }
fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_VERIFY); fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_VERIFY);
for (guint i = 0; i <= data->delay_verify_ms; i++) { for (guint i = 0; i <= priv->delay_verify_ms; i++) {
g_usleep(1000); g_usleep(1000);
fu_progress_set_percentage_full(progress, i, data->delay_verify_ms); fu_progress_set_percentage_full(progress, i, priv->delay_verify_ms);
} }
/* composite test, upgrade composite devices */ /* composite test, upgrade composite devices */

View File

@ -30,44 +30,44 @@ fu_plugin_tpm_init(FuPlugin *plugin)
static void static void
fu_plugin_tpm_destroy(FuPlugin *plugin) fu_plugin_tpm_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->tpm_device != NULL) if (priv->tpm_device != NULL)
g_object_unref(data->tpm_device); g_object_unref(priv->tpm_device);
if (data->bios_device != NULL) if (priv->bios_device != NULL)
g_object_unref(data->bios_device); g_object_unref(priv->bios_device);
if (data->ev_items != NULL) if (priv->ev_items != NULL)
g_ptr_array_unref(data->ev_items); g_ptr_array_unref(priv->ev_items);
} }
static void static void
fu_plugin_tpm_set_bios_pcr0s(FuPlugin *plugin) fu_plugin_tpm_set_bios_pcr0s(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GPtrArray) pcr0s = NULL; g_autoptr(GPtrArray) pcr0s = NULL;
if (data->tpm_device == NULL) if (priv->tpm_device == NULL)
return; return;
if (data->bios_device == NULL) if (priv->bios_device == NULL)
return; return;
/* add all the PCR0s */ /* add all the PCR0s */
pcr0s = fu_tpm_device_get_checksums(data->tpm_device, 0); pcr0s = fu_tpm_device_get_checksums(priv->tpm_device, 0);
if (pcr0s->len == 0) if (pcr0s->len == 0)
return; return;
for (guint i = 0; i < pcr0s->len; i++) { for (guint i = 0; i < pcr0s->len; i++) {
const gchar *checksum = g_ptr_array_index(pcr0s, i); const gchar *checksum = g_ptr_array_index(pcr0s, i);
fu_device_add_checksum(data->bios_device, checksum); fu_device_add_checksum(priv->bios_device, checksum);
} }
fu_device_add_flag(data->bios_device, FWUPD_DEVICE_FLAG_CAN_VERIFY); fu_device_add_flag(priv->bios_device, FWUPD_DEVICE_FLAG_CAN_VERIFY);
} }
/* set the PCR0 as the device checksum */ /* set the PCR0 as the device checksum */
static void static void
fu_plugin_tpm_device_registered(FuPlugin *plugin, FuDevice *device) fu_plugin_tpm_device_registered(FuPlugin *plugin, FuDevice *device)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (fu_device_has_instance_id(device, "main-system-firmware")) { if (fu_device_has_instance_id(device, "main-system-firmware")) {
g_set_object(&data->bios_device, device); g_set_object(&priv->bios_device, device);
fu_plugin_tpm_set_bios_pcr0s(plugin); fu_plugin_tpm_set_bios_pcr0s(plugin);
} }
} }
@ -75,10 +75,10 @@ fu_plugin_tpm_device_registered(FuPlugin *plugin, FuDevice *device)
static void static void
fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev) fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GPtrArray) pcr0s = NULL; g_autoptr(GPtrArray) pcr0s = NULL;
g_set_object(&data->tpm_device, FU_TPM_DEVICE(dev)); g_set_object(&priv->tpm_device, FU_TPM_DEVICE(dev));
fu_plugin_add_report_metadata(plugin, fu_plugin_add_report_metadata(plugin,
"TpmFamily", "TpmFamily",
fu_tpm_device_get_family(FU_TPM_DEVICE(dev))); fu_tpm_device_get_family(FU_TPM_DEVICE(dev)));
@ -87,7 +87,7 @@ fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev)
fu_plugin_tpm_set_bios_pcr0s(plugin); fu_plugin_tpm_set_bios_pcr0s(plugin);
/* add extra plugin metadata */ /* add extra plugin metadata */
pcr0s = fu_tpm_device_get_checksums(data->tpm_device, 0); pcr0s = fu_tpm_device_get_checksums(priv->tpm_device, 0);
for (guint i = 0; i < pcr0s->len; i++) { for (guint i = 0; i < pcr0s->len; i++) {
const gchar *csum = g_ptr_array_index(pcr0s, i); const gchar *csum = g_ptr_array_index(pcr0s, i);
GChecksumType csum_type = fwupd_checksum_guess_kind(csum); GChecksumType csum_type = fwupd_checksum_guess_kind(csum);
@ -105,7 +105,7 @@ fu_plugin_tpm_device_added(FuPlugin *plugin, FuDevice *dev)
static void static void
fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
/* create attr */ /* create attr */
@ -115,17 +115,17 @@ fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
/* check exists, and in v2.0 mode */ /* check exists, and in v2.0 mode */
if (data->tpm_device == NULL) { if (priv->tpm_device == NULL) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND);
return; return;
} }
if (g_strcmp0(fu_tpm_device_get_family(data->tpm_device), "2.0") != 0) { if (g_strcmp0(fu_tpm_device_get_family(priv->tpm_device), "2.0") != 0) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED);
return; return;
} }
/* success */ /* success */
fwupd_security_attr_add_guids(attr, fu_device_get_guids(FU_DEVICE(data->tpm_device))); fwupd_security_attr_add_guids(attr, fu_device_get_guids(FU_DEVICE(priv->tpm_device)));
fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS); fwupd_security_attr_add_flag(attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS);
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_FOUND); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_FOUND);
} }
@ -133,7 +133,7 @@ fu_plugin_tpm_add_security_attr_version(FuPlugin *plugin, FuSecurityAttrs *attrs
static void static void
fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gboolean reconstructed = TRUE; gboolean reconstructed = TRUE;
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -141,24 +141,24 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr
g_autoptr(GPtrArray) pcr0s_real = NULL; g_autoptr(GPtrArray) pcr0s_real = NULL;
/* no TPM device */ /* no TPM device */
if (data->tpm_device == NULL) if (priv->tpm_device == NULL)
return; return;
/* create attr */ /* create attr */
attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_RECONSTRUCTION_PCR0); attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_RECONSTRUCTION_PCR0);
fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin));
fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_IMPORTANT); fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_IMPORTANT);
fwupd_security_attr_add_guids(attr, fu_device_get_guids(data->tpm_device)); fwupd_security_attr_add_guids(attr, fu_device_get_guids(priv->tpm_device));
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
/* check reconstructed to PCR0 */ /* check reconstructed to PCR0 */
if (data->ev_items == NULL || data->bios_device == NULL) { if (priv->ev_items == NULL || priv->bios_device == NULL) {
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND);
return; return;
} }
/* calculate from the eventlog */ /* calculate from the eventlog */
pcr0s_calc = fu_tpm_eventlog_calc_checksums(data->ev_items, 0, &error); pcr0s_calc = fu_tpm_eventlog_calc_checksums(priv->ev_items, 0, &error);
if (pcr0s_calc == NULL) { if (pcr0s_calc == NULL) {
g_warning("failed to get eventlog reconstruction: %s", error->message); g_warning("failed to get eventlog reconstruction: %s", error->message);
fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID); fwupd_security_attr_set_result(attr, FWUPD_SECURITY_ATTR_RESULT_NOT_VALID);
@ -166,7 +166,7 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr
} }
/* compare against the real PCR0s */ /* compare against the real PCR0s */
pcr0s_real = fu_tpm_device_get_checksums(data->tpm_device, 0); pcr0s_real = fu_tpm_device_get_checksums(priv->tpm_device, 0);
for (guint i = 0; i < pcr0s_real->len; i++) { for (guint i = 0; i < pcr0s_real->len; i++) {
const gchar *checksum = g_ptr_array_index(pcr0s_real, i); const gchar *checksum = g_ptr_array_index(pcr0s_real, i);
reconstructed = FALSE; reconstructed = FALSE;
@ -198,23 +198,23 @@ fu_plugin_tpm_add_security_attr_eventlog(FuPlugin *plugin, FuSecurityAttrs *attr
static void static void
fu_plugin_tpm_add_security_attr_empty(FuPlugin *plugin, FuSecurityAttrs *attrs) fu_plugin_tpm_add_security_attr_empty(FuPlugin *plugin, FuSecurityAttrs *attrs)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FwupdSecurityAttr) attr = NULL; g_autoptr(FwupdSecurityAttr) attr = NULL;
/* no TPM device */ /* no TPM device */
if (data->tpm_device == NULL) if (priv->tpm_device == NULL)
return; return;
/* add attributes */ /* add attributes */
attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_EMPTY_PCR); attr = fwupd_security_attr_new(FWUPD_SECURITY_ATTR_ID_TPM_EMPTY_PCR);
fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin)); fwupd_security_attr_set_plugin(attr, fu_plugin_get_name(plugin));
fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_CRITICAL); fwupd_security_attr_set_level(attr, FWUPD_SECURITY_ATTR_LEVEL_CRITICAL);
fwupd_security_attr_add_guids(attr, fu_device_get_guids(data->tpm_device)); fwupd_security_attr_add_guids(attr, fu_device_get_guids(priv->tpm_device));
fu_security_attrs_append(attrs, attr); fu_security_attrs_append(attrs, attr);
/* check PCRs 0 through 7 for empty checksums */ /* check PCRs 0 through 7 for empty checksums */
for (guint pcr = 0; pcr <= 7; pcr++) { for (guint pcr = 0; pcr <= 7; pcr++) {
g_autoptr(GPtrArray) checksums = fu_tpm_device_get_checksums(data->tpm_device, pcr); g_autoptr(GPtrArray) checksums = fu_tpm_device_get_checksums(priv->tpm_device, pcr);
for (guint i = 0; i < checksums->len; i++) { for (guint i = 0; i < checksums->len; i++) {
const gchar *checksum = g_ptr_array_index(checksums, i); const gchar *checksum = g_ptr_array_index(checksums, i);
gboolean empty = TRUE; gboolean empty = TRUE;
@ -253,12 +253,12 @@ fu_plugin_tpm_add_security_attrs(FuPlugin *plugin, FuSecurityAttrs *attrs)
static gchar * static gchar *
fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin) fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
GString *str = g_string_new(""); GString *str = g_string_new("");
g_autoptr(GPtrArray) pcrs = NULL; g_autoptr(GPtrArray) pcrs = NULL;
for (guint i = 0; i < data->ev_items->len; i++) { for (guint i = 0; i < priv->ev_items->len; i++) {
FuTpmEventlogItem *item = g_ptr_array_index(data->ev_items, i); FuTpmEventlogItem *item = g_ptr_array_index(priv->ev_items, i);
g_autofree gchar *blobstr = NULL; g_autofree gchar *blobstr = NULL;
g_autofree gchar *checksum = NULL; g_autofree gchar *checksum = NULL;
@ -276,7 +276,7 @@ fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin)
g_string_append_printf(str, " [%s]", blobstr); g_string_append_printf(str, " [%s]", blobstr);
g_string_append(str, "\n"); g_string_append(str, "\n");
} }
pcrs = fu_tpm_eventlog_calc_checksums(data->ev_items, 0, NULL); pcrs = fu_tpm_eventlog_calc_checksums(priv->ev_items, 0, NULL);
if (pcrs != NULL) { if (pcrs != NULL) {
for (guint j = 0; j < pcrs->len; j++) { for (guint j = 0; j < pcrs->len; j++) {
const gchar *csum = g_ptr_array_index(pcrs, j); const gchar *csum = g_ptr_array_index(pcrs, j);
@ -291,7 +291,7 @@ fu_plugin_tpm_eventlog_report_metadata(FuPlugin *plugin)
static gboolean static gboolean
fu_plugin_tpm_coldplug_eventlog(FuPlugin *plugin, GError **error) fu_plugin_tpm_coldplug_eventlog(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
gsize bufsz = 0; gsize bufsz = 0;
const gchar *fn = "/sys/kernel/security/tpm0/binary_bios_measurements"; const gchar *fn = "/sys/kernel/security/tpm0/binary_bios_measurements";
g_autofree gchar *str = NULL; g_autofree gchar *str = NULL;
@ -312,9 +312,9 @@ fu_plugin_tpm_coldplug_eventlog(FuPlugin *plugin, GError **error)
fn); fn);
return FALSE; return FALSE;
} }
data->ev_items = priv->ev_items =
fu_tpm_eventlog_parser_new(buf, bufsz, FU_TPM_EVENTLOG_PARSER_FLAG_NONE, error); fu_tpm_eventlog_parser_new(buf, bufsz, FU_TPM_EVENTLOG_PARSER_FLAG_NONE, error);
if (data->ev_items == NULL) if (priv->ev_items == NULL)
return FALSE; return FALSE;
/* add optional report metadata */ /* add optional report metadata */
@ -339,7 +339,7 @@ fu_plugin_tpm_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error)
static gboolean static gboolean
fu_plugin_tpm_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_tpm_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *sysfstpmdir = NULL; g_autofree gchar *sysfstpmdir = NULL;
g_autofree gchar *fn_pcrs = NULL; g_autofree gchar *fn_pcrs = NULL;
@ -347,12 +347,12 @@ fu_plugin_tpm_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
sysfstpmdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_TPM); sysfstpmdir = fu_path_from_kind(FU_PATH_KIND_SYSFSDIR_TPM);
fn_pcrs = g_build_filename(sysfstpmdir, "tpm0", "pcrs", NULL); fn_pcrs = g_build_filename(sysfstpmdir, "tpm0", "pcrs", NULL);
if (g_file_test(fn_pcrs, G_FILE_TEST_EXISTS) && g_getenv("FWUPD_FORCE_TPM2") == NULL) { if (g_file_test(fn_pcrs, G_FILE_TEST_EXISTS) && g_getenv("FWUPD_FORCE_TPM2") == NULL) {
data->tpm_device = fu_tpm_v1_device_new(fu_plugin_get_context(plugin)); priv->tpm_device = fu_tpm_v1_device_new(fu_plugin_get_context(plugin));
g_object_set(data->tpm_device, "device-file", fn_pcrs, NULL); g_object_set(priv->tpm_device, "device-file", fn_pcrs, NULL);
fu_device_set_physical_id(FU_DEVICE(data->tpm_device), "tpm"); fu_device_set_physical_id(FU_DEVICE(priv->tpm_device), "tpm");
if (!fu_device_probe(FU_DEVICE(data->tpm_device), error)) if (!fu_device_probe(FU_DEVICE(priv->tpm_device), error))
return FALSE; return FALSE;
fu_plugin_device_add(plugin, FU_DEVICE(data->tpm_device)); fu_plugin_device_add(plugin, FU_DEVICE(priv->tpm_device));
} }
/* success */ /* success */

View File

@ -30,7 +30,7 @@ struct FuPluginData {
static gboolean static gboolean
fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error) fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
const guint8 needle[] = "f\0w\0u\0p\0d\0-\0e\0f\0i\0 \0v\0e\0r\0s\0i\0o\0n\0 "; const guint8 needle[] = "f\0w\0u\0p\0d\0-\0e\0f\0i\0 \0v\0e\0r\0s\0i\0o\0n\0 ";
gsize bufsz = 0; gsize bufsz = 0;
@ -40,10 +40,10 @@ fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error)
g_autofree gchar *version = NULL; g_autofree gchar *version = NULL;
/* find the UTF-16 version string */ /* find the UTF-16 version string */
if (!g_file_load_contents(data->fwupd_efi_file, NULL, &buf, &bufsz, NULL, error)) if (!g_file_load_contents(priv->fwupd_efi_file, NULL, &buf, &bufsz, NULL, error))
return FALSE; return FALSE;
if (!fu_memmem_safe((const guint8 *)buf, bufsz, needle, sizeof(needle), &offset, error)) { if (!fu_memmem_safe((const guint8 *)buf, bufsz, needle, sizeof(needle), &offset, error)) {
g_autofree gchar *fn = g_file_get_path(data->fwupd_efi_file); g_autofree gchar *fn = g_file_get_path(priv->fwupd_efi_file);
g_prefix_error(error, "searching %s: ", fn); g_prefix_error(error, "searching %s: ", fn);
return FALSE; return FALSE;
} }
@ -62,7 +62,7 @@ fu_plugin_uefi_capsule_fwupd_efi_parse(FuPlugin *plugin, GError **error)
/* convert to UTF-8 */ /* convert to UTF-8 */
version = g_utf16_to_utf8(version_tmp, -1, NULL, NULL, error); version = g_utf16_to_utf8(version_tmp, -1, NULL, NULL, error);
if (version == NULL) { if (version == NULL) {
g_autofree gchar *fn = g_file_get_path(data->fwupd_efi_file); g_autofree gchar *fn = g_file_get_path(priv->fwupd_efi_file);
g_prefix_error(error, "converting %s: ", fn); g_prefix_error(error, "converting %s: ", fn);
return FALSE; return FALSE;
} }
@ -93,7 +93,7 @@ fu_plugin_uefi_capsule_fwupd_efi_changed_cb(GFileMonitor *monitor,
static gboolean static gboolean
fu_plugin_uefi_capsule_fwupd_efi_probe(FuPlugin *plugin, GError **error) fu_plugin_uefi_capsule_fwupd_efi_probe(FuPlugin *plugin, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
g_autofree gchar *fn = NULL; g_autofree gchar *fn = NULL;
@ -101,12 +101,12 @@ fu_plugin_uefi_capsule_fwupd_efi_probe(FuPlugin *plugin, GError **error)
fn = fu_uefi_get_built_app_path(error); fn = fu_uefi_get_built_app_path(error);
if (fn == NULL) if (fn == NULL)
return FALSE; return FALSE;
data->fwupd_efi_file = g_file_new_for_path(fn); priv->fwupd_efi_file = g_file_new_for_path(fn);
data->fwupd_efi_monitor = priv->fwupd_efi_monitor =
g_file_monitor_file(data->fwupd_efi_file, G_FILE_MONITOR_NONE, NULL, error); g_file_monitor_file(priv->fwupd_efi_file, G_FILE_MONITOR_NONE, NULL, error);
if (data->fwupd_efi_monitor == NULL) if (priv->fwupd_efi_monitor == NULL)
return FALSE; return FALSE;
g_signal_connect(G_FILE_MONITOR(data->fwupd_efi_monitor), g_signal_connect(G_FILE_MONITOR(priv->fwupd_efi_monitor),
"changed", "changed",
G_CALLBACK(fu_plugin_uefi_capsule_fwupd_efi_changed_cb), G_CALLBACK(fu_plugin_uefi_capsule_fwupd_efi_changed_cb),
plugin); plugin);
@ -121,11 +121,11 @@ static void
fu_plugin_uefi_capsule_init(FuPlugin *plugin) fu_plugin_uefi_capsule_init(FuPlugin *plugin)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_alloc_data(plugin, sizeof(FuPluginData)); FuPluginData *priv = fu_plugin_alloc_data(plugin, sizeof(FuPluginData));
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
data->backend = fu_uefi_backend_new(ctx); priv->backend = fu_uefi_backend_new(ctx);
data->bgrt = fu_uefi_bgrt_new(); priv->bgrt = fu_uefi_bgrt_new();
fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_RUN_AFTER, "upower");
fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "tpm"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "tpm");
fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "dell"); fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_METADATA_SOURCE, "dell");
@ -141,17 +141,17 @@ fu_plugin_uefi_capsule_init(FuPlugin *plugin)
static void static void
fu_plugin_uefi_capsule_destroy(FuPlugin *plugin) fu_plugin_uefi_capsule_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->esp != NULL) if (priv->esp != NULL)
g_object_unref(data->esp); g_object_unref(priv->esp);
if (data->fwupd_efi_file != NULL) if (priv->fwupd_efi_file != NULL)
g_object_unref(data->fwupd_efi_file); g_object_unref(priv->fwupd_efi_file);
if (data->fwupd_efi_monitor != NULL) { if (priv->fwupd_efi_monitor != NULL) {
g_file_monitor_cancel(data->fwupd_efi_monitor); g_file_monitor_cancel(priv->fwupd_efi_monitor);
g_object_unref(data->fwupd_efi_monitor); g_object_unref(priv->fwupd_efi_monitor);
} }
g_object_unref(data->backend); g_object_unref(priv->backend);
g_object_unref(data->bgrt); g_object_unref(priv->bgrt);
} }
static gboolean static gboolean
@ -240,7 +240,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin,
GBytes *blob, GBytes *blob,
GError **error) GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
guint32 screen_x, screen_y; guint32 screen_x, screen_y;
gsize buf_size = g_bytes_get_size(blob); gsize buf_size = g_bytes_get_size(blob);
gssize size; gssize size;
@ -272,7 +272,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin,
} }
/* save to a predicatable filename */ /* save to a predicatable filename */
esp_path = fu_volume_get_mount_point(data->esp); esp_path = fu_volume_get_mount_point(priv->esp);
directory = fu_uefi_get_esp_path_for_os(device, esp_path); directory = fu_uefi_get_esp_path_for_os(device, esp_path);
basename = g_strdup_printf("fwupd-%s.cap", FU_EFIVAR_GUID_UX_CAPSULE); basename = g_strdup_printf("fwupd-%s.cap", FU_EFIVAR_GUID_UX_CAPSULE);
fn = g_build_filename(directory, "fw", basename, NULL); fn = g_build_filename(directory, "fw", basename, NULL);
@ -296,11 +296,11 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin,
header.image_type = 0; header.image_type = 0;
header.reserved = 0; header.reserved = 0;
header.x_offset = (screen_x / 2) - (width / 2); header.x_offset = (screen_x / 2) - (width / 2);
if (screen_y == fu_uefi_bgrt_get_height(data->bgrt)) { if (screen_y == fu_uefi_bgrt_get_height(priv->bgrt)) {
header.y_offset = (gdouble)screen_y * 0.8f; header.y_offset = (gdouble)screen_y * 0.8f;
} else { } else {
header.y_offset = header.y_offset =
fu_uefi_bgrt_get_yoffset(data->bgrt) + fu_uefi_bgrt_get_height(data->bgrt); fu_uefi_bgrt_get_yoffset(priv->bgrt) + fu_uefi_bgrt_get_height(priv->bgrt);
}; };
/* header, payload and image has to add to zero */ /* header, payload and image has to add to zero */
@ -335,7 +335,7 @@ fu_plugin_uefi_capsule_write_splash_data(FuPlugin *plugin,
static gboolean static gboolean
fu_plugin_uefi_capsule_update_splash(FuPlugin *plugin, FuDevice *device, GError **error) fu_plugin_uefi_capsule_update_splash(FuPlugin *plugin, FuDevice *device, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
guint best_idx = G_MAXUINT; guint best_idx = G_MAXUINT;
guint32 lowest_border_pixels = G_MAXUINT; guint32 lowest_border_pixels = G_MAXUINT;
guint32 screen_height = 768; guint32 screen_height = 768;
@ -362,7 +362,7 @@ fu_plugin_uefi_capsule_update_splash(FuPlugin *plugin, FuDevice *device, GError
} }
/* get the boot graphics resource table data */ /* get the boot graphics resource table data */
if (!fu_uefi_bgrt_get_supported(data->bgrt)) { if (!fu_uefi_bgrt_get_supported(priv->bgrt)) {
g_set_error_literal(error, g_set_error_literal(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
@ -489,19 +489,19 @@ fu_plugin_uefi_capsule_load_config(FuPlugin *plugin, FuDevice *device)
static void static void
fu_plugin_uefi_capsule_register_proxy_device(FuPlugin *plugin, FuDevice *device) fu_plugin_uefi_capsule_register_proxy_device(FuPlugin *plugin, FuDevice *device)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(FuUefiDevice) dev = NULL; g_autoptr(FuUefiDevice) dev = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
/* load all configuration variables */ /* load all configuration variables */
dev = fu_uefi_backend_device_new_from_dev(FU_UEFI_BACKEND(data->backend), device); dev = fu_uefi_backend_device_new_from_dev(FU_UEFI_BACKEND(priv->backend), device);
fu_plugin_uefi_capsule_load_config(plugin, FU_DEVICE(dev)); fu_plugin_uefi_capsule_load_config(plugin, FU_DEVICE(dev));
if (data->esp == NULL) if (priv->esp == NULL)
data->esp = fu_volume_new_esp_default(&error_local); priv->esp = fu_volume_new_esp_default(&error_local);
if (data->esp == NULL) { if (priv->esp == NULL) {
fu_device_inhibit(device, "no-esp", error_local->message); fu_device_inhibit(device, "no-esp", error_local->message);
} else { } else {
fu_uefi_device_set_esp(dev, data->esp); fu_uefi_device_set_esp(dev, priv->esp);
fu_device_uninhibit(device, "no-esp"); fu_device_uninhibit(device, "no-esp");
} }
fu_plugin_device_add(plugin, FU_DEVICE(dev)); fu_plugin_device_add(plugin, FU_DEVICE(dev));
@ -621,7 +621,7 @@ static gboolean
fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
guint64 nvram_total; guint64 nvram_total;
g_autofree gchar *esp_path = NULL; g_autofree gchar *esp_path = NULL;
g_autofree gchar *nvram_total_str = NULL; g_autofree gchar *nvram_total_str = NULL;
@ -641,12 +641,12 @@ fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError **
/* use GRUB to load updates */ /* use GRUB to load updates */
if (fu_plugin_get_config_value_boolean(plugin, "EnableGrubChainLoad")) { if (fu_plugin_get_config_value_boolean(plugin, "EnableGrubChainLoad")) {
fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(data->backend), fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(priv->backend),
FU_TYPE_UEFI_GRUB_DEVICE); FU_TYPE_UEFI_GRUB_DEVICE);
} }
/* check we can use this backend */ /* check we can use this backend */
if (!fu_backend_setup(data->backend, progress, &error_local)) { if (!fu_backend_setup(priv->backend, progress, &error_local)) {
if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_WRITE)) { if (g_error_matches(error_local, FWUPD_ERROR, FWUPD_ERROR_WRITE)) {
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_EFIVAR_NOT_MOUNTED); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_EFIVAR_NOT_MOUNTED);
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE);
@ -668,8 +668,8 @@ fu_plugin_uefi_capsule_startup(FuPlugin *plugin, FuProgress *progress, GError **
/* override the default ESP path */ /* override the default ESP path */
esp_path = fu_plugin_get_config_value(plugin, "OverrideESPMountPoint"); esp_path = fu_plugin_get_config_value(plugin, "OverrideESPMountPoint");
if (esp_path != NULL) { if (esp_path != NULL) {
data->esp = fu_volume_new_esp_for_path(esp_path, error); priv->esp = fu_volume_new_esp_for_path(esp_path, error);
if (data->esp == NULL) { if (priv->esp == NULL) {
g_prefix_error(error, g_prefix_error(error,
"invalid OverrideESPMountPoint=%s " "invalid OverrideESPMountPoint=%s "
"specified in config: ", "specified in config: ",
@ -812,7 +812,7 @@ fu_plugin_uefi_capsule_check_cod_support(GError **error)
static gboolean static gboolean
fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
const gchar *str; const gchar *str;
gboolean has_fde = FALSE; gboolean has_fde = FALSE;
g_autoptr(GError) error_udisks2 = NULL; g_autoptr(GError) error_udisks2 = NULL;
@ -829,9 +829,9 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError *
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 26, "add-devices"); fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 26, "add-devices");
fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "setup-bgrt"); fu_progress_add_step(progress, FWUPD_STATUS_LOADING, 1, "setup-bgrt");
if (data->esp == NULL) { if (priv->esp == NULL) {
data->esp = fu_volume_new_esp_default(&error_udisks2); priv->esp = fu_volume_new_esp_default(&error_udisks2);
if (data->esp == NULL) { if (priv->esp == NULL) {
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_ESP_NOT_FOUND); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_ESP_NOT_FOUND);
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_CLEAR_UPDATABLE);
fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_USER_WARNING); fu_plugin_add_flag(plugin, FWUPD_PLUGIN_FLAG_USER_WARNING);
@ -846,7 +846,7 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError *
if (!fu_plugin_uefi_capsule_check_cod_support(&error_cod)) { if (!fu_plugin_uefi_capsule_check_cod_support(&error_cod)) {
g_debug("not using CapsuleOnDisk support: %s", error_cod->message); g_debug("not using CapsuleOnDisk support: %s", error_cod->message);
} else { } else {
fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(data->backend), fu_uefi_backend_set_device_gtype(FU_UEFI_BACKEND(priv->backend),
FU_TYPE_UEFI_COD_DEVICE); FU_TYPE_UEFI_COD_DEVICE);
} }
} }
@ -860,16 +860,16 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError *
fu_progress_step_done(progress); fu_progress_step_done(progress);
/* add each device */ /* add each device */
if (!fu_backend_coldplug(data->backend, fu_progress_get_child(progress), error)) if (!fu_backend_coldplug(priv->backend, fu_progress_get_child(progress), error))
return FALSE; return FALSE;
fu_progress_step_done(progress); fu_progress_step_done(progress);
devices = fu_backend_get_devices(data->backend); devices = fu_backend_get_devices(priv->backend);
for (guint i = 0; i < devices->len; i++) { for (guint i = 0; i < devices->len; i++) {
FuUefiDevice *dev = g_ptr_array_index(devices, i); FuUefiDevice *dev = g_ptr_array_index(devices, i);
g_autoptr(GError) error_device = NULL; g_autoptr(GError) error_device = NULL;
if (data->esp != NULL) if (priv->esp != NULL)
fu_uefi_device_set_esp(dev, data->esp); fu_uefi_device_set_esp(dev, priv->esp);
if (!fu_plugin_uefi_capsule_coldplug_device(plugin, dev, &error_device)) { if (!fu_plugin_uefi_capsule_coldplug_device(plugin, dev, &error_device)) {
if (g_error_matches(error_device, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) { if (g_error_matches(error_device, FWUPD_ERROR, FWUPD_ERROR_NOT_SUPPORTED)) {
g_warning("skipping device that failed coldplug: %s", g_warning("skipping device that failed coldplug: %s",
@ -901,9 +901,9 @@ fu_plugin_uefi_capsule_coldplug(FuPlugin *plugin, FuProgress *progress, GError *
/* for debugging problems later */ /* for debugging problems later */
fu_plugin_uefi_capsule_test_secure_boot(plugin); fu_plugin_uefi_capsule_test_secure_boot(plugin);
if (!fu_uefi_bgrt_setup(data->bgrt, &error_local)) if (!fu_uefi_bgrt_setup(priv->bgrt, &error_local))
g_debug("BGRT setup failed: %s", error_local->message); g_debug("BGRT setup failed: %s", error_local->message);
str = fu_uefi_bgrt_get_supported(data->bgrt) ? "Enabled" : "Disabled"; str = fu_uefi_bgrt_get_supported(priv->bgrt) ? "Enabled" : "Disabled";
g_debug("UX Capsule support : %s", str); g_debug("UX Capsule support : %s", str);
fu_plugin_add_report_metadata(plugin, "UEFIUXCapsule", str); fu_plugin_add_report_metadata(plugin, "UEFIUXCapsule", str);
fu_progress_step_done(progress); fu_progress_step_done(progress);

View File

@ -33,30 +33,30 @@ fu_plugin_upower_init(FuPlugin *plugin)
static void static void
fu_plugin_upower_destroy(FuPlugin *plugin) fu_plugin_upower_destroy(FuPlugin *plugin)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
if (data->proxy != NULL) if (priv->proxy != NULL)
g_object_unref(data->proxy); g_object_unref(priv->proxy);
if (data->proxy_manager != NULL) if (priv->proxy_manager != NULL)
g_object_unref(data->proxy_manager); g_object_unref(priv->proxy_manager);
} }
static void static void
fu_plugin_upower_rescan_devices(FuPlugin *plugin) fu_plugin_upower_rescan_devices(FuPlugin *plugin)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GVariant) percentage_val = NULL; g_autoptr(GVariant) percentage_val = NULL;
g_autoptr(GVariant) type_val = NULL; g_autoptr(GVariant) type_val = NULL;
g_autoptr(GVariant) state_val = NULL; g_autoptr(GVariant) state_val = NULL;
/* check that we "have" a battery */ /* check that we "have" a battery */
type_val = g_dbus_proxy_get_cached_property(data->proxy, "Type"); type_val = g_dbus_proxy_get_cached_property(priv->proxy, "Type");
if (type_val == NULL || g_variant_get_uint32(type_val) == 0) { if (type_val == NULL || g_variant_get_uint32(type_val) == 0) {
fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN); fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN);
fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID); fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID);
return; return;
} }
state_val = g_dbus_proxy_get_cached_property(data->proxy, "State"); state_val = g_dbus_proxy_get_cached_property(priv->proxy, "State");
if (state_val == NULL || g_variant_get_uint32(state_val) == 0) { if (state_val == NULL || g_variant_get_uint32(state_val) == 0) {
g_warning("failed to query power state"); g_warning("failed to query power state");
fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN); fu_context_set_battery_state(ctx, FU_BATTERY_STATE_UNKNOWN);
@ -86,7 +86,7 @@ fu_plugin_upower_rescan_devices(FuPlugin *plugin)
} }
/* get percentage */ /* get percentage */
percentage_val = g_dbus_proxy_get_cached_property(data->proxy, "Percentage"); percentage_val = g_dbus_proxy_get_cached_property(priv->proxy, "Percentage");
if (percentage_val == NULL) { if (percentage_val == NULL) {
g_warning("failed to query power percentage level"); g_warning("failed to query power percentage level");
fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID); fu_context_set_battery_level(ctx, FWUPD_BATTERY_LEVEL_INVALID);
@ -99,13 +99,13 @@ static void
fu_plugin_upower_rescan_manager(FuPlugin *plugin) fu_plugin_upower_rescan_manager(FuPlugin *plugin)
{ {
FuContext *ctx = fu_plugin_get_context(plugin); FuContext *ctx = fu_plugin_get_context(plugin);
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autoptr(GVariant) lid_is_closed = NULL; g_autoptr(GVariant) lid_is_closed = NULL;
g_autoptr(GVariant) lid_is_present = NULL; g_autoptr(GVariant) lid_is_present = NULL;
/* check that we "have" a lid */ /* check that we "have" a lid */
lid_is_present = g_dbus_proxy_get_cached_property(data->proxy_manager, "LidIsPresent"); lid_is_present = g_dbus_proxy_get_cached_property(priv->proxy_manager, "LidIsPresent");
lid_is_closed = g_dbus_proxy_get_cached_property(data->proxy_manager, "LidIsClosed"); lid_is_closed = g_dbus_proxy_get_cached_property(priv->proxy_manager, "LidIsClosed");
if (lid_is_present == NULL || lid_is_closed == NULL) { if (lid_is_present == NULL || lid_is_closed == NULL) {
g_warning("failed to query lid state"); g_warning("failed to query lid state");
fu_context_set_lid_state(ctx, FU_LID_STATE_UNKNOWN); fu_context_set_lid_state(ctx, FU_LID_STATE_UNKNOWN);
@ -135,10 +135,10 @@ fu_plugin_upower_proxy_changed_cb(GDBusProxy *proxy,
static gboolean static gboolean
fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error) fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
{ {
FuPluginData *data = fu_plugin_get_data(plugin); FuPluginData *priv = fu_plugin_get_data(plugin);
g_autofree gchar *name_owner = NULL; g_autofree gchar *name_owner = NULL;
data->proxy_manager = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, priv->proxy_manager = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
NULL, NULL,
"org.freedesktop.UPower", "org.freedesktop.UPower",
@ -146,11 +146,11 @@ fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
"org.freedesktop.UPower", "org.freedesktop.UPower",
NULL, NULL,
error); error);
if (data->proxy_manager == NULL) { if (priv->proxy_manager == NULL) {
g_prefix_error(error, "failed to connect to upower: "); g_prefix_error(error, "failed to connect to upower: ");
return FALSE; return FALSE;
} }
data->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, priv->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE, G_DBUS_PROXY_FLAGS_NONE,
NULL, NULL,
"org.freedesktop.UPower", "org.freedesktop.UPower",
@ -158,24 +158,24 @@ fu_plugin_upower_startup(FuPlugin *plugin, FuProgress *progress, GError **error)
"org.freedesktop.UPower.Device", "org.freedesktop.UPower.Device",
NULL, NULL,
error); error);
if (data->proxy == NULL) { if (priv->proxy == NULL) {
g_prefix_error(error, "failed to connect to upower: "); g_prefix_error(error, "failed to connect to upower: ");
return FALSE; return FALSE;
} }
name_owner = g_dbus_proxy_get_name_owner(data->proxy); name_owner = g_dbus_proxy_get_name_owner(priv->proxy);
if (name_owner == NULL) { if (name_owner == NULL) {
g_set_error(error, g_set_error(error,
FWUPD_ERROR, FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED, FWUPD_ERROR_NOT_SUPPORTED,
"no owner for %s", "no owner for %s",
g_dbus_proxy_get_name(data->proxy)); g_dbus_proxy_get_name(priv->proxy));
return FALSE; return FALSE;
} }
g_signal_connect(G_DBUS_PROXY(data->proxy), g_signal_connect(G_DBUS_PROXY(priv->proxy),
"g-properties-changed", "g-properties-changed",
G_CALLBACK(fu_plugin_upower_proxy_changed_cb), G_CALLBACK(fu_plugin_upower_proxy_changed_cb),
plugin); plugin);
g_signal_connect(G_DBUS_PROXY(data->proxy_manager), g_signal_connect(G_DBUS_PROXY(priv->proxy_manager),
"g-properties-changed", "g-properties-changed",
G_CALLBACK(fu_plugin_upower_proxy_changed_cb), G_CALLBACK(fu_plugin_upower_proxy_changed_cb),
plugin); plugin);