RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1252764 - icrnl is not set when autologin is used
Summary: icrnl is not set when autologin is used
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: util-linux
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Karel Zak
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks: 1420851 1466365 1549617 1551061
TreeView+ depends on / blocked
 
Reported: 2015-08-12 08:36 UTC by Stefan Assmann
Modified: 2021-12-10 14:30 UTC (History)
8 users (show)

Fixed In Version: util-linux-2.23.2-56.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-30 10:52:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:3178 0 None None None 2018-10-30 10:53:27 UTC

Description Stefan Assmann 2015-08-12 08:36:46 UTC
Description of problem:
When running RHEL7 in a VM on either a RHEL6 or RHEL7 host and connecting to the VM via "virsh console" the terminal has -icrnl set, which means cr is not properly converted to newline.

host:
root.eng.bos.redhat.com:~ # stty -a
speed 38400 baud; rows 38; columns 131; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
root.eng.bos.redhat.com:~ # virsh console rhel7-64-kvm
Connected to domain rhel7-64-kvm
Escape character is ^]

## now in guest ##
[root@rhel7 ~]# echo $TERM
vt102
[root@rhel7 ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke

When switching to tcsh this works nicely.
[root@rhel7 ~]# tcsh
[root@rhel7 ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Version-Release number of selected component (if applicable):
bash-4.2.46-12.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. install RHEL7 VM on RHEL6 or RHEL7
2. virsh console <VM>
3. stty -a

Actual results:
-icrnl is set

Expected results:
icrnl is set

Additional info:
I assume this is a bash issue, if not please reassign. icrnl is set when using a RHEL6 VM instead of a RHEL7 VM.

Comment 1 Ondrej Oprala 2015-08-12 09:14:58 UTC
You only switched to tcsh, once you were connected to the gueste machine, right? What happens, if you run "bash" again, once connected (instead of tcsh)?

Comment 2 Stefan Assmann 2015-08-12 09:17:20 UTC
correct!

running bash again doesn't help.
[root@rhel7 ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke
[root@rhel7 ~]# bash
[root@rhel7 ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke

Comment 3 Corinna Vinschen 2015-08-12 11:26:27 UTC
(In reply to Ondrej Oprala from comment #1)
> You only switched to tcsh, once you were connected to the gueste machine,
> right? What happens, if you run "bash" again, once connected (instead of
> tcsh)?

I'm usually using tcsh as login shell. When running `virsh console ...',
login immediately exec's tcsh.  In this case I get the desired "icrnl"
setting as well.  From the tcsh sources you can see that tcsh always sets
icrnl at startup (function ed_Setup in ed.init.c).

Two potential reasons come to mind:

- Either "-icrnl" is either some default of the bash version in RHEL7
  but not in RHEL6,

- or the default is set to "-icrnl" by agetty or login and RHEL7 bash
  doesn't override icrnl explicitely, while RHEL6 bash does.


Corinna

Comment 5 Stefan Assmann 2016-02-09 09:27:11 UTC
Any update? Can we get this fixed?

Comment 10 Siteshwar Vashisht 2016-05-10 15:56:33 UTC
This issue is reproducible on RHEL 7.1 (but not RHEL 7.2) and depends on the terminal type set by systemd for serial consoles.

RHEL 7.1 :

root@rhel7:~ # echo $TERM
vt102                                                                                                                                                                                                                                        
root@rhel7:~ # stty -a                                                                                                                                                                                                                       
speed 115200 baud; rows 61; columns 237; line = 0;                                                                                                                                                                                           
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;                                 
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts                                                                                                                                                                              
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff -iuclc -ixany -imaxbel iutf8                                                                                                                                  
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0                                                                                                                                                              
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt -echoctl echoke 

RHEL 7.2 :

[root@localhost 615]# echo $TERM
vt220
[root@localhost 615]# stty -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke

agetty takes value of console type as command line argument which is passed by systemd.

[Service]
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM
Type=idle

In 'term-utils/agetty.c' :

 731         if (argc > optind && argv[optind])
 732                 op->term = argv[optind];
 733 

and 'ICRNL' flag is set based on end of line character set by terminal type.

1675         /* Account for special characters seen in input. */
1676         if (cp->eol == CR) {
1677                 tp->c_iflag |= ICRNL;
1678                 tp->c_oflag |= ONLCR;
1679         }


Affected system is running package 'systemd-208-20.el7.x86_64' which defaults to 'vt102' for serial consoles :


3716 const char *default_term_for_tty(const char *tty) {
3717         assert(tty);
3718 
3719         return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt102";
3720 }

This function has been updated to default to 'vt220' for serial consoles in 'systemd-219-19.el7.x86_64' :

4027 const char *default_term_for_tty(const char *tty) {
4028         assert(tty);
4029 
4030         return tty_is_vc_resolve(tty) ? "TERM=linux" : "TERM=vt220";
4031 }

Comment 11 Siteshwar Vashisht 2016-05-10 16:11:23 UTC
Reassigning to systemd.

See commit 3c4230a5afb27faec2176d4642c0e2e145971b5c in https://lists.freedesktop.org/archives/systemd-commits/2015-January/007818.html

Comment 12 Lukáš Nykrýn 2016-05-10 16:35:08 UTC
So if I understood this issue correctly we can close it as "fixed in current release" right?

Comment 13 Stefan Assmann 2016-05-11 06:39:37 UTC
Don't think we're there just yet.
I've hardcoded vt220 in my RHEL7.1 VM /usr/lib/systemd/system/serial-getty@.service and the results are still the same.

[root@rhel7 ~]# echo $TERM
vt220
[root@rhel7 ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke


What I don't understand on Siteshwar's comment is that the state of icrnl seems to be determined by the fact that eol is defined. However in the RHEL7.2 example from comment #10 I see
"eol = <undef>;" together with "icrnl"
So maybe something else changed in 7.2 to make this work?

Comment 14 Siteshwar Vashisht 2016-05-11 09:28:13 UTC
systemd is responsible for setting up the terminal, so somebody from the systemd team should be able to clarify how carriage return is generated (May be this behaviour was introduced by 'libsystemd-terminal').

Comment 15 Lukáš Nykrýn 2016-05-11 11:12:18 UTC
libsystemd-terminal and consoled were not used in rhel in any way. In the fact the whole code was dropped in upstream later.

I think that the relevant code is this:
https://github.com/lnykryn/systemd-rhel/blob/master/src/shared/util.c#L1921
but that is the same as in 7.1 with exception of https://github.com/lnykryn/systemd-rhel/commit/067fbebee46a376c639c9369dcaf80004047414d but I don't think that it is related.

Comment 16 Stefan Assmann 2016-07-01 08:25:47 UTC
I can also reproduce this with f24 in host/guest. So the issue is still there.

[root@fedora ~]# uname -a
Linux fedora 4.5.7-300.fc24.x86_64 #1 SMP Wed Jun 8 18:12:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@fedora ~]# grep ExecStart /usr/lib/systemd/system/serial-getty@.service
ExecStart=-/sbin/agetty -a root --long-hostname --keep-baud 115200,38400,9600 %I $TERM
[root@fedora ~]# stty -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl echoke -flusho -extproc

What can we do about that?

Comment 21 Lukáš Nykrýn 2017-11-07 12:41:26 UTC
No known fix yet, moving to 7.6.

Comment 23 David Tardon 2018-06-04 15:06:09 UTC
agetty ignores the terminal settings done by systemd and does its own setup. The problem is that ICRNL is only set if cp->eol == CR, but cp->eol is set in get_logname(), which is not called if --autologin is used...

Comment 24 Karel Zak 2018-06-05 11:15:57 UTC
David is probably right. 

For virtual console agetty sets ICRNL by reset_virtual_console(). Unfortunately, for serial-line it does not care and during initialization all iflags are removed (except IUTF8).

 tp->c_iflag = tp->c_iflag & IUTF8;

Maybe all we need is to keep iflags unmodified on autologin. Something like:

diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index b626cdbeb..7d9ec7489 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -1100,13 +1100,16 @@ static void termio_init(struct options *op, struct termios *tp)
         /* Flush input and output queues, important for modems! */
        tcflush(STDIN_FILENO, TCIOFLUSH);
 
+       if (!op->autolog) {
 #ifdef IUTF8
-       tp->c_iflag = tp->c_iflag & IUTF8;
-       if (tp->c_iflag & IUTF8)
-               op->flags |= F_UTF8;
+               tp->c_iflag = tp->c_iflag & IUTF8;
+               if (tp->c_iflag & IUTF8)
+                       op->flags |= F_UTF8;
 #else
-       tp->c_iflag = 0;
+               tp->c_iflag = 0;
 #endif
+       }
+
        tp->c_lflag = 0;
        tp->c_oflag &= OPOST | ONL

Comment 25 Karel Zak 2018-06-05 11:18:38 UTC
It would be nice if someone can test this solution. I can prepare a test build with the agetty patch.

Comment 26 Stefan Assmann 2018-06-05 11:22:17 UTC
Karel, point me to the build, I can test.

Comment 27 David Tardon 2018-06-05 19:32:47 UTC
Yup, that works.

[root@debug ~]# echo $TERM 
vt220
[root@debug ~]# stty -a
speed 38400 baud; rows 49; columns 95; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff -iuclc -ixany
imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt -echoctl echoke
-flusho -extproc

Comment 35 errata-xmlrpc 2018-10-30 10:52:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3178


Note You need to log in before you can comment on or make changes to this bug.