diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-10-07 08:00:13 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-10-07 08:00:13 +0200 |
commit | 9aa6dd027012892d14aa53f9c3d6965c37afc001 (patch) | |
tree | b97a8cb9ee8bf1c154ca52c010c9808d02b4fd85 /commands | |
parent | 408f054247fa7250546bc041b1deb306d0b9fa98 (diff) | |
parent | 666f12e0c19a19f4431e05f6e5b37e657a62038f (diff) | |
download | barebox-9aa6dd027012892d14aa53f9c3d6965c37afc001.tar.gz barebox-9aa6dd027012892d14aa53f9c3d6965c37afc001.tar.xz |
Merge branch 'for-next/login'
Conflicts:
include/console.h
Diffstat (limited to 'commands')
-rw-r--r-- | commands/login.c | 24 | ||||
-rw-r--r-- | commands/passwd.c | 8 |
2 files changed, 26 insertions, 6 deletions
diff --git a/commands/login.c b/commands/login.c index fb6bb35cfc..b616bf15fc 100644 --- a/commands/login.c +++ b/commands/login.c @@ -20,6 +20,11 @@ #include <complete.h> #include <password.h> #include <getopt.h> +#include <environment.h> +#include <globalvar.h> +#include <magicvar.h> +#include <init.h> +#include <console.h> #define PASSWD_MAX_LENGTH (128 + 1) @@ -31,13 +36,16 @@ #define LOGIN_MODE HIDE #endif +static int login_timeout = 0; + static int do_login(int argc, char *argv[]) { unsigned char passwd[PASSWD_MAX_LENGTH]; int passwd_len, opt; - int timeout = 0; + int timeout = login_timeout; char *timeout_cmd = "boot"; + console_allow_input(true); if (!is_passwd_enable()) { puts("login: password not set\n"); return 0; @@ -58,8 +66,10 @@ static int do_login(int argc, char *argv[]) puts("Password: "); passwd_len = password(passwd, PASSWD_MAX_LENGTH, LOGIN_MODE, timeout); - if (passwd_len < 0) + if (passwd_len < 0) { + console_allow_input(false); run_command(timeout_cmd, 0); + } if (check_passwd(passwd, passwd_len)) return 0; @@ -80,3 +90,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_int("login.timeout", &login_timeout, "%d"); + + return 0; +} +late_initcall(login_global_init); + +BAREBOX_MAGICVAR_NAMED(global_login_timeout, global.login.timeout, "timeout to type the password"); diff --git a/commands/passwd.c b/commands/passwd.c index baccfa6c0c..368c4016b9 100644 --- a/commands/passwd.c +++ b/commands/passwd.c @@ -63,7 +63,7 @@ static int do_passwd(int argc, char *argv[]) goto err; } - ret = set_passwd(passwd1, passwd1_len); + ret = set_env_passwd(passwd1, passwd1_len); if (ret < 0) { puts("Sorry, passwords write failed\n"); @@ -78,15 +78,15 @@ err: return 1; disable: - passwd_disable(); + passwd_env_disable(); puts("passwd: password disabled\n"); return ret; } static const __maybe_unused char cmd_passwd_help[] = "Usage: passwd\n" -"passwd allow you to specify a password\n" -"to disable it put an empty password\n" +"passwd allow you to specify a password in the env\n" +"to disable it put an empty password will still use the default password if set\n" ; BAREBOX_CMD_START(passwd) |