util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname()
@ 2019-02-27 22:22 Stanislav Brabec
  2019-03-01  8:04 ` Lubomir Rintel
  2019-03-04 10:39 ` Karel Zak
  0 siblings, 2 replies; 4+ messages in thread
From: Stanislav Brabec @ 2019-02-27 22:22 UTC (permalink / raw)
  To: util-linux; +Cc: Lubomir Rintel

As login supports non-ASCII characters in the logname, agetty should be
consistent.

8b58ffdd re-activated old and ASCII-only get_logname(), which restricted
the input to ASCII only. As the code does not read whole characters,
isascii(ascval) and isprint(ascval) returns nonsenses after entering a
non-ASCII character.

As keyboard maps don't contain unprintable non-control characters, it
seems to be relatively safe to remove both checks.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Lubomir Rintel <lkundrak@v3.sk>
---
 term-utils/agetty.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 1a3ebc308..0ef8ba36d 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -2175,8 +2175,6 @@ static char *get_logname(struct issue *ie, struct options *op, struct termios *t
 			case CTL('D'):
 				exit(EXIT_SUCCESS);
 			default:
-				if (!isascii(ascval) || !isprint(ascval))
-					break;
 				if ((size_t)(bp - logname) >= sizeof(logname) - 1)
 					log_err(_("%s: input overrun"), op->tty);
 				if ((tp->c_lflag & ECHO) == 0)
-- 
2.20.1

-- 
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: +420 284 084 060
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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname()
  2019-02-27 22:22 [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname() Stanislav Brabec
@ 2019-03-01  8:04 ` Lubomir Rintel
  2019-03-01 20:34   ` Stanislav Brabec
  2019-03-04 10:39 ` Karel Zak
  1 sibling, 1 reply; 4+ messages in thread
From: Lubomir Rintel @ 2019-03-01  8:04 UTC (permalink / raw)
  To: Stanislav Brabec, util-linux

On Wed, 2019-02-27 at 23:22 +0100, Stanislav Brabec wrote:
> As login supports non-ASCII characters in the logname, agetty should be
> consistent.
> 
> 8b58ffdd re-activated old and ASCII-only get_logname(), which restricted

A nit: please use this form to refer to other commits in commit
messages:

commit 8b58ffdd ('agetty: don't put the VC into canonical mode')

It improves readability.

> the input to ASCII only. As the code does not read whole characters,
> isascii(ascval) and isprint(ascval) returns nonsenses after entering a
> non-ASCII character.
> 
> As keyboard maps don't contain unprintable non-control characters, it
> seems to be relatively safe to remove both checks.
> 
> Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
> Cc: Lubomir Rintel <lkundrak@v3.sk>
> ---
>  term-utils/agetty.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/term-utils/agetty.c b/term-utils/agetty.c
> index 1a3ebc308..0ef8ba36d 100644
> --- a/term-utils/agetty.c
> +++ b/term-utils/agetty.c
> @@ -2175,8 +2175,6 @@ static char *get_logname(struct issue *ie, struct options *op, struct termios *t
>  			case CTL('D'):
>  				exit(EXIT_SUCCESS);
>  			default:
> -				if (!isascii(ascval) || !isprint(ascval))
> -					break;
>  				if ((size_t)(bp - logname) >= sizeof(logname) - 1)
>  					log_err(_("%s: input overrun"), op->tty);
>  				if ((tp->c_lflag & ECHO) == 0)
> -- 
> 2.20.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname()
  2019-03-01  8:04 ` Lubomir Rintel
@ 2019-03-01 20:34   ` Stanislav Brabec
  0 siblings, 0 replies; 4+ messages in thread
From: Stanislav Brabec @ 2019-03-01 20:34 UTC (permalink / raw)
  To: Lubomir Rintel, util-linux

Dne 01. 03. 19 v 9:04 Lubomir Rintel napsal(a):
> 
>> the input to ASCII only. As the code does not read whole characters,
>> isascii(ascval) and isprint(ascval) returns nonsenses after entering a
>> non-ASCII character.
>>

I did a small research about special characters in logname (with UTF-8 locales):

works in:
chown
su
ls -l
whoami
chpasswd
passwd

explicitly rejected in:
useradd (shadow)

Independently on the policy of allowing/disallowing accented characters in lognames, not responding to some key presses in agetty is counter intuitive, especially if login (reading logname after first failed login attempt) accepts them.

-- 
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: +420 284 084 060
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname()
  2019-02-27 22:22 [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname() Stanislav Brabec
  2019-03-01  8:04 ` Lubomir Rintel
@ 2019-03-04 10:39 ` Karel Zak
  1 sibling, 0 replies; 4+ messages in thread
From: Karel Zak @ 2019-03-04 10:39 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux, Lubomir Rintel

On Wed, Feb 27, 2019 at 11:22:19PM +0100, Stanislav Brabec wrote:
>  term-utils/agetty.c | 2 --
>  1 file changed, 2 deletions(-)

Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-04 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 22:22 [PATCH 1/2] agetty: Fix input of non-ASCII characters in get_logname() Stanislav Brabec
2019-03-01  8:04 ` Lubomir Rintel
2019-03-01 20:34   ` Stanislav Brabec
2019-03-04 10:39 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).