[U-Boot] [RFC PATCH 3/7] env: Introduce "export" operation and (access flag) restriction

Bernhard Nortmann bernhard.nortmann at web.de
Tue Jul 12 20:02:02 CEST 2016


Am 11.07.2016 um 20:14 schrieb Bernhard Nortmann:
> This patch introduces a new "export" environment operation
> (env_op_export) and the corresponding access flag
> ENV_FLAGS_VARACCESS_PREVENT_EXPORT; so that env_flags_validate()
> may now check requests to export specific variables.
>
> In turn, hexport_r() makes uses of this ability to suppress the
> export of variables that are flagged accordingly.
>
> Note that env_flags_validate() and hexport_r() will respect H_FORCE
> and H_PROGRAMMATIC flags, allowing to bypass the export filtering.
> H_PROGRAMMATIC gets used within env_print() to make sure all
> variables are listed. This is necessary because env_print() is
> essentially an "export to text" operation.
>
> Signed-off-by: Bernhard Nortmann <bernhard.nortmann at web.de>
> ---
>
> [...]
>
> diff --git a/lib/hashtable.c b/lib/hashtable.c
> index 02b4105..708319d 100644
> --- a/lib/hashtable.c
> +++ b/lib/hashtable.c
> @@ -621,6 +621,10 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag,
>   			if ((flag & H_HIDE_DOT) && ep->key[0] == '.')
>   				continue;
>   
> +			if (env_flags_validate(ep, NULL, env_op_export,
> +					       flag & H_FORCE) != 0)
> +				continue;
> +
>   			list[n++] = ep;
>   
>   			totlen += strlen(ep->key) + 2;

This is also a remnant of previous experiments, and a too narrow condition
that doesn't match the commit message's description. If "flag" is to be
fully respected (H_FORCE | H_PROGRAMMATIC bits), then the H_FORCE mask
(bitwise and operation) needs to be removed. Fixed in my local branch.

Regards, B. Nortmann



More information about the U-Boot mailing list