* [PATCH 0/2] defaultenv-2: add login support @ 2013-09-04 10:01 Jean-Christophe PLAGNIOL-VILLARD 2013-09-04 10:10 ` [PATCH 1/2] login: add globalvar timeout support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 4+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-04 10:01 UTC (permalink / raw) To: barebox HI, this will allow to request password when try to interrupt barebox auto boot defaultenv-2: add login support (2013-09-04 17:55:11 +0800) ---------------------------------------------------------------- Jean-Christophe PLAGNIOL-VILLARD (2): login: add globalvar timeout support defaultenv-2: add login support commands/login.c | 26 ++++++++++++++++++++++++++ defaultenv-2/base/bin/init | 9 +++++++++ 2 files changed, 35 insertions(+) Best Regards, J. _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] login: add globalvar timeout support 2013-09-04 10:01 [PATCH 0/2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-04 10:10 ` Jean-Christophe PLAGNIOL-VILLARD 2013-09-04 10:10 ` [PATCH 2/2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD 0 siblings, 1 reply; 4+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-04 10:10 UTC (permalink / raw) To: barebox Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- commands/login.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/commands/login.c b/commands/login.c index fb6bb35..f5429bc 100644 --- a/commands/login.c +++ b/commands/login.c @@ -20,6 +20,10 @@ #include <complete.h> #include <password.h> #include <getopt.h> +#include <environment.h> +#include <globalvar.h> +#include <magicvar.h> +#include <init.h> #define PASSWD_MAX_LENGTH (128 + 1) @@ -31,6 +35,16 @@ #define LOGIN_MODE HIDE #endif +static void login_getenv_int(const char *name, int *i) +{ + const char* str = getenv(name); + + if (!str) + return; + + *i = simple_strtoul(str, NULL, 10); +} + static int do_login(int argc, char *argv[]) { unsigned char passwd[PASSWD_MAX_LENGTH]; @@ -38,6 +52,8 @@ static int do_login(int argc, char *argv[]) int timeout = 0; char *timeout_cmd = "boot"; + login_getenv_int("global.login.timeout", &timeout); + if (!is_passwd_enable()) { puts("login: password not set\n"); return 0; @@ -80,3 +96,13 @@ BAREBOX_CMD_START(login) BAREBOX_CMD_HELP(cmd_login_help) BAREBOX_CMD_COMPLETE(empty_complete) BAREBOX_CMD_END + +static int login_global_init(void) +{ + globalvar_add_simple("login.timeout"); + + return 0; +} +late_initcall(login_global_init); + +BAREBOX_MAGICVAR_NAMED(global_login_timeout, global.login.timeout, "timeout to type the password"); -- 1.8.4.rc1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] defaultenv-2: add login support 2013-09-04 10:10 ` [PATCH 1/2] login: add globalvar timeout support Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-04 10:10 ` Jean-Christophe PLAGNIOL-VILLARD 2013-09-06 7:06 ` Sascha Hauer 0 siblings, 1 reply; 4+ messages in thread From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-04 10:10 UTC (permalink / raw) To: barebox request password to login is a timeout is specified and /env/etc/passwd present Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- defaultenv-2/base/bin/init | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init index ca02ba6..e696dce 100644 --- a/defaultenv-2/base/bin/init +++ b/defaultenv-2/base/bin/init @@ -16,11 +16,15 @@ global editcmd=sedit [ -e /env/config-board ] && /env/config-board /env/config +# request password to login is a timeout is specified and /env/etc/passwd present +[ -n ${global.login.timeout} ] && login_cmd=login + # allow to stop the boot before execute the /env/init/* # but without waiting timeout -s -a -v key 0 if [ "${key}" = "q" ]; then + ${login_cmd} exit fi @@ -38,6 +42,7 @@ timeout -a $global.autoboot_timeout -v key autoboot="$?" if [ "${key}" = "q" ]; then + ${login_cmd} exit fi @@ -48,7 +53,11 @@ fi if [ -e /env/menu ]; then if [ "${key}" != "m" ]; then echo -e "\ntype exit to get to the menu" + ${login_cmd} sh fi + ${login_cmd} /env/menu/mainmenu fi + +${login_cmd} -- 1.8.4.rc1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] defaultenv-2: add login support 2013-09-04 10:10 ` [PATCH 2/2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-06 7:06 ` Sascha Hauer 0 siblings, 0 replies; 4+ messages in thread From: Sascha Hauer @ 2013-09-06 7:06 UTC (permalink / raw) To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox On Wed, Sep 04, 2013 at 12:10:12PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > request password to login is a timeout is specified and /env/etc/passwd > present > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> > --- > defaultenv-2/base/bin/init | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init > index ca02ba6..e696dce 100644 > --- a/defaultenv-2/base/bin/init > +++ b/defaultenv-2/base/bin/init > @@ -16,11 +16,15 @@ global editcmd=sedit > [ -e /env/config-board ] && /env/config-board > /env/config > > +# request password to login is a timeout is specified and /env/etc/passwd present > +[ -n ${global.login.timeout} ] && login_cmd=login > + > # allow to stop the boot before execute the /env/init/* > # but without waiting > timeout -s -a -v key 0 > > if [ "${key}" = "q" ]; then > + ${login_cmd} > exit > fi > > @@ -38,6 +42,7 @@ timeout -a $global.autoboot_timeout -v key > autoboot="$?" > > if [ "${key}" = "q" ]; then > + ${login_cmd} > exit > fi > > @@ -48,7 +53,11 @@ fi > if [ -e /env/menu ]; then > if [ "${key}" != "m" ]; then > echo -e "\ntype exit to get to the menu" > + ${login_cmd} > sh > fi > + ${login_cmd} > /env/menu/mainmenu You should do it like this: if [ -e /env/menu ]; then ${login_cmd} if [ "${key}" != "m" ]; then echo -e "\ntype exit to get to the menu" sh fi /env/menu/mainmenu fi Otherwise you get prompted for a password when entering the shell and agin when going to the menu. 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-06 7:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-09-04 10:01 [PATCH 0/2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD 2013-09-04 10:10 ` [PATCH 1/2] login: add globalvar timeout support Jean-Christophe PLAGNIOL-VILLARD 2013-09-04 10:10 ` [PATCH 2/2] defaultenv-2: add login support Jean-Christophe PLAGNIOL-VILLARD 2013-09-06 7:06 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox