login: Follow timeout guidelines when password returns in time
If there's noise in the serial line, it will usually end up in Password: prompt and after timeout, autoboot process will be triggered. However, if the noise is translated to \n or whatever character code used to finish the password string, the login() funcion will against request the password() with the full timeout. If the noise keeps printing the \n or similar character with a high frequency, barebox will become stuck in the boot process. Related: SYS#4128
This commit is contained in:
parent
ca1b8e0ef2
commit
a07b1b7503
|
@ -25,6 +25,7 @@
|
|||
#include <magicvar.h>
|
||||
#include <init.h>
|
||||
#include <console.h>
|
||||
#include <clock.h>
|
||||
|
||||
#define PASSWD_MAX_LENGTH (128 + 1)
|
||||
|
||||
|
@ -44,6 +45,7 @@ static int do_login(int argc, char *argv[])
|
|||
int passwd_len, opt;
|
||||
int timeout = login_timeout;
|
||||
char *timeout_cmd = "boot";
|
||||
uint64_t start;
|
||||
|
||||
console_allow_input(true);
|
||||
if (!is_passwd_enable()) {
|
||||
|
@ -62,19 +64,21 @@ static int do_login(int argc, char *argv[])
|
|||
if (optind != argc)
|
||||
timeout_cmd = argv[optind];
|
||||
|
||||
start = get_time_ns();
|
||||
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 (passwd_len < 0)
|
||||
goto trigger_timeout;
|
||||
|
||||
if (check_passwd(passwd, passwd_len) == 1)
|
||||
return 0;
|
||||
} while(1);
|
||||
} while(!is_timeout(start, timeout * SECOND) || timeout == 0);
|
||||
|
||||
trigger_timeout:
|
||||
console_allow_input(false);
|
||||
run_command(timeout_cmd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue