All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Brabec <sbrabec@suse.cz>
To: Karel Zak <kzak@redhat.com>, Lubomir Rintel <lkundrak@v3.sk>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH v2] agetty: don't put the VC into canonical mode
Date: Thu, 18 Oct 2018 21:25:33 +0200	[thread overview]
Message-ID: <9313c880-265c-908a-6138-c8f24d6c434e@suse.cz> (raw)
In-Reply-To: <20181016074053.dea6ydle26y37uva@ws.net.home>

On Oct 16, 2018 at 9:40 AM Karel Zak wrote:
> On Tue, Oct 16, 2018 at 08:41:49AM +0200, Lubomir Rintel wrote:
>> Seems like zero lflags do the job just fine on a Linux VT. Reset it to
>> canonical mode before running login.
> 
> What about Del/Backspace keys when user is typing login name? :-)

It could be easy without Backspace support. Just read the characters.
But we have to implement Backspace.

When you leave canonical mode, then agetty code has to handle Backspace.

Hopefully, agetty doesn't support arrows and Delete (forward delete),
so we don't have to implement advanced parts of line editing.

My experiments show two possibilities. I am not sure, what is better,
but 1 seems to be more straightforward.


1) c_lflag &= ~(ICANON | ECHO)

This falls back to a no echo mode. Program has to handle echo and
buffer parsing. Program has to handle backspace.

The implementation seems to be straightforward.

Downside: Remote logins can experience delays when getting echo.


2) c_lflag &= ~(ICANON)

Non-canonical mode with echo seems to be usable as well. The terminal
itself does the echo, program does the input parsing. Program has to
handle Backspace. Echo will be immediate even with slow remote logins,
but Backspace has to be handled remotely.

The second implementation has a problem: The Linux console input and
output are out of sync in the time of agetty. Input returns 0x7f after
pressing backspace, but output does back step (not back space) after
sending 0x08. I don't know the fix yet.

Even with a proper configuration of erase character, terminal
in a non-canonical mode cannot do a back space. At the best, it will
do back step.

So, in the echo mode, program has to handle Backspace not only for
the input, but also for the output: Print a space to erase the deleted
character and then one back step again.

This approach is vulnerable to race: New letter is typed before
processing of backspace is not finished yet. But if I am correct, this
race will not affect the result on the screen.


-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                         e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa)                  tel: +49 911 7405384547
186 00 Praha 8-Karlín                          fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76

  reply	other threads:[~2018-10-18 19:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16  6:41 [PATCH v2] agetty: don't put the VC into canonical mode Lubomir Rintel
2018-10-16  7:40 ` Karel Zak
2018-10-18 19:25   ` Stanislav Brabec [this message]
2018-10-19  7:53     ` Karel Zak
2018-10-19  6:09   ` Lubomir Rintel
2018-10-19 13:08     ` Stanislav Brabec
2018-10-19 13:48       ` Lubomir Rintel
2018-10-19 20:08         ` Stanislav Brabec
2018-10-22  9:23           ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9313c880-265c-908a-6138-c8f24d6c434e@suse.cz \
    --to=sbrabec@suse.cz \
    --cc=kzak@redhat.com \
    --cc=lkundrak@v3.sk \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.