loginutils, login prompt

Denys Vlasenko vda.linux at googlemail.com
Tue Jan 29 14:09:12 UTC 2019


‪On Mon, Jan 28, 2019 at 10:36 AM ‫אלכסיי סיליוק‬‎
<alex.silyuk at gmail.com> wrote:‬
>
> hello, I am using loginutils, and I see that
> at login prompt if I entering username incorrect and want to remove part of username, I cant to edit it, in code I see you using getting username char by char, I want to get name only after entering and I will write patch for myself.

This code should be handling it? CTL(H) / 0x7f case labels:

                /* Read name, watch for break, erase, kill, end-of-line */
                bp = G.line_buf;
                while (1) {
                        /* Do not report trivial EINTR/EIO errors */
                        errno = EINTR; /* make read of 0 bytes be silent too */
                        if (read(STDIN_FILENO, &c, 1) < 1) {
                                finalize_tty_attrs();
                                if (errno == EINTR || errno == EIO)
                                        exit(EXIT_SUCCESS);
                                bb_perror_msg_and_die(bb_msg_read_error);
                        }

                        switch (c) {
                        case '\r':
                        case '\n':
                                *bp = '\0';
                                G.eol = c;
                                goto got_logname;
                        case CTL('H'):
                        case 0x7f:
                                G.tty_attrs.c_cc[VERASE] = c;
                                if (bp > G.line_buf) {
                                        full_write(STDOUT_FILENO,
"\010 \010", 3);
                                        bp--;
                                }
                                break;

Can you diagnose why this does not work for you?


More information about the busybox mailing list