Bug 1252764
Summary: | icrnl is not set when autologin is used | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Stefan Assmann <sassmann> |
Component: | util-linux | Assignee: | Karel Zak <kzak> |
Status: | CLOSED ERRATA | QA Contact: | Radka Brychtova <rskvaril> |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 7.2 | CC: | dtardon, fsumsal, jkejda, mkolbas, msekleta, rskvaril, svashisht, vinschen |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | util-linux-2.23.2-56.el7 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-10-30 10:52:39 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1420851, 1466365, 1549617, 1551061 |
Description
Stefan Assmann
2015-08-12 08:36:46 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)? 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 (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 Any update? Can we get this fixed? 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 } Reassigning to systemd. See commit 3c4230a5afb27faec2176d4642c0e2e145971b5c in https://lists.freedesktop.org/archives/systemd-commits/2015-January/007818.html So if I understood this issue correctly we can close it as "fixed in current release" right? 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? 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'). 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. 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? No known fix yet, moving to 7.6. 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... 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 It would be nice if someone can test this solution. I can prepare a test build with the agetty patch. Karel, point me to the build, I can test. 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 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 |