summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>2003-06-14 08:26:47 +0000
committergreen <green@FreeBSD.org>2003-06-14 08:26:47 +0000
commitd4b26c11420ce2faffd6f192bf2d6b1c5a68c490 (patch)
treed62958b1babc93d71a9433ae921cf1caa4ea63e2
parentd20c30720bd75946190688b47500e9780baef631 (diff)
downloadFreeBSD-src-d4b26c11420ce2faffd6f192bf2d6b1c5a68c490.zip
FreeBSD-src-d4b26c11420ce2faffd6f192bf2d6b1c5a68c490.tar.gz
In the last clean-up of this code, the fact that the default tty mode
information could only be gleaned from the the tty descriptor itself was neglected, so never did the tty's default settings get copied from the kernel. Specifically, this caused all manner of ctrl-keys to not work. Fix this by calling dogettytab() in all the proper places, and retrieving the terminfo temporarily in dogettytab().
-rw-r--r--libexec/getty/main.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index a20dd73..3e079c1 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -205,10 +205,8 @@ main(int argc, char *argv[])
gettable("default", defent);
gendefaults();
tname = "default";
- if (argc > 1) {
+ if (argc > 1)
tname = argv[1];
- dogettytab(tname);
- }
/*
* The following is a work around for vhangup interactions
@@ -217,9 +215,10 @@ main(int argc, char *argv[])
* that the file descriptors are already set up for us.
* J. Gettys - MIT Project Athena.
*/
- if (argc <= 2 || strcmp(argv[2], "-") == 0)
+ if (argc <= 2 || strcmp(argv[2], "-") == 0) {
strcpy(ttyn, ttyname(STDIN_FILENO));
- else {
+ dogettytab(tname);
+ } else {
strcpy(ttyn, dev);
strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
if (strcmp(argv[0], "+") != 0) {
@@ -232,6 +231,7 @@ main(int argc, char *argv[])
if (IC) {
if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
exit(1);
+ dogettytab(tname);
setdefttymode();
if (getty_chat(IC, CT, DC) > 0) {
syslog(LOG_ERR, "modem init problem on %s", ttyn);
@@ -246,6 +246,7 @@ main(int argc, char *argv[])
if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
exit(1);
+ dogettytab(tname);
setdefttymode();
rfds = 1 << 0; /* FD_SET */
to.tv_sec = RT;
@@ -268,6 +269,7 @@ main(int argc, char *argv[])
} else { /* maybe blocking open */
if (!opentty(ttyn, O_RDWR | (NC ? O_NONBLOCK : 0 )))
exit(1);
+ dogettytab(tname);
}
}
}
@@ -801,6 +803,7 @@ putf(const char *cp)
static void
dogettytab(const char *tname)
{
+ struct termios backupmode;
/* Read the database entry */
gettable(tname, tabent);
@@ -813,6 +816,17 @@ dogettytab(const char *tname)
if (OPset || EPset || APset || NPset)
OPset = EPset = APset = NPset = 1;
- /* Fill in default values for unset capabilities */
+ /*
+ * Fill in default values for unset capabilities. Since the
+ * defaults are derived from the actual tty mode, save any
+ * changes to the tmode and fetch it temporarily for
+ * setdefaults() to use.
+ */
+ backupmode = tmode;
+ if (tcgetattr(STDIN_FILENO, &tmode) < 0) {
+ syslog(LOG_ERR, "tcgetattr %s: %m", ttyn);
+ exit(1);
+ }
setdefaults();
+ tmode = backupmode;
}
OpenPOWER on IntegriCloud