diff --git a/util-linux-2.23-agetty-clocal.patch b/util-linux-2.23-agetty-clocal.patch index f48541a..2637a4a 100644 --- a/util-linux-2.23-agetty-clocal.patch +++ b/util-linux-2.23-agetty-clocal.patch @@ -1,50 +1,5 @@ -From ef264c830effc91add6da334204215f61eb8515e Mon Sep 17 00:00:00 2001 -From: Karel Zak -Date: Thu, 23 May 2013 09:25:06 +0200 -Subject: [PATCH] agetty: allow full control on CLOCAL flag - -Now the -L option allows to explicitly enable CLOCAL flag. - -Unfortunately sometimes it's necessary to clear the flag. This patch -add optional argument = to specify 'auto', 'always' and 'never' -to control CLOCAL flag. - -Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=816342 -Signed-off-by: Karel Zak ---- - term-utils/agetty.8 | 14 ++++++++++++-- - term-utils/agetty.c | 44 +++++++++++++++++++++++++++++++++++++------- - 2 files changed, 49 insertions(+), 9 deletions(-) - -diff --git a/term-utils/agetty.8 b/term-utils/agetty.8 -index 64a1dd2..8d5286c 100644 ---- a/term-utils/agetty.8 -+++ b/term-utils/agetty.8 -@@ -138,10 +138,20 @@ This allows the use of a non-standard login program (for example, - one that asks for a dial-up password or that uses a different - password file). - .TP --\-L, \-\-local\-line --Force the line to be a local line with no need for carrier detect. This can -+\-L, \-\-local\-line [=\fImode\fP] -+Control CLOCAL line flag, the optional argument \fImode\fP is 'auto', 'always' or 'never'. -+If the \fImode\fP argument is omitted then the default is 'always'. If the -+\-\-local\-line option is ommitted at all then the default is 'auto'. -+ -+The \fImode\fP 'always' forces the line to be a local line with no need for carrier detect. This can - be useful when you have a locally attached terminal where the serial line - does not set the carrier detect signal. -+ -+The \fImode\fP 'never' explicitly clears CLOCAL flags from line setting and -+the carrier detect signal is expected on the line. -+ -+The \fImode\fP 'auto' (agetty default) does not modify CLOCAL setting -+and follows the setting enabled by kernel. - .TP - \-m, \-\-extract\-baud - Try to extract the baud rate the CONNECT status message diff --git a/term-utils/agetty.c b/term-utils/agetty.c -index dd52f70..0d01e7e 100644 +index a23cf6d..054a1dd 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -132,13 +132,20 @@ struct options { @@ -69,17 +24,52 @@ index dd52f70..0d01e7e 100644 #define F_INITSTRING (1<<4) /* initstring is set */ #define F_WAITCRLF (1<<5) /* wait for CR or LF */ #define F_CUSTISSUE (1<<6) /* give alternative issue file */ -@@ -314,7 +321,8 @@ int main(int argc, char **argv) +@@ -235,6 +242,9 @@ static void login_options_to_argv(char *argv[], int *argc, char *str, char *user + static char *fakehost; + + #ifdef DEBUGGING ++#ifndef ++# define DEBUG_OUTPUT "/dev/ttyp0" ++#endif + #define debug(s) do { fprintf(dbf,s); fflush(dbf); } while (0) + FILE *dbf; + #else +@@ -270,7 +280,7 @@ int main(int argc, char **argv) + sigaction(SIGINT, &sa, &sa_int); + + #ifdef DEBUGGING +- dbf = fopen("/dev/ttyp0", "w"); ++ dbf = fopen(DEBUG_OUTPUT, "w"); + for (int i = 1; i < argc; i++) + debug(argv[i]); + #endif /* DEBUGGING */ +@@ -311,8 +321,10 @@ int main(int argc, char **argv) strlen(options.initstring)); } - if (!serial_tty_option(&options, F_LOCAL)) -+ if ((options.flags & F_VCONSOLE) == 0 && -+ options.clocal == CLOCAL_MODE_ALWAYS) - /* Go to blocking write mode unless -L is specified. */ +- /* Go to blocking write mode unless -L is specified. */ ++ if (options.flags & F_VCONSOLE || options.clocal != CLOCAL_MODE_ALWAYS) ++ /* Go to blocking mode unless -L is specified, this change ++ * affects stdout, stdin and stderr as all the file descriptors ++ * are created by dup(). */ fcntl(STDOUT_FILENO, F_SETFL, fcntl(STDOUT_FILENO, F_GETFL, 0) & ~O_NONBLOCK); -@@ -541,7 +549,7 @@ static void parse_args(int argc, char **argv, struct options *op) + +@@ -420,6 +432,12 @@ int main(int argc, char **argv) + options.tty); + } + ++#ifdef DEBUGGING ++ fprintf(dbf, "read %c\n", ch); ++ if (close_stream(dbf) != 0) ++ log_err("write failed: %s", DEBUG_OUTPUT); ++#endif ++ + /* Let the login program take care of password validation. */ + execv(options.login, login_argv); + log_err(_("%s: can't exec %s: %m"), options.tty, login_argv[0]); +@@ -532,7 +550,7 @@ static void parse_args(int argc, char **argv, struct options *op) { "init-string", required_argument, 0, 'I' }, { "noclear", no_argument, 0, 'J' }, { "login-program", required_argument, 0, 'l' }, @@ -88,7 +78,7 @@ index dd52f70..0d01e7e 100644 { "extract-baud", no_argument, 0, 'm' }, { "skip-login", no_argument, 0, 'n' }, { "nonewline", no_argument, 0, 'N' }, -@@ -610,7 +618,18 @@ static void parse_args(int argc, char **argv, struct options *op) +@@ -601,7 +619,18 @@ static void parse_args(int argc, char **argv, struct options *op) op->login = optarg; break; case 'L': @@ -108,7 +98,7 @@ index dd52f70..0d01e7e 100644 break; case 'm': op->flags |= F_PARSE; -@@ -1097,8 +1116,19 @@ static void termio_init(struct options *op, struct termios *tp) +@@ -1088,8 +1117,19 @@ static void termio_init(struct options *op, struct termios *tp) cfsetispeed(tp, ispeed); cfsetospeed(tp, ospeed); @@ -130,7 +120,29 @@ index dd52f70..0d01e7e 100644 #ifdef HAVE_STRUCT_TERMIOS_C_LINE tp->c_line = 0; #endif -@@ -1655,7 +1685,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) +@@ -1410,9 +1450,10 @@ static char *get_logname(struct options *op, struct termios *tp, struct chardata + + if (read(STDIN_FILENO, &c, 1) < 1) { + +- /* Do not report trivial like EINTR/EIO errors. */ ++ /* The terminal could be open with O_NONBLOCK when ++ * -L (force CLOCAL) is specified... */ + if (errno == EINTR || errno == EAGAIN) { +- usleep(1000); ++ usleep(250000); + continue; + } + switch (errno) { +@@ -1633,7 +1674,7 @@ static speed_t bcode(char *s) + static void __attribute__ ((__noreturn__)) usage(FILE *out) + { + fputs(USAGE_HEADER, out); +- fprintf(out, _(" %1$s [options] line baud_rate,... [termtype]\n" ++ fprintf(out, _(" %1$s [options] line [baud_rate,...] [termtype]\n" + " %1$s [options] baud_rate,... line [termtype]\n"), program_invocation_short_name); + fputs(USAGE_OPTIONS, out); + fputs(_(" -8, --8bits assume 8-bit tty\n"), out); +@@ -1646,7 +1687,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fputs(_(" -i, --noissue do not display issue file\n"), out); fputs(_(" -I, --init-string set init string\n"), out); fputs(_(" -l, --login-program specify login program\n"), out); @@ -139,6 +151,3 @@ index dd52f70..0d01e7e 100644 fputs(_(" -m, --extract-baud extract baud rate during connect\n"), out); fputs(_(" -n, --skip-login do not prompt for login\n"), out); fputs(_(" -o, --login-options options that are passed to login\n"), out); --- -1.8.1.4 - diff --git a/util-linux.spec b/util-linux.spec index 3894a42..b4de327 100644 --- a/util-linux.spec +++ b/util-linux.spec @@ -2,7 +2,7 @@ Summary: A collection of basic system utilities Name: util-linux Version: 2.23.1 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain Group: System Environment/Base URL: http://en.wikipedia.org/wiki/Util-linux @@ -77,7 +77,7 @@ Requires: libmount = %{version}-%{release} # 151635 - makeing /var/log/lastlog Patch0: util-linux-ng-2.22-login-lastlog.patch -### Backport from v2.24 +### Backport from v2.24 + #972457 Patch1: util-linux-2.23-agetty-clocal.patch ### 962145 - in.telnetd immediately closes connection Patch2: util-linux-2.23-login-TCSANOW.patch @@ -797,6 +797,9 @@ fi %{_libdir}/pkgconfig/uuid.pc %changelog +* Thu Jun 13 2013 Karel Zak 2.23.1-3 +- fix #972457 - agetty idle I/O polling causes elevated CPU usage + * Wed Jun 5 2013 Karel Zak 2.23.1-2 - fix #962145 - in.telnetd immediately closes connection