From 90e88b221e8bc60dc50f3246051369b8f580c0d0 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 7 Mar 2023 16:29:05 +1100 Subject: [PATCH] Allow -a to create a non-existent variable There is no much point in failing when trying to append, we may as well create the variable. This way it can be used for dbx update payloads that must be applied in append mode even if there isn't a dbx yet. This is nicer than using -w with EFI_VARIABLE_APPEND_WRITE added to the attributes passed with -A Signed-off-by: Benjamin Herrenschmidt --- src/efivar.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/efivar.c b/src/efivar.c index e335a6b9..1f9d6139 100644 --- a/src/efivar.c +++ b/src/efivar.c @@ -355,14 +355,8 @@ edit_variable(const char *guid_name, void *data, size_t data_size, exit(1); } - rc = efi_get_variable(guid, name, &old_data, &old_data_size, - &old_attributes); - if (rc < 0 && edit_type != EDIT_WRITE) { - fprintf(stderr, "efivar: %m\n"); - show_errors(); - exit(1); - } - + rc = efi_get_variable(guid, name, &old_data, &old_data_size, &old_attributes); + /* Ignore errors, as -a can be used to create a variable */ if (attrib != 0) old_attributes = attrib;