]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: use CTRL+C to erase username
authorKarel Zak <kzak@redhat.com>
Fri, 30 Jul 2021 09:50:46 +0000 (11:50 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 30 Jul 2021 09:50:46 +0000 (11:50 +0200)
aggety(8) from the beginning ignores ^C (the small exception was
between 2.32 and 2.34 when this char has been misinterpreted).

This patch forces agetty to interpret ^C like ^U, it means to
erase the user's input and wait for a completely new username.
The small difference is that for ^C it does not set 'kill character'.

This change does not affect serial lines where ^C is still ignored like
in previous decades. I'd like to avoid any regression as I have
no clue if any serial lines do not send this control char in some
context ...

Fixes: https://github.com/karelzak/util-linux/issues/1399
References: https://github.com/karelzak/util-linux/issues/1046
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/agetty.c

index 3b3d5101adda3dd740ee499ad7ef72b3fd01dd6b..d072d64d3a51e0c73e68e939e030c32f6e2b7c3a 100644 (file)
@@ -2267,6 +2267,11 @@ static char *get_logname(struct issue *ie, struct options *op, struct termios *t
                                break;
                        case CTL('U'):
                                cp->kill = ascval;              /* set kill character */
+                               /* fallthrough */
+                       case CTL('C'):
+                               if (key == CTL('C') && !(op->flags & F_VCONSOLE))
+                                       /* Ignore CTRL+C on serial line */
+                                       break;
                                while (bp > logname) {
                                        if ((tp->c_lflag & ECHO) == 0)
                                                write_all(1, erase[cp->parity], 3);
@@ -2275,9 +2280,6 @@ static char *get_logname(struct issue *ie, struct options *op, struct termios *t
                                break;
                        case CTL('D'):
                                exit(EXIT_SUCCESS);
-                       case CTL('C'):
-                               /* Ignore */
-                               break;
                        default:
                                if ((size_t)(bp - logname) >= sizeof(logname) - 1)
                                        log_err(_("%s: input overrun"), op->tty);