[PATCH 4/5] cmd: allow disabling of timeout for password entry

Steffen Jaeckel jaeckel-floss at eyet-services.de
Tue Apr 13 00:15:22 CEST 2021


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 at eyet-services.de>
---

 cmd/Kconfig       | 8 ++++++++
 common/autoboot.c | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index c735e81b37..03c07d0f32 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -177,6 +177,14 @@ config CMD_SBI
 	help
 	  Display information about the SBI implementation.
 
+config AUTOBOOT_NEVER_TIMEOUT
+	bool "Make the password entry never time-out"
+	depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION
+	help
+	  This option removes the timeout from the password entry
+	  when the user first presses the <Enter> key before entering
+	  any other character.
+
 endmenu
 
 menu "Boot commands"
diff --git a/common/autoboot.c b/common/autoboot.c
index 5bda3da7b1..467333db9d 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -62,6 +62,7 @@ static int passwd_abort_crypt(uint64_t etime)
 	char presskey[DELAY_STOP_STR_MAX_LENGTH];
 	u_int presskey_len = 0;
 	int abort = 0;
+	int never_timeout = 0;
 
 	if (IS_ENABLED(HAS_STOP_STR_CRYPT) && !crypt_env_str)
 		crypt_env_str = AUTOBOOT_STOP_STR_ENC;
@@ -82,6 +83,11 @@ static int passwd_abort_crypt(uint64_t etime)
 
 			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';
 				crypt_compare(crypt_env_str, presskey, &abort);
 				/* you had one chance */
@@ -90,7 +96,7 @@ static int passwd_abort_crypt(uint64_t etime)
 				presskey_len++;
 			}
 		}
-	} while (get_ticks() <= etime);
+	} while (never_timeout || get_ticks() <= etime);
 
 	return abort;
 }
-- 
2.30.1



More information about the U-Boot mailing list