diff mbox

[U-Boot,RFC,v2,1/7] env: Allow unconditional access if H_PROGRAMMATIC is set

Message ID 1479292229-17256-2-git-send-email-bernhard.nortmann@web.de
State RFC
Delegated to: Joe Hershberger
Headers show

Commit Message

Bernhard Nortmann Nov. 16, 2016, 10:29 a.m. UTC
This patch modifies env_flags_validate() in such a way that any
operation will *always* be allowed if H_PROGRAMMATIC is present.

Without this change, programmatically changing environment vars
may fail depending on their flags, e.g. when trying to setenv*()
a variable that is marked "read-only".
http://lists.denx.de/pipermail/u-boot/2016-April/250237.html

Notes: H_FORCE may be insufficient for this purpose, as it can be
disabled by CONFIG_ENV_ACCESS_IGNORE_FORCE.
H_PROGRAMMATIC indicates "U-Boot internal" use. By contrast, any
user interaction (from U-Boot prompt or scripts) is expected to
be marked H_INTERACTIVE.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>

---

Changes in v2: None

 common/env_flags.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Simon Glass Nov. 19, 2016, 1:47 p.m. UTC | #1
On 16 November 2016 at 03:29, Bernhard Nortmann
<bernhard.nortmann@web.de> wrote:
> This patch modifies env_flags_validate() in such a way that any
> operation will *always* be allowed if H_PROGRAMMATIC is present.
>
> Without this change, programmatically changing environment vars
> may fail depending on their flags, e.g. when trying to setenv*()
> a variable that is marked "read-only".
> http://lists.denx.de/pipermail/u-boot/2016-April/250237.html
>
> Notes: H_FORCE may be insufficient for this purpose, as it can be
> disabled by CONFIG_ENV_ACCESS_IGNORE_FORCE.
> H_PROGRAMMATIC indicates "U-Boot internal" use. By contrast, any
> user interaction (from U-Boot prompt or scripts) is expected to
> be marked H_INTERACTIVE.
>
> Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
>
> ---
>
> Changes in v2: None
>
>  common/env_flags.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/common/env_flags.c b/common/env_flags.c
index 921d377..1087f4e 100644
--- a/common/env_flags.c
+++ b/common/env_flags.c
@@ -523,6 +523,8 @@  int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
 	}
 
 	/* check for access permission */
+	if (flag & H_PROGRAMMATIC)
+		return 0;
 #ifndef CONFIG_ENV_ACCESS_IGNORE_FORCE
 	if (flag & H_FORCE)
 		return 0;