Re: [PATCH v2] agetty: don't put the VC into canonical mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2018-10-16 at 09:40 +0200, Karel Zak wrote:
> On Tue, Oct 16, 2018 at 08:41:49AM +0200, Lubomir Rintel wrote:
> > The wait_for_term_input()'s select() needs to be tripped when the
> > user
> > starts typing. Otherwise the reloads can abort an already in-
> > progress login.
> > 
> > Coupled with \4 and \6 expansions that happen to be there on Fedora
> > Server,
> > this means reload on every netlink event. With a couple of IPv6
> > routers
> > announcing their networks and temporary addresses in use can make
> > it
> > sometimes virtually impossible to log in.
> 
> It's too late for v2.33. It also seems we need to wait for
> Stanislav's
> work on this issue -- his idea is to complete disable the reload
> notification when user start typing, and it also requires to switch
> to non-canonical mode.
> 
> This is definitely something we need to fix in v2.34 and v2.33.1.
> 
> > 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? :-)

They seem to work the same as they used to?

>From Stanislav's message I notice that there's supposed to be some
problem with them -- I'm not seeing that. Either the patch does
something different or I'm not looking at the right thing.

(I haven't looked at Stanislav's patch -- but I surely intend to give
it a try.)

Lubo

> 
>     Karel
> 
> > Signed-off-by: Lubomir Rintel <lkundrak@xxxxx>
> > 
> > ---
> > Changes since v1:
> > - Unreversed the logic in termio_final()/reset_vc() conditional
> > 
> > Tested on a vc and serial console on a stock Fedora installation:
> > 
> >   /sbin/agetty -o -p -- \u --noclear tty1 linux
> >   /sbin/agetty -o -p -- \u --keep-baud 115200,38400,9600 ttyS2
> > vt220
> > 
> >  term-utils/agetty.c | 26 ++++++++++++++++++--------
> >  1 file changed, 18 insertions(+), 8 deletions(-)
> > 
> > diff --git a/term-utils/agetty.c b/term-utils/agetty.c
> > index 3c87ec64e..3834813f1 100644
> > --- a/term-utils/agetty.c
> > +++ b/term-utils/agetty.c
> > @@ -303,7 +303,7 @@ static void parse_speeds(struct options *op,
> > char *arg);
> >  static void update_utmp(struct options *op);
> >  static void open_tty(char *tty, struct termios *tp, struct options
> > *op);
> >  static void termio_init(struct options *op, struct termios *tp);
> > -static void reset_vc (const struct options *op, struct termios
> > *tp);
> > +static void reset_vc(const struct options *op, struct termios *tp,
> > int canon);
> >  static void auto_baud(struct termios *tp);
> >  static void list_speeds(void);
> >  static void output_special_char (unsigned char c, struct options
> > *op,
> > @@ -485,13 +485,14 @@ int main(int argc, char **argv)
> >  	if (options.timeout)
> >  		alarm(0);
> >  
> > -	if ((options.flags & F_VCONSOLE) == 0) {
> > -		/* Finalize the termios settings. */
> > +	/* Finalize the termios settings. */
> > +	if ((options.flags & F_VCONSOLE) == 0)
> >  		termio_final(&options, &termios, &chardata);
> > +	else
> > +		reset_vc(&options, &termios, 1);
> >  
> > -		/* Now the newline character should be properly
> > written. */
> > -		write_all(STDOUT_FILENO, "\r\n", 2);
> > -	}
> > +	/* Now the newline character should be properly written. */
> > +	write_all(STDOUT_FILENO, "\r\n", 2);
> >  
> >  	sigaction(SIGQUIT, &sa_quit, NULL);
> >  	sigaction(SIGINT, &sa_int, NULL);
> > @@ -1234,7 +1235,7 @@ static void termio_init(struct options *op,
> > struct termios *tp)
> >  		setlocale(LC_CTYPE, "POSIX");
> >  		op->flags &= ~F_UTF8;
> >  #endif
> > -		reset_vc(op, tp);
> > +		reset_vc(op, tp, 0);
> >  
> >  		if ((tp->c_cflag & (CS8|PARODD|PARENB)) == CS8)
> >  			op->flags |= F_EIGHTBITS;
> > @@ -1344,7 +1345,7 @@ static void termio_init(struct options *op,
> > struct termios *tp)
> >  }
> >  
> >  /* Reset virtual console on stdin to its defaults */
> > -static void reset_vc(const struct options *op, struct termios *tp)
> > +static void reset_vc(const struct options *op, struct termios *tp,
> > int canon)
> >  {
> >  	int fl = 0;
> >  
> > @@ -1353,6 +1354,15 @@ static void reset_vc(const struct options
> > *op, struct termios *tp)
> >  
> >  	reset_virtual_console(tp, fl);
> >  
> > +#ifdef AGETTY_RELOAD
> > +	/*
> > +	 * Discard all the flags that makes the line go canonical with
> > echoing.
> > +	 * We need to know when the user starts typing.
> > +	 */
> > +	if (canon == 0)
> > +		tp->c_lflag = 0;
> > +#endif
> > +
> >  	if (tcsetattr(STDIN_FILENO, TCSADRAIN, tp))
> >  		log_warn(_("setting terminal attributes failed: %m"));
> >  
> > -- 
> > 2.19.1
> > 




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux