diff mbox series

bootloader: EBG: env_unset(STATE_KEY) ~ env_set(STATE_KEY, STATE_OK)

Message ID 20210126110329.9392-1-christian.storm@siemens.com
State Accepted
Headers show
Series bootloader: EBG: env_unset(STATE_KEY) ~ env_set(STATE_KEY, STATE_OK) | expand

Commit Message

Christian Storm Jan. 26, 2021, 11:03 a.m. UTC
Unsetting STATE_KEY (CONFIG_UPDATE_STATE_BOOTLOADER) in EFI Boot Guard's
environment is semantically equivalent to setting STATE_KEY to STATE_OK.

Signed-off-by: Heiko Schabert <heiko.schabert@siemens.com>
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 bootloader/ebg.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Stefano Babic Jan. 26, 2021, 11:52 a.m. UTC | #1
On 26.01.21 12:03, Christian Storm wrote:
> Unsetting STATE_KEY (CONFIG_UPDATE_STATE_BOOTLOADER) in EFI Boot Guard's
> environment is semantically equivalent to setting STATE_KEY to STATE_OK.
> 
> Signed-off-by: Heiko Schabert <heiko.schabert@siemens.com>
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  bootloader/ebg.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/bootloader/ebg.c b/bootloader/ebg.c
> index 321c34e..0f35c00 100644
> --- a/bootloader/ebg.c
> +++ b/bootloader/ebg.c
> @@ -86,6 +86,11 @@ int bootloader_env_unset(const char *name)
>  		if (ret) {
>  			ERROR("Cannot unset %s in bootloader environment: %s.", RCS_KEY, strerror(ret));
>  		}
> +	} else if (strncmp(name, (char *)STATE_KEY, strlen((char *)STATE_KEY) + 1) == 0) {
> +		/* Unsetting STATE_KEY is semantically equivalent to setting it to STATE_OK. */
> +		if ((ret = ebg_env_setglobalstate(&ebgenv, STATE_OK - '0')) != 0) {
> +			ERROR("Cannot unset %s in bootloader environment.", STATE_KEY);
> +		}
>  	} else {
>  		ret = ebg_env_set_ex(&ebgenv, (char *)name, USERVAR_TYPE_DELETED, (uint8_t *)"", 1);
>  	}
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/bootloader/ebg.c b/bootloader/ebg.c
index 321c34e..0f35c00 100644
--- a/bootloader/ebg.c
+++ b/bootloader/ebg.c
@@ -86,6 +86,11 @@  int bootloader_env_unset(const char *name)
 		if (ret) {
 			ERROR("Cannot unset %s in bootloader environment: %s.", RCS_KEY, strerror(ret));
 		}
+	} else if (strncmp(name, (char *)STATE_KEY, strlen((char *)STATE_KEY) + 1) == 0) {
+		/* Unsetting STATE_KEY is semantically equivalent to setting it to STATE_OK. */
+		if ((ret = ebg_env_setglobalstate(&ebgenv, STATE_OK - '0')) != 0) {
+			ERROR("Cannot unset %s in bootloader environment.", STATE_KEY);
+		}
 	} else {
 		ret = ebg_env_set_ex(&ebgenv, (char *)name, USERVAR_TYPE_DELETED, (uint8_t *)"", 1);
 	}