public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 10/12] env: acl: Add environment variable access control list
Date: Wed, 22 Aug 2012 23:43:36 -0400	[thread overview]
Message-ID: <201208222343.37055.vapier@gentoo.org> (raw)
In-Reply-To: <1345236586-19076-11-git-send-email-joe.hershberger@ni.com>

On Friday 17 August 2012 16:49:44 Joe Hershberger wrote:
> --- a/common/cmd_nvedit.c
> +++ b/common/cmd_nvedit.c
>
> +#if defined(CONFIG_ENV_ACL)
> +#include <env_acl.h>
> +#endif

the header should not need protection just to be included

> +#ifdef CONFIG_ENV_ACL
> +	if (env_acl_validate_env_set_params(argc, argv) < 0)
> +		return 1;
> +#endif

have the header define env_acl_validate_env_set_params() as a return 0 static 
inline func when CONFIG_ENV_ACL isn't defined and then you can drop the ifdef 
here

> --- /dev/null
> +++ b/common/env_acl.c
>
> + * (C) Copyright 2010

fwiw, it's 2012 now

> +static int _env_acl_lookup_r(const char *name, char *attributes, int
> static_acl)
> ...
> +	entry = strstr(acl, name);
> +	while (entry != NULL) {
> +		if ((entry == acl || *(entry - 1) == ENV_ACL_LIST_DELIM ||
> +		    *(entry - 1) == ' ') &&
> +		    (*(entry + strlen(name)) == ENV_ACL_ATTR_SEP ||
> +		     *(entry + strlen(name)) == ENV_ACL_LIST_DELIM ||
> +		     *(entry + strlen(name)) == '\0' ||
> +		     *(entry + strlen(name)) == ' '))
> +			break;

is that strlen optimized away ?  i suspect not.  and even if it is, the 
duplication here is kind of ugly, so it'd be better to use a local var 
anyways.
	const char *acl_val = entry + strlen(name);

> +static int env_acl_lookup_r(const char *name, char *attributes)
> +{
> +	int ret_val;
> +	/* try the env first */
> +	ret_val = _env_acl_lookup_r(name, attributes, 0);
> +	if (ret_val != 0) {
> +		/* if not found in the env, look in the static list */
> +		ret_val = _env_acl_lookup_r(name, attributes, 1);
> +	}
> +	return ret_val;
> +}
> +
> +enum env_acl_var_type env_acl_get_type(const char *name)
> +{
> +	char *type;

const

> +static void skip_num(int hex, const char *value, const char **end,
> +	int max_digits)
> +{
> +	int i;
> +
> +	if (hex && is_hex_prefix(value))
> +		value += 2;
> +
> +	for (i = max_digits; i != 0; i--) {
> +		if (hex && !isxdigit(*value))
> +			break;
> +		if (!hex && !isdigit(*value))
> +			break;
> +		value++;
> +	}
> +	if (end != NULL)
> +		*end = value;
> +}

couldn't you use strtol and abuse the endptr field ?

> --- a/tools/env/fw_env.h
> +++ b/tools/env/fw_env.h
> 
> +#define min(x, y) ({				\
> +	typeof(x) _min1 = (x);			\
> +	typeof(y) _min2 = (y);			\
> +	(void) (&_min1 == &_min2);		\
> +	_min1 < _min2 ? _min1 : _min2; })

ugh, no.  use include/compiler.h.  you might want to look@the min/max 
already defined in include/common.h rather than duplicating another one 
locally.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120822/4371457d/attachment.pgp>

  reply	other threads:[~2012-08-23  3:43 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-28  2:07 [U-Boot] Read-only env variables Joe Hershberger
2010-05-06 21:58 ` Wolfgang Denk
2010-05-10  6:30   ` Joe Hershberger
2010-05-10  6:56     ` Wolfgang Denk
2010-05-10 19:16       ` Joe Hershberger
2010-05-10 20:43         ` Wolfgang Denk
2010-05-10 21:33           ` Joe Hershberger
2010-05-11 20:19             ` Craig Millen
2010-05-11 22:03               ` Wolfgang Denk
2010-05-11 22:52                 ` Joe Hershberger
2010-05-12  9:34                   ` Wolfgang Denk
2010-05-12 23:46                     ` Joe Hershberger
2010-06-22 21:18                       ` Wolfgang Denk
2010-06-22 21:49                         ` Joe Hershberger
2010-06-22 22:29                           ` Wolfgang Denk
2012-08-17 20:49                             ` [U-Boot] [PATCH 0/12] Add environment type checking and access control Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 01/12] tools/env: Use a board-specific default env Joe Hershberger
2012-08-23  3:17                                 ` Mike Frysinger
2012-08-23 15:45                                   ` Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 02/12] tools/env: Remove unneeded complexity Joe Hershberger
2012-08-23  3:30                                 ` Mike Frysinger
2012-08-17 20:49                               ` [U-Boot] [PATCH 03/12] tools/env: Don't call env_init() in fw_getenv() Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 04/12] tools/env: Reduce the impact on real-time processes Joe Hershberger
2012-08-23  3:30                                 ` Mike Frysinger
2012-08-23 16:26                                   ` Joe Hershberger
2012-08-23 20:31                                     ` Mike Frysinger
2012-08-17 20:49                               ` [U-Boot] [PATCH 05/12] tools/env: Serialize calls to fw_*env Joe Hershberger
2012-08-23  3:33                                 ` Mike Frysinger
2012-10-03  1:12                                   ` Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 06/12] env: Make the "silent" env var take effect immediately Joe Hershberger
2012-08-23  3:35                                 ` Mike Frysinger
2012-08-17 20:49                               ` [U-Boot] [PATCH 07/12] env: Update serial baudrate in env_relocate() Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 08/12] env: Check for NULL pointer in envmatch() Joe Hershberger
2012-08-17 23:51                                 ` Mike Frysinger
2012-08-17 20:49                               ` [U-Boot] [PATCH 09/12] env: Clarify the cases for env set Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 10/12] env: acl: Add environment variable access control list Joe Hershberger
2012-08-23  3:43                                 ` Mike Frysinger [this message]
2012-09-13 20:13                                 ` Wolfgang Denk
2012-09-14  2:24                                   ` Joe Hershberger
2012-09-14 18:42                                     ` Wolfgang Denk
2012-11-01 16:39                                       ` [U-Boot] [PATCH v3 0/18] Add environment call-back and flags capability Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 01/18] Make linux kernel string funcs available to tools Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 02/18] env: Refactor do_apply to a flag Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 03/18] env: Consolidate common code in hsearch_r() Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 04/18] env: Refactor apply into change_ok Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 05/18] env: Use getenv_yesno() more generally Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 06/18] env: Hide '.' variables in env print by default Joe Hershberger
2012-11-02 10:44                                           ` Luka Perkov
2012-11-02 22:23                                             ` Wolfgang Denk
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 07/18] env: Add support for callbacks to environment vars Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 08/18] env: Add a command to view callbacks Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 09/18] env: Add a bootfile env handler Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 10/18] env: Add a baudrate " Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 11/18] env: Add a loadaddr " Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 12/18] env: Add a console " Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 13/18] env: Add a silent " Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 14/18] env: Add environment variable flags Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 15/18] tools/env: Add environment variable flags support Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 16/18] env: Add a command to display details about env flags Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 17/18] env: Add support for access control to .flags Joe Hershberger
2012-11-01 16:39                                         ` [U-Boot] [PATCH v3 18/18] env: Handle write-once ethaddr and serial# generically Joe Hershberger
2012-11-02 22:40                                         ` [U-Boot] [PATCH v3 0/18] Add environment call-back and flags capability Wolfgang Denk
2012-11-05  0:15                                           ` Joe Hershberger
2012-12-01 19:44                                           ` Joe Hershberger
2012-12-05  1:52                                         ` [U-Boot] [PATCH v4 0/20] " Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 01/20] Make linux kernel string funcs available to tools Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 02/20] env: Refactor do_apply to a flag Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 03/20] env: Consolidate common code in hsearch_r() Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 04/20] env: Refactor apply into change_ok Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 05/20] env: Use getenv_yesno() more generally Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 06/20] env: Hide '.' variables in env print by default Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 07/20] env: Add support for callbacks to environment vars Joe Hershberger
2012-12-05  2:34                                             ` Graeme Russ
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 08/20] env: Add a command to view callbacks Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 09/20] env: Add a bootfile env handler Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 10/20] env: Add a baudrate " Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 11/20] env: Add a loadaddr " Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 12/20] env: Add a console " Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 13/20] env: Add a silent " Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 14/20] env: Add environment variable flags Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 15/20] tools/env: Add environment variable flags support Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 16/20] env: Add a command to display details about env flags Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 17/20] env: Add support for access control to .flags Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 18/20] env: Add setenv force support Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 19/20] env: Implement the env delete command Joe Hershberger
2012-12-05  1:52                                           ` [U-Boot] [PATCH v4 20/20] env: Handle write-once ethaddr and serial# generically Joe Hershberger
2012-12-11 16:51                                           ` [U-Boot] [PATCH v4 0/20] Add environment call-back and flags capability Tom Rini
2012-12-12  4:16                                           ` [U-Boot] [PATCH v5 " Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 01/20] Make linux kernel string funcs available to tools Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 02/20] env: Refactor do_apply to a flag Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 03/20] env: Consolidate common code in hsearch_r() Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 04/20] env: Refactor apply into change_ok Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 05/20] env: Use getenv_yesno() more generally Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 06/20] env: Hide '.' variables in env print by default Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 07/20] env: Add support for callbacks to environment vars Joe Hershberger
2013-01-11  8:06                                               ` Stefan Roese
2013-01-14 23:23                                                 ` Joe Hershberger
2013-01-15  6:51                                                   ` Stefan Roese
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 08/20] env: Add a command to view callbacks Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 09/20] env: Add a bootfile env handler Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 10/20] env: Add a baudrate " Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 11/20] env: Add a loadaddr " Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 12/20] env: Add a console " Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 13/20] env: Add a silent " Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 14/20] env: Add environment variable flags Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 15/20] tools/env: Add environment variable flags support Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 16/20] env: Add a command to display details about env flags Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 17/20] env: Add support for access control to .flags Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 18/20] env: Add setenv force support Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 19/20] env: Implement the env delete command Joe Hershberger
2012-12-12  4:16                                             ` [U-Boot] [PATCH v5 20/20] env: Handle write-once ethaddr and serial# generically Joe Hershberger
2012-12-14 16:05                                             ` [U-Boot] [PATCH v5 0/20] Add environment call-back and flags capability Tom Rini
2012-08-17 20:49                               ` [U-Boot] [PATCH 11/12] env: acl: Add support for access control to env ACL Joe Hershberger
2012-08-17 20:49                               ` [U-Boot] [PATCH 12/12] env: cosmetic: Consilidate the default env definition Joe Hershberger
2012-08-23  3:44                                 ` Mike Frysinger
2012-10-03 19:38                               ` [U-Boot] [PATCH v2 0/5] Cleanup fw_*env and a few common env Joe Hershberger
2012-10-03 19:38                                 ` [U-Boot] [PATCH v2 1/5] tools/env: Use a board-specific default env Joe Hershberger
2012-10-03 19:38                                 ` [U-Boot] [PATCH v2 2/5] tools/env: Remove unneeded complexity Joe Hershberger
2012-10-03 19:38                                 ` [U-Boot] [PATCH v2 3/5] tools/env: Don't call env_init() in fw_getenv() Joe Hershberger
2012-10-03 19:38                                 ` [U-Boot] [PATCH v2 4/5] tools/env: Serialize calls to fw_*env Joe Hershberger
2012-10-03 23:24                                   ` uboot at lukaperkov.net
2012-10-04 18:31                                     ` [U-Boot] [PATCH] tools: Add a README note about fw_printenv lock file Joe Hershberger
2012-10-03 19:38                                 ` [U-Boot] [PATCH v2 5/5] env: Check for NULL pointer in envmatch() Joe Hershberger
2012-10-09 17:13                                 ` [U-Boot] [PATCH v2 0/5] Cleanup fw_*env and a few common env Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201208222343.37055.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox