summaryrefslogtreecommitdiffstats
path: root/term-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2014-11-20 10:56:03 +0100
committerKarel Zak2014-11-20 10:56:03 +0100
commit8410cdd38ad06d0904ec3ba252336fecc4aff067 (patch)
tree3bfbb3cc3a226e800cd6e70239e889e09d988068 /term-utils/agetty.c
parentlibmount: fix lock test to use real time to sync (diff)
downloadkernel-qcow2-util-linux-8410cdd38ad06d0904ec3ba252336fecc4aff067.tar.gz
kernel-qcow2-util-linux-8410cdd38ad06d0904ec3ba252336fecc4aff067.tar.xz
kernel-qcow2-util-linux-8410cdd38ad06d0904ec3ba252336fecc4aff067.zip
aggety: always set default serial line speed
* makes speeds table usage more robust * don't call next_speed() for empty speeds table to avoid division by zero * default to 9600 when port baud unspecified Addresses: https://github.com/karelzak/util-linux/pull/131 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils/agetty.c')
-rw-r--r--term-utils/agetty.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index 590122899..cda0ab731 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -386,6 +386,11 @@ int main(int argc, char **argv)
sigaction(SIGHUP, &sa_hup, NULL);
tcsetpgrp(STDIN_FILENO, getpid());
+
+ /* Default serial line speed (may be ignored on --{extract,keep}-baud) */
+ if ((options.flags & F_VCONSOLE) == 0 && options.numspeed == 0)
+ options.speeds[options.numspeed++] = bcode("9600");
+
/* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */
debug("calling termio_init\n");
termio_init(&options, &termios);
@@ -447,7 +452,7 @@ int main(int argc, char **argv)
debug("reading login name\n");
while ((username =
get_logname(&options, &termios, &chardata)) == NULL)
- if ((options.flags & F_VCONSOLE) == 0)
+ if ((options.flags & F_VCONSOLE) == 0 && options.numspeed)
next_speed(&options, &termios);
}
}
@@ -801,8 +806,6 @@ static void parse_args(int argc, char **argv, struct options *op)
char *v = argv[optind++];
if (is_speed(v))
parse_speeds(op, v);
- else
- op->speeds[op->numspeed++] = bcode("9600");
}
}
@@ -1223,7 +1226,11 @@ static void termio_init(struct options *op, struct termios *tp)
return;
}
- if (op->flags & F_KEEPSPEED) {
+ /*
+ * Serial line
+ */
+
+ if (op->flags & F_KEEPSPEED || !op->numspeed) {
/* Save the original setting. */
ispeed = cfgetispeed(tp);
ospeed = cfgetospeed(tp);