Dear Daniel Kiper,
I hope this message finds you well.
My name is Andy Lau, and I am reaching out to discuss a small enhancement aimed at
improving the user experience within GRUB2. Following an excellent suggestion from Jiří "bindiff" Wolker,
I have implemented support for a new boolean environment variable called echo_password.
This variable allows users to control whether characters are echoed (displayed as *) when entering passwords in GRUB2.
Rationale for the Feature:
Enhanced User Experience:
In certain scenarios, such as during debugging or when users need confirmation of their input,
having some form of visual feedback—even if it's just asterisks—can be significantly helpful.
Maintaining Security and Flexibility: By default, no characters are echoed to ensure security.
However, enabling the echo_password option provides flexibility for users who may require visual confirmation without compromising on security.
I have thoroughly tested this functionality in my local environment.
The submitted patch titled “lib-crypto-Add-echo_password-boolean-environment-var. patch”
introduces this capability to optionally enable visual feedback during password input in GRUB2.
I personally have a strong interest in the development of GRUB2, and I look forward to contributing more to the community in the future.
Given your extensive experience and deep insights into the GRUB2 project,
I would greatly appreciate it if you could take the time to review this proposal.
Your feedback and any suggestions for improvement would be invaluable.
If there are no objections, I kindly ask for your consideration to merge this patch into the mainline.
Thank you very much for your time and consideration.
Best regards,
Andy Lau
[https://github.com/AndyLau-SOC]
How to reach me: liuyan...@kylinos.cn
-------------------------------------
From: Andy Lau <liuyan...@kylinos.cn>
Date: Thu, 29 May 2025 15:46:48 +0800
Subject: [PATCH] lib/crypto: Add echo_password boolean environment variable
for password echo
Implements character echo (e.g., '*') for user password input in GRUB.
Currently, there is no visual feedback during password entry, making it difficult for users
to confirm their input. therefore, using the echo_password boolean environment variable
allows users to decide for themselves whether to display their "password".
This change significantly improves the user experience.
Signed-off-by: Andy Lau <liuyan...@kylinos.cn>
---
grub-core/lib/crypto.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
index 396f76410..f28051778 100644
--- a/grub-core/lib/crypto.c
+++ b/grub-core/lib/crypto.c
@@ -455,6 +455,9 @@ grub_password_get (char buf[], unsigned buf_size)
{
unsigned cur_len = 0;
int key;
+ bool echo_password = false;
+
+ echo_password = grub_env_get_bool ("echo_password", false);
while (1)
{
@@ -471,7 +474,10 @@ grub_password_get (char buf[], unsigned buf_size)
if (key == '\b')
{
if (cur_len)
- cur_len--;
+ {
+ cur_len--;
+ grub_printf ("\b \b");
+ }
continue;
}
@@ -479,7 +485,12 @@ grub_password_get (char buf[], unsigned buf_size)
continue;
if (cur_len + 2 < buf_size)
- buf[cur_len++] = key;
+ {
+ buf[cur_len++] = key;
+ if (echo_password) {
+ grub_printf ("*");
+ }
+ }
}
grub_memset (buf + cur_len, 0, buf_size - cur_len);
--
2.34.1
----
lib-crypto-Add-echo_password-boolean-environment-var.patch
Description: Binary data
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel