From 18266d8ec7bb6f944fc0068dfc6e7e2a206b33883c0fa959f3227f6812d2eef5 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 10 Jan 2014 13:13:23 +0000 Subject: [PATCH 1/3] . OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=199 --- ...ty-fooled-on-serial-line-due-plymout.patch | 101 ++++++++++++++++++ util-linux.changes | 9 ++ util-linux.spec | 5 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 agetty-fooled-on-serial-line-due-plymout.patch diff --git a/agetty-fooled-on-serial-line-due-plymout.patch b/agetty-fooled-on-serial-line-due-plymout.patch new file mode 100644 index 0000000..dae4c0f --- /dev/null +++ b/agetty-fooled-on-serial-line-due-plymout.patch @@ -0,0 +1,101 @@ +Even with TTYReset=no it seems with systemd or plymouth the termios +flags become changed from under the first agetty on a serial system +console as the flags are locked. + +--- + agetty.c | 39 ++++++++++++++++++++++++++++++++------- + 1 file changed, 32 insertions(+), 7 deletions(-) + +--- term-utils/agetty.c ++++ term-utils/agetty.c 2014-01-10 13:05:50.411075349 +0000 +@@ -281,8 +281,9 @@ + static char *fakehost; + + #ifdef DEBUGGING ++# include "closestream.h" + # ifndef DEBUG_OUTPUT +-# define DEBUG_OUTPUT "/dev/ttyp0" ++# define DEBUG_OUTPUT "/dev/tty10" + # endif + # define debug(s) do { fprintf(dbf,s); fflush(dbf); } while (0) + FILE *dbf; +@@ -320,8 +321,12 @@ + + #ifdef DEBUGGING + dbf = fopen(DEBUG_OUTPUT, "w"); +- for (int i = 1; i < argc; i++) ++ for (int i = 1; i < argc; i++) { ++ if (i > 1) ++ debug(" "); + debug(argv[i]); ++ } ++ debug("\n"); + #endif /* DEBUGGING */ + + /* Parse command-line arguments. */ +@@ -473,7 +478,6 @@ + if (options.osrelease) + free(options.osrelease); + #ifdef DEBUGGING +- fprintf(dbf, "read %c\n", ch); + if (close_stream(dbf) != 0) + log_err("write failed: %s", DEBUG_OUTPUT); + #endif +@@ -1090,6 +1094,23 @@ + { + speed_t ispeed, ospeed; + struct winsize ws; ++ int i; ++ ++ for (i = 0; i < 10; i++) { ++ /* ++ * Even with TTYReset=no it seems with systemd or plymouth ++ * the termios flags become changed from under the first ++ * agetty on a serial system console as the flags are locked. ++ */ ++ struct termios lock; ++ memset(&lock, 0, sizeof(struct termios)); ++ if (ioctl(STDIN_FILENO, TIOCGLCKTRMIOS, &lock) < 0) ++ break; ++ if (!lock.c_iflag && !lock.c_oflag && !lock.c_cflag && !lock.c_lflag) ++ break; ++ debug("termios locked\n"); ++ tcsendbreak(STDIN_FILENO, 0); /* 0.25 upto 0.5 seconds */ ++ } + + if (op->flags & F_VCONSOLE) { + #if defined(IUTF8) && defined(KDGKBMODE) +@@ -1154,9 +1175,6 @@ + * later on. + */ + +- /* Flush input and output queues, important for modems! */ +- tcflush(STDIN_FILENO, TCIOFLUSH); +- + #ifdef IUTF8 + tp->c_iflag = tp->c_iflag & IUTF8; + if (tp->c_iflag & IUTF8) +@@ -1216,8 +1234,11 @@ + if (op->flags & F_RTSCTS) + tp->c_cflag |= CRTSCTS; + #endif ++ /* Flush input and output queues, important for modems! */ ++ tcflush(STDIN_FILENO, TCIOFLUSH); + +- tcsetattr(STDIN_FILENO, TCSANOW, tp); ++ if (tcsetattr(STDIN_FILENO, TCSANOW, tp)) ++ log_warn(_("setting terminal attributes failed: %m")); + + /* Go to blocking input even in local mode. */ + fcntl(STDIN_FILENO, F_SETFL, +@@ -1238,6 +1259,10 @@ + + if (tcsetattr(STDIN_FILENO, TCSADRAIN, tp)) + log_warn(_("setting terminal attributes failed: %m")); ++ ++ /* Go to blocking input even in local mode. */ ++ fcntl(STDIN_FILENO, F_SETFL, ++ fcntl(STDIN_FILENO, F_GETFL, 0) & ~O_NONBLOCK); + } + + /* Extract baud rate from modem status message. */ diff --git a/util-linux.changes b/util-linux.changes index baf13a7..ef9c134 100644 --- a/util-linux.changes +++ b/util-linux.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Fri Jan 10 13:08:45 UTC 2014 - werner@suse.de + +- Add patch + agetty-fooled-on-serial-line-due-plymout.patch + even with TTYReset=no it seems with systemd or plymouth the termios + flags become changed from under the first agetty on a serial system + console as the flags are locked (bnc#774126). + ------------------------------------------------------------------- Tue Dec 10 16:10:27 UTC 2013 - sweet_f_a@gmx.de diff --git a/util-linux.spec b/util-linux.spec index ead67ef..4ca12ea 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -1,7 +1,7 @@ # # spec file for package util-linux # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -108,6 +108,8 @@ Patch12: util-linux-2.23.1-noenc-suse.diff Patch13: blkdiscard-BLKSSZGET-fills-in-an-int.patch # PATCH-FIX-SUSE -- better support of S390 in agetty Patch14: tty3270-on-serial-line-of-s390.patch +# PATCH-FIX-SUSE -- Let agetty not be fooled by locked termios srtucture +Patch15: agetty-fooled-on-serial-line-due-plymout.patch # hack for boot.localfs Patch20: util-linux-HACK-boot.localfs.diff @@ -226,6 +228,7 @@ xzcat %{S:0} | %gpg_verify %{S:12} - %patch12 -p1 %patch13 -p1 %patch14 -p0 +%patch15 -p0 # %patch20 -p1 # From b7f38c041353bb299d5ba048eb7a3c30633f60e065a35c4eb53260051c3ee2d9 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 10 Jan 2014 13:23:44 +0000 Subject: [PATCH 2/3] . OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=200 --- agetty-fooled-on-serial-line-due-plymout.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/agetty-fooled-on-serial-line-due-plymout.patch b/agetty-fooled-on-serial-line-due-plymout.patch index dae4c0f..2b1a957 100644 --- a/agetty-fooled-on-serial-line-due-plymout.patch +++ b/agetty-fooled-on-serial-line-due-plymout.patch @@ -8,7 +8,7 @@ console as the flags are locked. --- term-utils/agetty.c +++ term-utils/agetty.c 2014-01-10 13:05:50.411075349 +0000 -@@ -281,8 +281,9 @@ +@@ -281,8 +281,9 @@ static void login_options_to_argv(char * static char *fakehost; #ifdef DEBUGGING @@ -19,7 +19,7 @@ console as the flags are locked. # endif # define debug(s) do { fprintf(dbf,s); fflush(dbf); } while (0) FILE *dbf; -@@ -320,8 +321,12 @@ +@@ -320,8 +321,12 @@ int main(int argc, char **argv) #ifdef DEBUGGING dbf = fopen(DEBUG_OUTPUT, "w"); @@ -33,7 +33,7 @@ console as the flags are locked. #endif /* DEBUGGING */ /* Parse command-line arguments. */ -@@ -473,7 +478,6 @@ +@@ -473,7 +478,6 @@ int main(int argc, char **argv) if (options.osrelease) free(options.osrelease); #ifdef DEBUGGING @@ -41,7 +41,7 @@ console as the flags are locked. if (close_stream(dbf) != 0) log_err("write failed: %s", DEBUG_OUTPUT); #endif -@@ -1090,6 +1094,23 @@ +@@ -1090,6 +1094,23 @@ static void termio_init(struct options * { speed_t ispeed, ospeed; struct winsize ws; @@ -65,7 +65,7 @@ console as the flags are locked. if (op->flags & F_VCONSOLE) { #if defined(IUTF8) && defined(KDGKBMODE) -@@ -1154,9 +1175,6 @@ +@@ -1154,9 +1175,6 @@ static void termio_init(struct options * * later on. */ @@ -75,7 +75,7 @@ console as the flags are locked. #ifdef IUTF8 tp->c_iflag = tp->c_iflag & IUTF8; if (tp->c_iflag & IUTF8) -@@ -1216,8 +1234,11 @@ +@@ -1216,8 +1234,11 @@ static void termio_init(struct options * if (op->flags & F_RTSCTS) tp->c_cflag |= CRTSCTS; #endif @@ -88,7 +88,7 @@ console as the flags are locked. /* Go to blocking input even in local mode. */ fcntl(STDIN_FILENO, F_SETFL, -@@ -1238,6 +1259,10 @@ +@@ -1238,6 +1259,10 @@ static void reset_vc(const struct option if (tcsetattr(STDIN_FILENO, TCSADRAIN, tp)) log_warn(_("setting terminal attributes failed: %m")); From 50031106a14708ff4fa2eaefce46d5089d798ceace7484397a5ee4114bab1cf1 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 10 Jan 2014 14:07:34 +0000 Subject: [PATCH 3/3] . OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=201 --- ...out.patch => agetty-fooled-on-serial-line-due-plymouth.patch | 2 +- util-linux.changes | 2 +- util-linux.spec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename agetty-fooled-on-serial-line-due-plymout.patch => agetty-fooled-on-serial-line-due-plymouth.patch (99%) diff --git a/agetty-fooled-on-serial-line-due-plymout.patch b/agetty-fooled-on-serial-line-due-plymouth.patch similarity index 99% rename from agetty-fooled-on-serial-line-due-plymout.patch rename to agetty-fooled-on-serial-line-due-plymouth.patch index 2b1a957..8efb5e8 100644 --- a/agetty-fooled-on-serial-line-due-plymout.patch +++ b/agetty-fooled-on-serial-line-due-plymouth.patch @@ -47,7 +47,7 @@ console as the flags are locked. struct winsize ws; + int i; + -+ for (i = 0; i < 10; i++) { ++ for (i = 0; i < 20; i++) { + /* + * Even with TTYReset=no it seems with systemd or plymouth + * the termios flags become changed from under the first diff --git a/util-linux.changes b/util-linux.changes index ef9c134..19f0687 100644 --- a/util-linux.changes +++ b/util-linux.changes @@ -2,7 +2,7 @@ Fri Jan 10 13:08:45 UTC 2014 - werner@suse.de - Add patch - agetty-fooled-on-serial-line-due-plymout.patch + agetty-fooled-on-serial-line-due-plymouth.patch even with TTYReset=no it seems with systemd or plymouth the termios flags become changed from under the first agetty on a serial system console as the flags are locked (bnc#774126). diff --git a/util-linux.spec b/util-linux.spec index 4ca12ea..8faf5c7 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -109,7 +109,7 @@ Patch13: blkdiscard-BLKSSZGET-fills-in-an-int.patch # PATCH-FIX-SUSE -- better support of S390 in agetty Patch14: tty3270-on-serial-line-of-s390.patch # PATCH-FIX-SUSE -- Let agetty not be fooled by locked termios srtucture -Patch15: agetty-fooled-on-serial-line-due-plymout.patch +Patch15: agetty-fooled-on-serial-line-due-plymouth.patch # hack for boot.localfs Patch20: util-linux-HACK-boot.localfs.diff