bug #60114: The "Backspace" key doesn't work correctly in the superuser authentication prompt.
Hi, yesterday I submitted a bug report about wrong backspace key behavior in superuser login prompt and I finally found it. So I attach patch with my fix so it can be merged into upstream.
From a227f1a2c54aa420e016ffb5ca1c41fe93a2bd68 Mon Sep 17 00:00:00 2001
From: Egor Ignatov <[email protected]>
Date: Fri, 26 Feb 2021 12:08:23 +0300
Subject: [PATCH] Fix backspace in username prompt
--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-)
grub-core/normal/auth.c +3 -1
@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +9 -2
@@ -846,8 +846,15 @@ grub_gfxterm_putchar (struct grub_term_output *term,switch (c->base) {case '\b' : -if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; +if (virtual_screen.cursor_x >0 ) + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4
Quoted 9 lines · Egor Ignatov
Hi, yesterday I submitted a bug report about wrong backspace key behavior in superuser login prompt and I finally found it. So I attach patch with my fix so it can be merged into upstream.
Quoted 1 line
From
a227f1a2c54aa420e016ffb5ca1c41fe93a2bd68Mon Sep 17 00:00:00 2001From: Egor Ignatov <[email protected]>
Date: Fri, 26 Feb 2021 12:08:23 +0300
Subject: [PATCH] Fix backspace in username prompt
May I ask you to use "git send-email" to send the patch?
Additionally, could you explain in the commit message why this patch is needed and what it does? And of course add your SOB...
Quoted 11 lines
--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-)grub-core/normal/auth.c +0
-0
grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 182
Quoted 7 lines
grub-core/normal/auth.c +3
-1@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" );
Why could not you leave original grub_printf() call?
Quoted 20 lines
grub-core/normal/auth.c +0
-0}continue ; }grub-core/normal/charset.c +1
-0@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :grub-core/term/gfxterm.c +0
-0
grub-core/term/gfxterm.c grub_gfxterm_putchar (struct grub_term_output *term, · line 852
Quoted 9 lines
grub-core/term/gfxterm.c +4
-2@@ -846,8 +846,15 @@ grub_gfxterm_putchar (struct grub_term_output *term,switch (c->base) {case '\b' : -if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; +if (virtual_screen.cursor_x >0 ) + { + virtual_screen.cursor_x--; + }
I think you can leave original "if" as is.
grub-core/term/gfxterm.c grub_gfxterm_putchar (struct grub_term_output *term, · line 857
Quoted 5 lines
grub-core/term/gfxterm.c +5
-0+else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }
Daniel