mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/4] login: disable input console if password wrong
Date: Mon, 16 Sep 2013 17:15:43 +0200	[thread overview]
Message-ID: <20130916151543.GA30088@pengutronix.de> (raw)
In-Reply-To: <20130916143733.GF21829@ns203013.ovh.net>

On Mon, Sep 16, 2013 at 04:37:33PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:33 Mon 16 Sep     , Sascha Hauer wrote:
> > On Sun, Sep 15, 2013 at 01:30:52PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > so we guarantee that barebox is secured again user interaction
> > > 
> > > +static bool console_input_allow = false;
> > > +
> > > +static int console_input_allow_set(struct device_d *dev, struct param_d *p, const char *val)
> > > +{
> > > +	int ret = dev_param_set_generic(dev, p, val);
> > > +
> > > +	if (val && simple_strtoul(val, NULL, 10))
> > > +		console_input_allow = true;
> > > +	else
> > > +		console_input_allow = false;
> > > +
> > > +	return ret;
> > > +}
> > > +
> > > +static int console_global_init(void)
> > > +{
> > > +	globalvar_add("console.input_allow", console_input_allow_set, NULL, 0);
> > > +
> > > +	if (IS_ENABLED(CONFIG_CMD_LOGIN) && is_passwd_enable())
> > > +		setenv("global.console.input_allow", "0");
> > > +	else
> > > +		setenv("global.console.input_allow", "1");
> > > +
> > > +	return 0;
> > > +}
> > > +late_initcall(console_global_init);
> > 
> > With the attached patch applied the above would go down to:
> > 
> > static int console_input_allow;
> > 
> > static int console_global_init(void)
> > {
> > 	dev_add_param_bool(&global_device, "console.input_allow",
> > 		NULL, NULL, &console_input_allow, NULL);
> 
> I'm not a fan to export the global_device but I like the dev_addxxx

I'm not a fan of this also. The alternative would be to:

static inline struct param_d *global_add_param_bool(const char *name,
		int (*set)(struct param_d *p, void *priv),
		int (*get)(struct param_d *p, void *priv),
		int *value, void *priv)
{
	return dev_add_param_bool(&global_device, name, get, set,
			value, priv;
}

(We would still export global_device but could convert the above to non
static inline functions later should we have to).

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-09-16 15:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-15 11:28 [PATCH 0/2 v2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD
2013-09-15 11:30 ` [PATCH 1/4] login: add globalvar timeout support Jean-Christophe PLAGNIOL-VILLARD
2013-09-15 11:30   ` [PATCH 2/4] login: disable input console if password wrong Jean-Christophe PLAGNIOL-VILLARD
2013-09-16  8:33     ` Sascha Hauer
2013-09-16 14:37       ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-16 15:15         ` Sascha Hauer [this message]
2013-09-15 11:30   ` [PATCH 3/4] login/passwd: add default password support Jean-Christophe PLAGNIOL-VILLARD
2013-09-15 11:30   ` [PATCH 4/4] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD
2013-09-16  8:02   ` [PATCH 1/4] login: add globalvar timeout support Sascha Hauer
2013-09-16 14:39     ` Jean-Christophe PLAGNIOL-VILLARD

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=20130916151543.GA30088@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /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