diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-09-01 09:43:54 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-09-01 09:43:54 +0200 |
commit | 049fb66d212caf2324e6ef2920c44b59858fc04d (patch) | |
tree | 5afd9e06c6a95e20e2cfe377a82fed28bc5ede11 /commands | |
parent | feeb12878871e89a4c3da3b1d7dc644e84d67da0 (diff) | |
parent | 460cc8219121c042dbac4f1cd527ccfacd8f7c72 (diff) | |
download | barebox-049fb66d212caf2324e6ef2920c44b59858fc04d.tar.gz barebox-049fb66d212caf2324e6ef2920c44b59858fc04d.tar.xz |
Merge branch 'for-next/login'
Diffstat (limited to 'commands')
-rw-r--r-- | commands/Kconfig | 12 | ||||
-rw-r--r-- | commands/login.c | 70 | ||||
-rw-r--r-- | commands/menutree.c | 3 |
3 files changed, 11 insertions, 74 deletions
diff --git a/commands/Kconfig b/commands/Kconfig index 25ed9ddafb..630cb12169 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -928,7 +928,7 @@ config CMD_LS config CMD_MD5SUM tristate select COMPILE_HASH - select MD5 + select DIGEST_MD5_GENERIC prompt "md5sum" help Usage: md5sum FILE|AREA... @@ -993,7 +993,7 @@ config CMD_RMDIR config CMD_SHA1SUM tristate select COMPILE_HASH - select SHA1 + select DIGEST_SHA1_GENERIC prompt "sha1sum" help Calculate SHA1 digest @@ -1005,7 +1005,7 @@ config CMD_SHA1SUM config CMD_SHA224SUM tristate select COMPILE_HASH - select SHA224 + select DIGEST_SHA224_GENERIC prompt "sha224sum" help Calculate SHA224 digest @@ -1017,7 +1017,7 @@ config CMD_SHA224SUM config CMD_SHA256SUM tristate select COMPILE_HASH - select SHA256 + select DIGEST_SHA256_GENERIC prompt "sha256sum" help sha256sum - calculate SHA256 digest @@ -1029,7 +1029,7 @@ config CMD_SHA256SUM config CMD_SHA384SUM tristate select COMPILE_HASH - select SHA384 + select DIGEST_SHA384_GENERIC prompt "sha384sum" help Calculate SHA384 digest @@ -1041,7 +1041,7 @@ config CMD_SHA384SUM config CMD_SHA512SUM tristate select COMPILE_HASH - select SHA512 + select DIGEST_SHA512_GENERIC prompt "sha512sum" help sha512sum - calculate SHA512 digest diff --git a/commands/login.c b/commands/login.c index bf5085c854..58bb592900 100644 --- a/commands/login.c +++ b/commands/login.c @@ -19,89 +19,23 @@ #include <command.h> #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) - -#if defined(CONFIG_PASSWD_MODE_STAR) -#define LOGIN_MODE STAR -#elif defined(CONFIG_PASSWD_MODE_CLEAR) -#define LOGIN_MODE CLEAR -#else -#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 = login_timeout; - char *timeout_cmd = "boot"; - - console_allow_input(true); - if (!is_passwd_enable()) { - puts("login: password not set\n"); - return 0; - } - - while((opt = getopt(argc, argv, "t:")) > 0) { - switch(opt) { - case 't': - timeout = simple_strtoul(optarg, NULL, 10); - break; - } - } - - if (optind != argc) - timeout_cmd = argv[optind]; - - do { - puts("Password: "); - passwd_len = password(passwd, PASSWD_MAX_LENGTH, LOGIN_MODE, timeout); - - if (passwd_len < 0) { - console_allow_input(false); - run_command(timeout_cmd); - } - - if (check_passwd(passwd, passwd_len) == 1) - return 0; - } while(1); + login(); return 0; } BAREBOX_CMD_HELP_START(login) BAREBOX_CMD_HELP_TEXT("Asks for a password from the console before script execution continues.") -BAREBOX_CMD_HELP_TEXT("The password can be set with the 'passwd' command. Instead of specifying") -BAREBOX_CMD_HELP_TEXT("a TIMEOUT the magic variable 'global.login.timeout' could be set.") -BAREBOX_CMD_HELP_TEXT("") -BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT("-t TIMEOUT", "Execute COMMAND if no login withing TIMEOUT seconds") +BAREBOX_CMD_HELP_TEXT("The password can be set with the 'passwd' command.") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(login) .cmd = do_login, BAREBOX_CMD_DESC("ask for a password") - BAREBOX_CMD_OPTS("[-t TIMEOUT] COMMAND") BAREBOX_CMD_GROUP(CMD_GRP_CONSOLE) 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/menutree.c b/commands/menutree.c index 5d30b67ee5..ea5f65f3a1 100644 --- a/commands/menutree.c +++ b/commands/menutree.c @@ -12,12 +12,15 @@ #include <common.h> #include <getopt.h> #include <menu.h> +#include <password.h> static int do_menutree(int argc, char *argv[]) { int opt, ret; char *path = "/env/menu"; + login(); + while ((opt = getopt(argc, argv, "m:")) > 0) { switch (opt) { case 'm': |