common: allow disabling of timeout for password entry
In case a user has to enter a complicated password it is sometimes
desireable to give the user more time than the default timeout.
Enabling this feature will disable the timeout entirely in case the user
presses the <Enter> key before entering any other character.
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/common/autoboot.c b/common/autoboot.c
index 832ef7c..2564ef8 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -63,6 +63,10 @@
* or
* the config value CONFIG_AUTOBOOT_STOP_STR_CRYPT
*
+ * In case the config value CONFIG_AUTOBOOT_NEVER_TIMEOUT has been enabled
+ * this function never times out if the user presses the <Enter> key
+ * before starting to enter the password.
+ *
* @etime: Timeout value ticks (stop when get_ticks() reachs this)
* @return 0 if autoboot should continue, 1 if it should stop
*/
@@ -72,6 +76,7 @@
char presskey[DELAY_STOP_STR_MAX_LENGTH];
u_int presskey_len = 0;
int abort = 0;
+ int never_timeout = 0;
int err;
if (IS_ENABLED(CONFIG_AUTOBOOT_STOP_STR_ENABLE) && !crypt_env_str)
@@ -91,6 +96,11 @@
if ((presskey[presskey_len] == '\r') ||
(presskey[presskey_len] == '\n')) {
+ if (IS_ENABLED(CONFIG_AUTOBOOT_NEVER_TIMEOUT) &&
+ !presskey_len) {
+ never_timeout = 1;
+ continue;
+ }
presskey[presskey_len] = '\0';
err = crypt_compare(crypt_env_str, presskey,
&abort);
@@ -104,7 +114,7 @@
presskey_len++;
}
}
- } while (get_ticks() <= etime);
+ } while (never_timeout || get_ticks() <= etime);
return abort;
}