Skip to content

Commit

Permalink
Allow -a to create a non-existent variable
Browse files Browse the repository at this point in the history
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 <benh@kernel.crashing.org>
  • Loading branch information
ozbenh authored and vathpela committed Mar 7, 2023
1 parent 9306e0b commit 90e88b2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/efivar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 90e88b2

Please sign in to comment.