summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-05-05 19:01:13 +0000
committerjoerg <joerg@FreeBSD.org>1996-05-05 19:01:13 +0000
commit289d83e1bca7867454702376e7598825b3bf49a2 (patch)
tree9fcbb1cf60af1a534cd4b1dc67cc99143428a872 /libexec
parentf6bfadad2892ae8e55931c0d104fa2b095ea2676 (diff)
downloadFreeBSD-src-289d83e1bca7867454702376e7598825b3bf49a2.zip
FreeBSD-src-289d83e1bca7867454702376e7598825b3bf49a2.tar.gz
Finally commit the changes that make getty(8) no longer depend on the
COMPAT_43 cruft. This is supposedly the last core utility that has been using it! (So now, one should be able to remove this option from the config files. Be aware that the last officially released xterm however still requires it.) The getty has been running now for several weeks on my modem line, so i feel safe about it. Obtained from: mostly from the NetBSD vendor-branch
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getty/Makefile7
-rw-r--r--libexec/getty/extern.h27
-rw-r--r--libexec/getty/getty.811
-rw-r--r--libexec/getty/gettytab.5152
-rw-r--r--libexec/getty/gettytab.h48
-rw-r--r--libexec/getty/init.c65
-rw-r--r--libexec/getty/main.c300
-rw-r--r--libexec/getty/pathnames.h7
-rw-r--r--libexec/getty/subr.c518
-rw-r--r--libexec/getty/ttys.525
10 files changed, 804 insertions, 356 deletions
diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile
index 8113441..96f7f7e 100644
--- a/libexec/getty/Makefile
+++ b/libexec/getty/Makefile
@@ -1,10 +1,13 @@
-# @(#)Makefile 5.12 (Berkeley) 1/21/91
+# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
+# $Id: Makefile,v 1.1.1.2 1996/04/13 15:33:02 joerg Exp $
PROG= getty
-SRCS= main.c init.c subr.c gettytab.c
+SRCS= main.c init.c subr.c
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN5= gettytab.5 ttys.5
MAN8= getty.8
+# for the paranoid:
+#CFLAGS+= -Wall -Wstrict-prototypes -Wno-unused -Wwrite-strings
.include <bsd.prog.mk>
diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h
index 3663166..bcffdae 100644
--- a/libexec/getty/extern.h
+++ b/libexec/getty/extern.h
@@ -31,27 +31,32 @@
* SUCH DAMAGE.
*
* from: @(#)extern.h 8.1 (Berkeley) 6/4/93
- * $Id: extern.h,v 1.2 1994/08/17 20:10:29 pk Exp $
+ * $Id: extern.h,v 1.1.1.4 1996/04/13 15:33:04 joerg Exp $
*/
struct delayval;
+struct termios;
+struct gettyflags;
+struct gettynums;
+struct gettystrs;
+
+extern char hostname[];
+extern int hopcount;
+extern struct termios tmode, omode;
+extern struct gettyflags gettyflags[];
+extern struct gettynums gettynums[];
+extern struct gettystrs gettystrs[];
int adelay __P((int, struct delayval *));
-char *autobaud __P((void));
+const char *autobaud __P((void));
int delaybits __P((void));
-void edithost __P((char *));
+void edithost __P((const char *));
void gendefaults __P((void));
-int getent __P((char *, char *));
-int getflag __P((char *));
-long getnum __P((char *));
-char *getstr __P((char *, char **));
-void gettable __P((char *, char *));
+void gettable __P((const char *, char *));
void makeenv __P((char *[]));
-char *portselector __P((void));
+const char *portselector __P((void));
void set_ttydefaults __P((int));
void setchars __P((void));
void setdefaults __P((void));
void setflags __P((int));
int speed __P((int));
-
-int login_tty __P((int)); /* From libutil. */
diff --git a/libexec/getty/getty.8 b/libexec/getty/getty.8
index ce6274b..bc0e050 100644
--- a/libexec/getty/getty.8
+++ b/libexec/getty/getty.8
@@ -1,5 +1,5 @@
-.\" Copyright (c) 1980, 1991 Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1980, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -29,9 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)getty.8 6.6 (Berkeley) 4/25/91
-.\"
-.Dd April 25, 1991
+.\" from: @(#)getty.8 8.1 (Berkeley) 6/4/93
+.\" $Id: getty.8,v 1.1.1.2 1996/04/13 15:33:06 joerg Exp $
+.\" "
+.Dd June 4, 1993
.Dt GETTY 8
.Os BSD 4
.Sh NAME
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index db6b1cc..5198f94 100644
--- a/libexec/getty/gettytab.5
+++ b/libexec/getty/gettytab.5
@@ -1,5 +1,5 @@
-.\" Copyright (c) 1983, 1991 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1983, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -29,9 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)gettytab.5 6.7 (Berkeley) 5/10/91
-.\"
-.Dd May 10, 1991
+.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
+.\" $Id: gettytab.5,v 1.1.1.3 1996/04/13 15:33:07 joerg Exp $
+.\" "
+.Dd April 19, 1994
.Dt GETTYTAB 5
.Os BSD 4.2
.Sh NAME
@@ -76,13 +77,13 @@ table.
.Bl -column Namexx /usr/bin/login Default
.It Sy Name Type Default Description
.It "ap bool false terminal uses any parity"
-.It "bd num 0 backspace delay"
.It "bk str 0377 alternate end of line character (input break)"
-.It "cb bool false use crt backspace mode"
-.It "cd num 0 carriage-return delay"
+.It "c0 num unused tty control flags to write messages"
+.It "c1 num unused tty control flags to read login name"
+.It "c2 num unused tty control flags to leave terminal as"
.It "ce bool false use crt erase algorithm"
.It "ck bool false use crt kill algorithm"
-.It "cl str" Ta Dv NULL Ta
+.It "cl str" Ta Dv NULL Ta
.No "screen clear sequence"
.It "co bool false console - add"
.Ql \en
@@ -100,21 +101,23 @@ after login prompt
.No "end of text"
.Pq Dv EOF
character
-.It "ev str" Ta Dv NULL Ta
+.It "ev str" Ta Dv NULL Ta
.No "initial environment"
.It "f0 num unused tty mode flags to write messages"
.It "f1 num unused tty mode flags to read login name"
.It "f2 num unused tty mode flags to leave terminal as"
-.It "fd num 0 form-feed (vertical motion) delay"
.It "fl str" Ta So Li ^O Sc Ta
.No "output flush character"
.It "hc bool false do"
.Tn NOT
hangup line on last close
-.It "he str" Ta Dv NULL Ta
+.It "he str" Ta Dv NULL Ta
.No "hostname editing string"
.It "hn str hostname hostname"
.It "ht bool false terminal has real tabs"
+.It "i0 num unused tty input flags to write messages"
+.It "i1 num unused tty input flags to read login name"
+.It "i2 num unused tty input flags to leave terminal as"
.It "ig bool false ignore garbage characters in login name"
.It "im str" Ta Dv NULL Ta
.No "initial (banner) message"
@@ -123,16 +126,21 @@ hangup line on last close
.It "is num unused input speed"
.It "kl str" Ta So Li ^U Sc Ta
.No "kill character"
-.It "lc bool false terminal has lower case"
+.It "l0 num unused tty local flags to write messages"
+.It "l1 num unused tty local flags to read login name"
+.It "l2 num unused tty local flags to leave terminal as"
.It "lm str login: login prompt"
.It "ln str" Ta So Li ^V Sc Ta
.No "``literal next'' character"
.It "lo str" Ta Pa /usr/bin/login Ta
.No "program to exec when name obtained"
-.It "nd num 0 newline (line-feed) delay"
+.It "mb bool false do flow control based on carrier"
.It "nl bool false terminal has (or might have) a newline character"
-.It "np bool false terminal uses no parity (8bit chars)"
+.It "np bool false terminal uses no parity (i.e. 8-bit characters)"
.It "nx str default next table (for auto speed selection)"
+.It "o0 num unused tty output flags to write messages"
+.It "o1 num unused tty output flags to read login name"
+.It "o2 num unused tty output flags to leave terminal as"
.It "op bool false terminal uses odd parity"
.It "os num unused output speed"
.It "pc str" Ta So Li \e0 Sc Ta
@@ -158,10 +166,9 @@ use raw for input, use cbreak
.It "tt str" Ta Dv NULL Ta
.No "terminal type (for environment)"
.It "ub bool false do unbuffered output (of prompts etc)"
-.It "uc bool false terminal is known upper case only"
.It "we str" Ta So Li ^W Sc Ta
.No "word erase character"
-.It "xc bool false do
+.It xc bool false do
.Tn NOT
echo control chars as
.Ql ^X
@@ -169,6 +176,18 @@ echo control chars as
(stop output) character
.It "xn str" Ta So Li ^Q Sc Ta Dv XON
(start output) character
+.It "Lo str C the locale name used for \&%d in the banner message"
+.El
+.Pp
+The following capabilities are no longer supported by getty(8):
+.Bl -column Namexx /usr/bin/login Default
+.It "bd num 0 backspace delay"
+.It "cb bool false use crt backspace mode"
+.It "cd num 0 carriage-return delay"
+.It "fd num 0 form-feed (vertical motion) delay"
+.It "lc bool false terminal has lower case"
+.It "nd num 0 newline (line-feed) delay"
+.It "uc bool false terminal is known upper case only"
.El
.Pp
If no line speed is specified, speed will not be altered
@@ -183,18 +202,43 @@ are derived from the boolean flags specified.
If the derivation should prove inadequate,
any (or all) of these three may be overridden
with one of the
-.Em \&f0 ,
-.Em \&f1 ,
+.Em \&c0 ,
+.Em \&c1 ,
+.Em \&c2 ,
+.Em \&i0 ,
+.Em \&i1 ,
+.Em \&i2 ,
+.Em \&l0 ,
+.Em \&l1 ,
+.Em \&l2 ,
+.Em \&o0 ,
+.Em \&o1 ,
or
-.Em \&f2
+.Em \&o2
numeric specifications, which can be used to specify
(usually in octal, with a leading '0')
the exact values of the flags.
-Local (new tty) flags are set in the top 16 bits
-of this (32 bit) value.
+These flags correspond to the termios
+.Em c_cflag ,
+.Em c_iflag ,
+.Em c_lflag ,
+and
+.Em c_oflag
+fields, respectively. Each these sets must be completely specified to be
+effective.
+The
+.Em \&f0 ,
+.Em \&f1 ,
+and
+.Em \&f2
+are excepted for backwards compatibility with a previous incarnation of
+the TTY sub-system. In these flags the bottom 16 bits of the (32 bits)
+value contain the sgttyb
+.Em sg_flags
+field, while the top 16 bits represent the local mode word.
.Pp
Should
-.Xr getty
+.Xr getty 8
receive a null character
(presumed to indicate a line break)
it will restart using the table indicated by the
@@ -218,33 +262,51 @@ The initial message, and login message,
.Em \&im
and
.Em \&lm
-may include the character sequence
-.Em \&%h
-or
-.Em \&%t
-to obtain
-the hostname or tty name respectively.
-.Pf ( Em %%
-obtains a single '%' character.)
-The hostname is normally obtained from the system,
-but may be set by the
+may include any of the following character sequences, which expand to
+information about the environment in which
+.Xr getty 8
+is running.
+.Pp
+.Bl -tag -width \&%xxx -compact
+.It \&%d
+The current date and time in the locale's representation as of the
+.Em \&Lo
+string
+(the \&%+ format of
+.Xr strftime 3 ).
+.It \&%h
+The hostname of the machine, which is normally obtained from the
+system using
+.Xr gethostname 2 ,
+but may also be overridden by the
.Em \&hn
table entry.
-In either case it may be edited with
-.Em \&he .
-The
+In either case it may be edited with the
.Em \&he
-string is a sequence of characters, each character that
-is neither '@' nor '#' is copied into the final hostname.
+string.
A '@' in the
.Em \&he
-string, causes one character from the real hostname to
+string causes one character from the real hostname to
be copied to the final hostname.
A '#' in the
.Em \&he
-string, causes the next character of the real hostname
+string causes the next character of the real hostname
to be skipped.
+Each character that
+is neither '@' nor '#' is copied into the final hostname.
Surplus '@' and '#' characters are ignored.
+.It \&%t
+The tty name.
+.It "\&%m, \&%r, \&%s, \&%v"
+The type of machine, release of the operating system, name of the
+operating system, and version of the kernel, respectively, as
+returned by
+.Xr uname 2 .
+.It \&%%
+A
+.Dq %
+character.
+.El
.Pp
When getty execs the login process, given
in the
@@ -270,14 +332,16 @@ then getty will exit within the indicated
number of seconds, either having
received a login name and passed control
to
-.Xr login ,
+.Xr login 1 ,
or having received an alarm signal, and exited.
This may be useful to hangup dial in lines.
.Pp
Output from
-.Xr getty
+.Xr getty 8
is even parity unless
.Em \&op
+or
+.Em \&np
is specified.
The
.Em \&op
@@ -288,12 +352,14 @@ to allow any parity on input, but generate odd parity output.
Note: this only applies while getty is being run,
terminal driver limitations prevent a more complete
implementation.
-.Xr Getty
+.Xr Getty 8
does not check parity of input characters in
.Dv RAW
mode.
.Sh SEE ALSO
.Xr login 1 ,
+.Xr gethostname 2 ,
+.Xr uname 2 ,
.Xr termcap 5 ,
.Xr getty 8 .
.Sh BUGS
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index 6f393ce..6eecc12 100644
--- a/libexec/getty/gettytab.h
+++ b/libexec/getty/gettytab.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1983 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,27 +30,28 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)gettytab.h 5.5 (Berkeley) 3/27/91
+ * from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
+ * $Id: gettytab.h,v 1.1.1.2 1996/04/13 15:33:09 joerg Exp $
*/
/*
* Getty description definitions.
*/
struct gettystrs {
- char *field; /* name to lookup in gettytab */
+ const char *field; /* name to lookup in gettytab */
char *defalt; /* value we find by looking in defaults */
char *value; /* value that we find there */
};
struct gettynums {
- char *field; /* name to lookup */
+ const char *field; /* name to lookup */
long defalt; /* number we find in defaults */
long value; /* number we find there */
int set; /* we actually got this one */
};
struct gettyflags {
- char *field; /* name to lookup */
+ const char *field; /* name to lookup */
char invrt; /* name existing in gettytab --> false */
char defalt; /* true/false in defaults */
char value; /* true/false flag */
@@ -84,6 +85,7 @@ struct gettyflags {
#define FL gettystrs[21].value
#define WE gettystrs[22].value
#define LN gettystrs[23].value
+#define Lo gettystrs[24].value
/*
* Numeric definitions.
@@ -104,6 +106,30 @@ struct gettyflags {
#define F2 gettynums[11].value
#define F2set gettynums[11].set
#define PF gettynums[12].value
+#define C0 gettynums[13].value
+#define C0set gettynums[13].set
+#define C1 gettynums[14].value
+#define C1set gettynums[14].set
+#define C2 gettynums[15].value
+#define C2set gettynums[15].set
+#define I0 gettynums[16].value
+#define I0set gettynums[16].set
+#define I1 gettynums[17].value
+#define I1set gettynums[17].set
+#define I2 gettynums[18].value
+#define I2set gettynums[18].set
+#define L0 gettynums[19].value
+#define L0set gettynums[19].set
+#define L1 gettynums[20].value
+#define L1set gettynums[20].set
+#define L2 gettynums[21].value
+#define L2set gettynums[21].set
+#define O0 gettynums[22].value
+#define O0set gettynums[22].set
+#define O1 gettynums[23].value
+#define O1set gettynums[23].set
+#define O2 gettynums[24].value
+#define O2set gettynums[24].set
/*
* Boolean values.
@@ -133,13 +159,5 @@ struct gettyflags {
#define AB gettyflags[19].value
#define DX gettyflags[20].value
#define NP gettyflags[21].value
+#define MB gettyflags[22].value
-int getent();
-long getnum();
-int getflag();
-char *getstr();
-
-extern struct gettyflags gettyflags[];
-extern struct gettynums gettynums[];
-extern struct gettystrs gettystrs[];
-extern int hopcount;
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index ac7112f..f289795 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1983 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,7 +32,8 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)init.c 5.6 (Berkeley) 3/27/91";
+/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/
+static char rcsid[] = "$Id: init.c,v 1.1.1.2 1996/04/13 15:33:10 joerg Exp $";
#endif /* not lint */
/*
@@ -40,40 +41,41 @@ static char sccsid[] = "@(#)init.c 5.6 (Berkeley) 3/27/91";
*
* Melbourne getty.
*/
-#include <sgtty.h>
+#include <termios.h>
+#include "extern.h"
#include "gettytab.h"
#include "pathnames.h"
-extern struct sgttyb tmode;
-extern struct tchars tc;
-extern struct ltchars ltc;
-extern char hostname[];
+static char loginmsg[] = "login: ";
+static char nullstr[] = "";
+static char loginprg[] = _PATH_LOGIN;
struct gettystrs gettystrs[] = {
{ "nx" }, /* next table */
{ "cl" }, /* screen clear characters */
{ "im" }, /* initial message */
- { "lm", "login: " }, /* login message */
- { "er", &tmode.sg_erase }, /* erase character */
- { "kl", &tmode.sg_kill }, /* kill character */
- { "et", &tc.t_eofc }, /* eof chatacter (eot) */
- { "pc", "" }, /* pad character */
+ { "lm", loginmsg }, /* login message */
+ { "er", &tmode.c_cc[VERASE] }, /* erase character */
+ { "kl", &tmode.c_cc[VKILL] }, /* kill character */
+ { "et", &tmode.c_cc[VEOF] }, /* eof chatacter (eot) */
+ { "pc", nullstr }, /* pad character */
{ "tt" }, /* terminal type */
{ "ev" }, /* enviroment */
- { "lo", _PATH_LOGIN }, /* login program */
+ { "lo", loginprg }, /* login program */
{ "hn", hostname }, /* host name */
{ "he" }, /* host name edit */
- { "in", &tc.t_intrc }, /* interrupt char */
- { "qu", &tc.t_quitc }, /* quit char */
- { "xn", &tc.t_startc }, /* XON (start) char */
- { "xf", &tc.t_stopc }, /* XOFF (stop) char */
- { "bk", &tc.t_brkc }, /* brk char (alt \n) */
- { "su", &ltc.t_suspc }, /* suspend char */
- { "ds", &ltc.t_dsuspc }, /* delayed suspend */
- { "rp", &ltc.t_rprntc }, /* reprint char */
- { "fl", &ltc.t_flushc }, /* flush output */
- { "we", &ltc.t_werasc }, /* word erase */
- { "ln", &ltc.t_lnextc }, /* literal next */
+ { "in", &tmode.c_cc[VINTR] }, /* interrupt char */
+ { "qu", &tmode.c_cc[VQUIT] }, /* quit char */
+ { "xn", &tmode.c_cc[VSTART] }, /* XON (start) char */
+ { "xf", &tmode.c_cc[VSTOP] }, /* XOFF (stop) char */
+ { "bk", &tmode.c_cc[VEOL] }, /* brk char (alt \n) */
+ { "su", &tmode.c_cc[VSUSP] }, /* suspend char */
+ { "ds", &tmode.c_cc[VDSUSP] }, /* delayed suspend */
+ { "rp", &tmode.c_cc[VREPRINT] },/* reprint char */
+ { "fl", &tmode.c_cc[VDISCARD] },/* flush output */
+ { "we", &tmode.c_cc[VWERASE] }, /* word erase */
+ { "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
+ { "Lo" }, /* locale for strftime() */
{ 0 }
};
@@ -91,6 +93,18 @@ struct gettynums gettynums[] = {
{ "f1" }, /* input flags */
{ "f2" }, /* user mode flags */
{ "pf" }, /* delay before flush at 1st prompt */
+ { "c0" }, /* output c_flags */
+ { "c1" }, /* input c_flags */
+ { "c2" }, /* user mode c_flags */
+ { "i0" }, /* output i_flags */
+ { "i1" }, /* input i_flags */
+ { "i2" }, /* user mode i_flags */
+ { "l0" }, /* output l_flags */
+ { "l1" }, /* input l_flags */
+ { "l2" }, /* user mode l_flags */
+ { "o0" }, /* output o_flags */
+ { "o1" }, /* input o_flags */
+ { "o2" }, /* user mode o_flags */
{ 0 }
};
@@ -117,5 +131,6 @@ struct gettyflags gettyflags[] = {
{ "ab", 0 }, /* auto-baud detect with '\r' */
{ "dx", 0 }, /* set decctlq */
{ "np", 0 }, /* no parity at all (8bit chars) */
+ { "mb", 0 }, /* do MDMBUF flow control */
{ 0 }
};
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index a161ed5..03ae7bb 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -1,6 +1,6 @@
/*-
- * Copyright (c) 1980 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,61 +32,67 @@
*/
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.16 (Berkeley) 3/27/91";
+/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/
+static char rcsid[] = "$Id: main.c,v 1.1.1.2 1996/04/13 15:33:11 joerg Exp $";
#endif /* not lint */
-#define USE_OLD_TTY
-
#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+#include <sys/ttydefaults.h>
+#include <sys/utsname.h>
+#include <errno.h>
#include <signal.h>
#include <fcntl.h>
-#include <sgtty.h>
#include <time.h>
#include <ctype.h>
+#include <fcntl.h>
+#include <libutil.h>
+#include <locale.h>
#include <setjmp.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <ctype.h>
+#include <signal.h>
#include <stdlib.h>
#include <string.h>
+#include <syslog.h>
+#include <termios.h>
+#include <time.h>
+#include <unistd.h>
+
#include "gettytab.h"
#include "pathnames.h"
+#include "extern.h"
-struct sgttyb tmode = {
- 0, 0, CERASE, CKILL, 0
-};
-struct tchars tc = {
- CINTR, CQUIT, CSTART,
- CSTOP, CEOF, CBRK,
-};
-struct ltchars ltc = {
- CSUSP, CDSUSP, CRPRNT,
- CFLUSH, CWERASE, CLNEXT
-};
+/*
+ * Set the amount of running time that getty should accumulate
+ * before deciding that something is wrong and exit.
+ */
+#define GETTY_TIMEOUT 60 /* seconds */
+
+#undef CTRL
+#define CTRL(x) (x&037)
+
+struct termios tmode, omode;
int crmod, digit, lower, upper;
char hostname[MAXHOSTNAMELEN];
+struct utsname kerninfo;
char name[16];
char dev[] = _PATH_DEV;
char ttyn[32];
-char *portselector();
-char *ttyname();
#define OBUFSIZ 128
#define TABBUFSIZ 512
char defent[TABBUFSIZ];
-char defstrs[TABBUFSIZ];
char tabent[TABBUFSIZ];
-char tabstrs[TABBUFSIZ];
char *env[128];
@@ -109,46 +115,80 @@ char partab[] = {
0000,0200,0200,0000,0200,0000,0000,0201
};
-#define ERASE tmode.sg_erase
-#define KILL tmode.sg_kill
-#define EOT tc.t_eofc
+#define ERASE tmode.c_cc[VERASE]
+#define KILL tmode.c_cc[VKILL]
+#define EOT tmode.c_cc[VEOF]
jmp_buf timeout;
+static void dingdong __P((int));
+static int getname __P((void));
+static void interrupt __P((int));
+static void oflush __P((void));
+static void prompt __P((void));
+static void putchr __P((int));
+static void putf __P((const char *));
+static void putpad __P((const char *));
+static void puts __P((const char *));
+static void timeoverrun __P((int));
+
+int main __P((int, char **));
+
static void
-dingdong()
+dingdong(signo)
+ int signo;
{
-
alarm(0);
- signal(SIGALRM, SIG_DFL);
longjmp(timeout, 1);
}
jmp_buf intrupt;
static void
-interrupt()
+interrupt(signo)
+ int signo;
{
-
- signal(SIGINT, interrupt);
longjmp(intrupt, 1);
}
+/*
+ * Action to take when getty is running too long.
+ */
+static void
+timeoverrun(signo)
+ int signo;
+{
+
+ syslog(LOG_ERR, "getty exiting due to excessive running time\n");
+ exit(1);
+}
+
+int
main(argc, argv)
int argc;
char **argv;
{
extern char **environ;
- char *tname;
- int repcnt = 0;
+ const char *tname;
+ int repcnt = 0, failopenlogged = 0;
+ struct rlimit limit;
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
- openlog("getty", LOG_ODELAY|LOG_CONS, LOG_AUTH);
+ openlog("getty", LOG_ODELAY|LOG_CONS|LOG_PID, LOG_AUTH);
gethostname(hostname, sizeof(hostname));
if (hostname[0] == '\0')
strcpy(hostname, "Amnesiac");
+
+ /*
+ * Limit running time to deal with broken or dead lines.
+ */
+ (void)signal(SIGXCPU, timeoverrun);
+ limit.rlim_max = RLIM_INFINITY;
+ limit.rlim_cur = GETTY_TIMEOUT;
+ (void)setrlimit(RLIMIT_CPU, &limit);
+
/*
* The following is a work around for vhangup interactions
* which cause great problems getting window systems started.
@@ -168,9 +208,11 @@ main(argc, argv)
chmod(ttyn, 0600);
revoke(ttyn);
while ((i = open(ttyn, O_RDWR)) == -1) {
- if (repcnt % 10 == 0) {
+ if ((repcnt % 10 == 0) &&
+ (errno != ENXIO || !failopenlogged)) {
syslog(LOG_ERR, "%s: %m", ttyn);
closelog();
+ failopenlogged = 1;
}
repcnt++;
sleep(60);
@@ -179,40 +221,56 @@ main(argc, argv)
}
}
- gettable("default", defent, defstrs);
+ /* Start with default tty settings */
+ if (tcgetattr(0, &tmode) < 0) {
+ syslog(LOG_ERR, "%s: %m", ttyn);
+ exit(1);
+ }
+ /*
+ * Don't rely on the driver too much, and initialize crucial
+ * things according to <sys/ttydefaults.h>. Avoid clobbering
+ * the c_cc[] settings however, the console drivers might wish
+ * to leave their idea of the preferred VERASE key value
+ * there.
+ */
+ tmode.c_iflag = TTYDEF_IFLAG;
+ tmode.c_oflag = TTYDEF_OFLAG;
+ tmode.c_lflag = TTYDEF_LFLAG;
+ tmode.c_cflag = TTYDEF_CFLAG;
+ omode = tmode;
+
+ gettable("default", defent);
gendefaults();
tname = "default";
if (argc > 1)
tname = argv[1];
for (;;) {
int off = 0;
- int flushboth = 0;
- struct sgttyb fake;
- gettable(tname, tabent, tabstrs);
+ gettable(tname, tabent);
if (OPset || EPset || APset)
APset++, OPset++, EPset++;
setdefaults();
- ioctl(0, TIOCFLUSH, &flushboth); /* clear out the crap */
+ off = 0;
+ (void)tcflush(0, TCIOFLUSH); /* clear out the crap */
ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
ioctl(0, FIOASYNC, &off); /* ditto for async mode */
- ioctl(0, TIOCGETP, &fake); /* initialize kernel termios */
+
if (IS)
- tmode.sg_ispeed = speed(IS);
+ cfsetispeed(&tmode, speed(IS));
else if (SP)
- tmode.sg_ispeed = speed(SP);
+ cfsetispeed(&tmode, speed(SP));
if (OS)
- tmode.sg_ospeed = speed(OS);
+ cfsetospeed(&tmode, speed(OS));
else if (SP)
- tmode.sg_ospeed = speed(SP);
- set_tmode(0);
+ cfsetospeed(&tmode, speed(SP));
+ setflags(0);
setchars();
- ioctl(0, TIOCSETC, &tc);
- if (HC)
- ioctl(0, TIOCHPCL, 0);
+ if (tcsetattr(0, TCSANOW, &tmode) < 0) {
+ syslog(LOG_ERR, "%s: %m", ttyn);
+ exit(1);
+ }
if (AB) {
- extern char *autobaud();
-
tname = autobaud();
continue;
}
@@ -226,8 +284,8 @@ main(argc, argv)
if (IM && *IM)
putf(IM);
if (setjmp(timeout)) {
- tmode.sg_ispeed = tmode.sg_ospeed = 0;
- ioctl(0, TIOCSETP, &tmode);
+ tmode.c_ispeed = tmode.c_ospeed = 0;
+ (void)tcsetattr(0, TCSANOW, &tmode);
exit(1);
}
if (TO) {
@@ -237,39 +295,56 @@ main(argc, argv)
if (getname()) {
register int i;
+ oflush();
alarm(0);
signal(SIGALRM, SIG_DFL);
- oflush();
if (name[0] == '-') {
puts("user names may not start with '-'.");
continue;
}
if (!(upper || lower || digit))
continue;
- set_tmode(2);
- ioctl(0, TIOCSLTC, &ltc);
+ setflags(2);
+ if (crmod) {
+ tmode.c_iflag |= ICRNL;
+ tmode.c_oflag |= ONLCR;
+ }
+#if REALLY_OLD_TTYS
+ if (upper || UC)
+ tmode.sg_flags |= LCASE;
+ if (lower || LC)
+ tmode.sg_flags &= ~LCASE;
+#endif
+ if (tcsetattr(0, TCSANOW, &tmode) < 0) {
+ syslog(LOG_ERR, "%s: %m", ttyn);
+ exit(1);
+ }
+ signal(SIGINT, SIG_DFL);
for (i = 0; environ[i] != (char *)0; i++)
env[i] = environ[i];
makeenv(&env[i]);
+ limit.rlim_max = RLIM_INFINITY;
+ limit.rlim_cur = RLIM_INFINITY;
+ (void)setrlimit(RLIMIT_CPU, &limit);
execle(LO, "login", "-p", name, (char *) 0, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
}
- signal(SIGINT, SIG_IGN);
alarm(0);
signal(SIGALRM, SIG_DFL);
+ signal(SIGINT, SIG_IGN);
if (NX && *NX)
tname = NX;
}
}
+static int
getname()
{
register int c;
register char *np;
char cs;
- int flushin = 1 /*FREAD*/;
/*
* Interrupt may happen if we use CBREAK mode
@@ -279,14 +354,17 @@ getname()
return (0);
}
signal(SIGINT, interrupt);
- ioctl(0, TIOCFLUSH, &flushin); /* purge any input */
+ setflags(1);
prompt();
oflush();
if (PF > 0) {
sleep(PF);
PF = 0;
}
- set_tmode(1);
+ if (tcsetattr(0, TCSANOW, &tmode) < 0) {
+ syslog(LOG_ERR, "%s: %m", ttyn);
+ exit(1);
+ }
crmod = digit = lower = upper = 0;
np = name;
for (;;) {
@@ -295,7 +373,7 @@ getname()
exit(0);
if ((c = cs&0177) == 0)
return (0);
- if (c == EOT || c == 4 /*^D*/)
+ if (c == EOT || c == CTRL('d'))
exit(1);
if (c == '\r' || c == '\n' || np >= &name[sizeof name]) {
putf("\r\n");
@@ -308,15 +386,15 @@ getname()
else if (c == ERASE || c == '\b' || c == 0177) {
if (np > name) {
np--;
- if (tmode.sg_ospeed >= B1200)
+ if (cfgetospeed(&tmode) >= 1200)
puts("\b \b");
else
putchr(cs);
}
continue;
- } else if (c == KILL || c == 025 /*^U*/) {
+ } else if (c == KILL || c == CTRL('u')) {
putchr('\r');
- if (tmode.sg_ospeed < B1200)
+ if (cfgetospeed(&tmode) < 1200)
putchr('\n');
/* this is the way they do it down under ... */
else if (np > name)
@@ -335,23 +413,19 @@ getname()
*np = 0;
if (c == '\r')
crmod = 1;
- if (upper && !lower && !LC || UC)
+ if ((upper && !lower && !LC) || UC)
for (np = name; *np; np++)
if (isupper(*np))
*np = tolower(*np);
return (1);
}
-static
-short tmspc10[] = {
- 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5, 15
-};
-
+static void
putpad(s)
- register char *s;
+ register const char *s;
{
register pad = 0;
- register mspc10;
+ speed_t ospeed = cfgetospeed(&tmode);
if (isdigit(*s)) {
while (isdigit(*s)) {
@@ -370,10 +444,7 @@ putpad(s)
* If no delay needed, or output speed is
* not comprehensible, then don't try to delay.
*/
- if (pad == 0)
- return;
- if (tmode.sg_ospeed <= 0 ||
- tmode.sg_ospeed >= (sizeof tmspc10 / sizeof tmspc10[0]))
+ if (pad == 0 || ospeed <= 0)
return;
/*
@@ -382,14 +453,14 @@ putpad(s)
* Transmitting pad characters slows many terminals down and also
* loads the system.
*/
- mspc10 = tmspc10[tmode.sg_ospeed];
- pad += mspc10 / 2;
- for (pad /= mspc10; pad > 0; pad--)
+ pad = (pad * ospeed + 50000) / 100000;
+ while (pad--)
putchr(*PC);
}
+static void
puts(s)
- register char *s;
+ register const char *s;
{
while (*s)
putchr(*s++);
@@ -398,7 +469,9 @@ puts(s)
char outbuf[OBUFSIZ];
int obufcnt = 0;
+static void
putchr(cc)
+ int cc;
{
char c;
@@ -416,6 +489,7 @@ putchr(cc)
write(STDOUT_FILENO, &c, 1);
}
+static void
oflush()
{
if (obufcnt)
@@ -423,6 +497,7 @@ oflush()
obufcnt = 0;
}
+static void
prompt()
{
@@ -431,8 +506,9 @@ prompt()
putchr('\n');
}
+static void
putf(cp)
- register char *cp;
+ register const char *cp;
{
extern char editedhost[];
time_t t;
@@ -446,7 +522,7 @@ putf(cp)
switch (*++cp) {
case 't':
- slash = rindex(ttyn, '/');
+ slash = strrchr(ttyn, '/');
if (slash == (char *) 0)
puts(ttyn);
else
@@ -458,13 +534,29 @@ putf(cp)
break;
case 'd': {
- static char fmt[] = "%l:% %p on %A, %d %B %Y";
-
- fmt[4] = 'M'; /* I *hate* SCCS... */
+ t = (time_t)0;
(void)time(&t);
- (void)strftime(db, sizeof(db), fmt, localtime(&t));
+ if (Lo)
+ (void)setlocale(LC_TIME, Lo);
+ (void)strftime(db, sizeof(db), "%+", localtime(&t));
puts(db);
break;
+
+ case 's':
+ puts(kerninfo.sysname);
+ break;
+
+ case 'm':
+ puts(kerninfo.machine);
+ break;
+
+ case 'r':
+ puts(kerninfo.release);
+ break;
+
+ case 'v':
+ puts(kerninfo.version);
+ break;
}
case '%':
@@ -474,29 +566,3 @@ putf(cp)
cp++;
}
}
-
-/*
- * The conversions from sgttyb to termios make LITOUT and PASS8 affect
- * the parity. So every TIOCSETP ioctl has to be paired with a TIOCLSET
- * ioctl (at least if LITOUT or PASS8 has changed, and PASS8 may vary
- * with 'n').
- */
-set_tmode(n)
- int n;
-{
- long allflags;
-
- allflags = setflags(n);
- tmode.sg_flags = allflags & 0xffff;
- allflags >>= 16;
- if (n == 2) {
- if (crmod || NL)
- tmode.sg_flags |= CRMOD;
- if (upper || UC)
- tmode.sg_flags |= LCASE;
- if (lower || LC)
- tmode.sg_flags &= ~LCASE;
- }
- ioctl(0, TIOCSETP, &tmode);
- ioctl(0, TIOCLSET, &allflags);
-}
diff --git a/libexec/getty/pathnames.h b/libexec/getty/pathnames.h
index e02b8b9..c3a0711 100644
--- a/libexec/getty/pathnames.h
+++ b/libexec/getty/pathnames.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,7 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)pathnames.h 5.3 (Berkeley) 6/1/90
+ * from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93
+ * $Id: pathnames.h,v 1.1.1.2 1996/04/13 15:33:13 joerg Exp $
*/
#include <paths.h>
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index 6e4f5f0..1718605 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1983 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,53 +29,59 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE
- * -------------------- ----- ----------------------
- * CURRENT PATCH LEVEL: 1 00150
- * -------------------- ----- ----------------------
- *
- * 22 Apr 93 Rodney W. Grimes support for 57600 and 115200 baud
- *
*/
#ifndef lint
-static char sccsid[] = "@(#)subr.c 5.10 (Berkeley) 2/26/91";
+/*static char sccsid[] = "from: @(#)subr.c 8.1 (Berkeley) 6/4/93";*/
+static char rcsid[] = "$Id: subr.c,v 1.1.1.2 1996/04/13 15:33:14 joerg Exp $";
#endif /* not lint */
/*
* Melbourne getty.
*/
-#include <sys/param.h>
-#include <sgtty.h>
+#define COMPAT_43
+#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#ifdef DEBUG
+#include <stdio.h>
+#endif
+
#include "gettytab.h"
+#include "pathnames.h"
+#include "extern.h"
-extern struct sgttyb tmode;
-extern struct tchars tc;
-extern struct ltchars ltc;
+
+#ifdef COMPAT_43
+static void compatflags __P((long));
+#endif
/*
* Get a table entry.
*/
-gettable(name, buf, area)
- char *name, *buf, *area;
+void
+gettable(name, buf)
+ const char *name;
+ char *buf;
{
register struct gettystrs *sp;
register struct gettynums *np;
register struct gettyflags *fp;
- register n;
+ long n;
+ const char *dba[2];
+ dba[0] = _PATH_GETTYTAB;
+ dba[1] = 0;
- hopcount = 0; /* new lookup, start fresh */
- if (getent(buf, name) != 1)
+ if (cgetent(&buf, dba, name) != 0)
return;
for (sp = gettystrs; sp->field; sp++)
- sp->value = getstr(sp->field, &area);
+ cgetstr(buf, sp->field, &sp->value);
for (np = gettynums; np->field; np++) {
- n = getnum(np->field);
- if (n == -1)
+ if (cgetnum(buf, np->field, &n) == -1)
np->set = 0;
else {
np->set = 1;
@@ -83,16 +89,26 @@ gettable(name, buf, area)
}
}
for (fp = gettyflags; fp->field; fp++) {
- n = getflag(fp->field);
- if (n == -1)
+ if (cgetcap(buf, fp->field, ':') == NULL)
fp->set = 0;
else {
fp->set = 1;
- fp->value = n ^ fp->invrt;
+ fp->value = 1 ^ fp->invrt;
}
}
+#ifdef DEBUG
+ printf("name=\"%s\", buf=\"%s\"\r\n", name, buf);
+ for (sp = gettystrs; sp->field; sp++)
+ printf("cgetstr: %s=%s\r\n", sp->field, sp->value);
+ for (np = gettynums; np->field; np++)
+ printf("cgetnum: %s=%d\r\n", np->field, np->value);
+ for (fp = gettyflags; fp->field; fp++)
+ printf("cgetflags: %s='%c' set='%c'\r\n", fp->field,
+ fp->value + '0', fp->set + '0');
+#endif /* DEBUG */
}
+void
gendefaults()
{
register struct gettystrs *sp;
@@ -112,6 +128,7 @@ gendefaults()
fp->defalt = fp->invrt;
}
+void
setdefaults()
{
register struct gettystrs *sp;
@@ -137,104 +154,338 @@ charnames[] = {
static char *
charvars[] = {
- &tmode.sg_erase, &tmode.sg_kill, &tc.t_intrc,
- &tc.t_quitc, &tc.t_startc, &tc.t_stopc,
- &tc.t_eofc, &tc.t_brkc, &ltc.t_suspc,
- &ltc.t_dsuspc, &ltc.t_rprntc, &ltc.t_flushc,
- &ltc.t_werasc, &ltc.t_lnextc, 0
+ &tmode.c_cc[VERASE], &tmode.c_cc[VKILL], &tmode.c_cc[VINTR],
+ &tmode.c_cc[VQUIT], &tmode.c_cc[VSTART], &tmode.c_cc[VSTOP],
+ &tmode.c_cc[VEOF], &tmode.c_cc[VEOL], &tmode.c_cc[VSUSP],
+ &tmode.c_cc[VDSUSP], &tmode.c_cc[VREPRINT], &tmode.c_cc[VDISCARD],
+ &tmode.c_cc[VWERASE], &tmode.c_cc[VLNEXT], 0
};
+void
setchars()
{
register int i;
- register char *p;
+ register const char *p;
for (i = 0; charnames[i]; i++) {
p = *charnames[i];
if (p && *p)
*charvars[i] = *p;
else
- *charvars[i] = '\377';
+ *charvars[i] = _POSIX_VDISABLE;
}
}
-long
+/* Macros to clear/set/test flags. */
+#define SET(t, f) (t) |= (f)
+#define CLR(t, f) (t) &= ~(f)
+#define ISSET(t, f) ((t) & (f))
+
+void
setflags(n)
+ int n;
{
- register long f;
+ register tcflag_t iflag, oflag, cflag, lflag;
+#ifdef COMPAT_43
switch (n) {
case 0:
- if (F0set)
- return(F0);
+ if (F0set) {
+ compatflags(F0);
+ return;
+ }
break;
case 1:
- if (F1set)
- return(F1);
+ if (F1set) {
+ compatflags(F1);
+ return;
+ }
break;
default:
- if (F2set)
- return(F2);
+ if (F2set) {
+ compatflags(F2);
+ return;
+ }
break;
}
+#endif
- f = 0;
+ switch (n) {
+ case 0:
+ if (C0set && I0set && L0set && O0set) {
+ tmode.c_cflag = C0;
+ tmode.c_iflag = I0;
+ tmode.c_lflag = L0;
+ tmode.c_oflag = O0;
+ return;
+ }
+ break;
+ case 1:
+ if (C1set && I1set && L1set && O1set) {
+ tmode.c_cflag = C1;
+ tmode.c_iflag = I1;
+ tmode.c_lflag = L1;
+ tmode.c_oflag = O1;
+ return;
+ }
+ break;
+ default:
+ if (C2set && I2set && L2set && O2set) {
+ tmode.c_cflag = C2;
+ tmode.c_iflag = I2;
+ tmode.c_lflag = L2;
+ tmode.c_oflag = O2;
+ return;
+ }
+ break;
+ }
- if (AP)
- f |= ANYP;
- else if (OP)
- f |= ODDP;
- else if (EP)
- f |= EVENP;
- if (NP)
- f |= PASS8;
+ iflag = omode.c_iflag;
+ oflag = omode.c_oflag;
+ cflag = omode.c_cflag;
+ lflag = omode.c_lflag;
+
+ if (NP) {
+ CLR(cflag, CSIZE|PARENB);
+ SET(cflag, CS8);
+ CLR(iflag, ISTRIP|INPCK|IGNPAR);
+ } else if (AP || EP || OP) {
+ CLR(cflag, CSIZE);
+ SET(cflag, CS7|PARENB);
+ SET(iflag, ISTRIP);
+ if (OP && !EP) {
+ SET(iflag, INPCK|IGNPAR);
+ SET(cflag, PARODD);
+ if (AP)
+ CLR(iflag, INPCK);
+ } else if (EP && !OP) {
+ SET(iflag, INPCK|IGNPAR);
+ CLR(cflag, PARODD);
+ if (AP)
+ CLR(iflag, INPCK);
+ } else if (AP || (EP && OP)) {
+ CLR(iflag, INPCK|IGNPAR);
+ CLR(cflag, PARODD);
+ }
+ } /* else, leave as is */
+#if 0
if (UC)
f |= LCASE;
+#endif
- if (NL)
- f |= CRMOD;
-
- f |= delaybits();
+ if (HC)
+ SET(cflag, HUPCL);
+ else
+ CLR(cflag, HUPCL);
- if (n == 1) { /* read mode flags */
- if (RW)
- f |= RAW;
- else
- f |= CBREAK;
- return (f);
+ if (MB)
+ SET(cflag, MDMBUF);
+ else
+ CLR(cflag, MDMBUF);
+
+ if (NL) {
+ SET(iflag, ICRNL);
+ SET(oflag, ONLCR|OPOST);
+ } else {
+ CLR(iflag, ICRNL);
+ CLR(oflag, ONLCR);
}
if (!HT)
- f |= XTABS;
+ SET(oflag, OXTABS|OPOST);
+ else
+ CLR(oflag, OXTABS);
+
+#ifdef XXX_DELAY
+ SET(f, delaybits());
+#endif
+
+ if (n == 1) { /* read mode flags */
+ if (RW) {
+ iflag = 0;
+ CLR(oflag, OPOST);
+ CLR(cflag, CSIZE|PARENB);
+ SET(cflag, CS8);
+ lflag = 0;
+ } else {
+ CLR(lflag, ICANON);
+ }
+ goto out;
+ }
if (n == 0)
- return (f);
+ goto out;
+#if 0
if (CB)
- f |= CRTBS;
+ SET(f, CRTBS);
+#endif
if (CE)
- f |= CRTERA;
+ SET(lflag, ECHOE);
+ else
+ CLR(lflag, ECHOE);
if (CK)
- f |= CRTKIL;
+ SET(lflag, ECHOKE);
+ else
+ CLR(lflag, ECHOKE);
if (PE)
- f |= PRTERA;
+ SET(lflag, ECHOPRT);
+ else
+ CLR(lflag, ECHOPRT);
if (EC)
- f |= ECHO;
+ SET(lflag, ECHO);
+ else
+ CLR(lflag, ECHO);
if (XC)
- f |= CTLECH;
+ SET(lflag, ECHOCTL);
+ else
+ CLR(lflag, ECHOCTL);
if (DX)
- f |= DECCTQ;
+ SET(lflag, IXANY);
+ else
+ CLR(lflag, IXANY);
- return (f);
+out:
+ tmode.c_iflag = iflag;
+ tmode.c_oflag = oflag;
+ tmode.c_cflag = cflag;
+ tmode.c_lflag = lflag;
+}
+
+#ifdef COMPAT_43
+/*
+ * Old TTY => termios, snatched from <sys/kern/tty_compat.c>
+ */
+void
+compatflags(flags)
+register long flags;
+{
+ register tcflag_t iflag, oflag, cflag, lflag;
+
+ iflag = BRKINT|ICRNL|IMAXBEL|IXON|IXANY;
+ oflag = OPOST|ONLCR|OXTABS;
+ cflag = CREAD;
+ lflag = ICANON|ISIG|IEXTEN;
+
+ if (ISSET(flags, TANDEM))
+ SET(iflag, IXOFF);
+ else
+ CLR(iflag, IXOFF);
+ if (ISSET(flags, ECHO))
+ SET(lflag, ECHO);
+ else
+ CLR(lflag, ECHO);
+ if (ISSET(flags, CRMOD)) {
+ SET(iflag, ICRNL);
+ SET(oflag, ONLCR);
+ } else {
+ CLR(iflag, ICRNL);
+ CLR(oflag, ONLCR);
+ }
+ if (ISSET(flags, XTABS))
+ SET(oflag, OXTABS);
+ else
+ CLR(oflag, OXTABS);
+
+
+ if (ISSET(flags, RAW)) {
+ iflag &= IXOFF;
+ CLR(lflag, ISIG|ICANON|IEXTEN);
+ CLR(cflag, PARENB);
+ } else {
+ SET(iflag, BRKINT|IXON|IMAXBEL);
+ SET(lflag, ISIG|IEXTEN);
+ if (ISSET(flags, CBREAK))
+ CLR(lflag, ICANON);
+ else
+ SET(lflag, ICANON);
+ switch (ISSET(flags, ANYP)) {
+ case 0:
+ CLR(cflag, PARENB);
+ break;
+ case ANYP:
+ SET(cflag, PARENB);
+ CLR(iflag, INPCK);
+ break;
+ case EVENP:
+ SET(cflag, PARENB);
+ SET(iflag, INPCK);
+ CLR(cflag, PARODD);
+ break;
+ case ODDP:
+ SET(cflag, PARENB);
+ SET(iflag, INPCK);
+ SET(cflag, PARODD);
+ break;
+ }
+ }
+
+ /* Nothing we can do with CRTBS. */
+ if (ISSET(flags, PRTERA))
+ SET(lflag, ECHOPRT);
+ else
+ CLR(lflag, ECHOPRT);
+ if (ISSET(flags, CRTERA))
+ SET(lflag, ECHOE);
+ else
+ CLR(lflag, ECHOE);
+ /* Nothing we can do with TILDE. */
+ if (ISSET(flags, MDMBUF))
+ SET(cflag, MDMBUF);
+ else
+ CLR(cflag, MDMBUF);
+ if (ISSET(flags, NOHANG))
+ CLR(cflag, HUPCL);
+ else
+ SET(cflag, HUPCL);
+ if (ISSET(flags, CRTKIL))
+ SET(lflag, ECHOKE);
+ else
+ CLR(lflag, ECHOKE);
+ if (ISSET(flags, CTLECH))
+ SET(lflag, ECHOCTL);
+ else
+ CLR(lflag, ECHOCTL);
+ if (!ISSET(flags, DECCTQ))
+ SET(iflag, IXANY);
+ else
+ CLR(iflag, IXANY);
+ CLR(lflag, TOSTOP|FLUSHO|PENDIN|NOFLSH);
+ SET(lflag, ISSET(flags, TOSTOP|FLUSHO|PENDIN|NOFLSH));
+
+ if (ISSET(flags, RAW|LITOUT|PASS8)) {
+ CLR(cflag, CSIZE);
+ SET(cflag, CS8);
+ if (!ISSET(flags, RAW|PASS8))
+ SET(iflag, ISTRIP);
+ else
+ CLR(iflag, ISTRIP);
+ if (!ISSET(flags, RAW|LITOUT))
+ SET(oflag, OPOST);
+ else
+ CLR(oflag, OPOST);
+ } else {
+ CLR(cflag, CSIZE);
+ SET(cflag, CS7);
+ SET(iflag, ISTRIP);
+ SET(oflag, OPOST);
+ }
+
+ tmode.c_iflag = iflag;
+ tmode.c_oflag = oflag;
+ tmode.c_cflag = cflag;
+ tmode.c_lflag = lflag;
}
+#endif
+#ifdef XXX_DELAY
struct delayval {
unsigned delay; /* delay in ms */
int bits;
@@ -245,44 +496,45 @@ struct delayval {
*/
struct delayval crdelay[] = {
- 1, CR1,
- 2, CR2,
- 3, CR3,
- 83, CR1,
- 166, CR2,
- 0, CR3,
+ { 1, CR1 },
+ { 2, CR2 },
+ { 3, CR3 },
+ { 83, CR1 },
+ { 166, CR2 },
+ { 0, CR3 },
};
struct delayval nldelay[] = {
- 1, NL1, /* special, calculated */
- 2, NL2,
- 3, NL3,
- 100, NL2,
- 0, NL3,
+ { 1, NL1 }, /* special, calculated */
+ { 2, NL2 },
+ { 3, NL3 },
+ { 100, NL2 },
+ { 0, NL3 },
};
struct delayval bsdelay[] = {
- 1, BS1,
- 0, 0,
+ { 1, BS1 },
+ { 0, 0 },
};
struct delayval ffdelay[] = {
- 1, FF1,
- 1750, FF1,
- 0, FF1,
+ { 1, FF1 },
+ { 1750, FF1 },
+ { 0, FF1 },
};
struct delayval tbdelay[] = {
- 1, TAB1,
- 2, TAB2,
- 3, XTABS, /* this is expand tabs */
- 100, TAB1,
- 0, TAB2,
+ { 1, TAB1 },
+ { 2, TAB2 },
+ { 3, XTABS }, /* this is expand tabs */
+ { 100, TAB1 },
+ { 0, TAB2 },
};
+int
delaybits()
{
- register f;
+ register int f;
f = adelay(CD, crdelay);
f |= adelay(ND, nldelay);
@@ -292,6 +544,7 @@ delaybits()
return (f);
}
+int
adelay(ms, dp)
register ms;
register struct delayval *dp;
@@ -302,13 +555,15 @@ adelay(ms, dp)
dp++;
return (dp->bits);
}
+#endif
-char editedhost[MAXHOSTNAMELEN];
+char editedhost[MAXHOSTNAMELEN];
+void
edithost(pat)
- register char *pat;
+ register const char *pat;
{
- register char *host = HN;
+ register const char *host = HN;
register char *res = editedhost;
if (!pat)
@@ -344,34 +599,36 @@ edithost(pat)
editedhost[sizeof editedhost - 1] = '\0';
}
-struct speedtab {
+static struct speedtab {
int speed;
int uxname;
} speedtab[] = {
- 50, B50,
- 75, B75,
- 110, B110,
- 134, B134,
- 150, B150,
- 200, B200,
- 300, B300,
- 600, B600,
- 1200, B1200,
- 1800, B1800,
- 2400, B2400,
- 4800, B4800,
- 9600, B9600,
- 19200, EXTA,
- 19, EXTA, /* for people who say 19.2K */
- 38400, EXTB,
- 38, EXTB,
- 7200, EXTB, /* alternative */
- 57600, B57600,
- 115200, B115200,
- 0
+ { 50, B50 },
+ { 75, B75 },
+ { 110, B110 },
+ { 134, B134 },
+ { 150, B150 },
+ { 200, B200 },
+ { 300, B300 },
+ { 600, B600 },
+ { 1200, B1200 },
+ { 1800, B1800 },
+ { 2400, B2400 },
+ { 4800, B4800 },
+ { 9600, B9600 },
+ { 19200, EXTA },
+ { 19, EXTA }, /* for people who say 19.2K */
+ { 38400, EXTB },
+ { 38, EXTB },
+ { 7200, EXTB }, /* alternative */
+ { 57600, B57600 },
+ { 115200, B115200 },
+ { 0 }
};
+int
speed(val)
+ int val;
{
register struct speedtab *sp;
@@ -385,22 +642,22 @@ speed(val)
return (B300); /* default in impossible cases */
}
+void
makeenv(env)
char *env[];
{
static char termbuf[128] = "TERM=";
register char *p, *q;
register char **ep;
- char *index();
ep = env;
if (TT && *TT) {
strcat(termbuf, TT);
*ep++ = termbuf;
}
- if (p = EV) {
+ if ((p = EV)) {
q = p;
- while (q = index(q, ',')) {
+ while ((q = strchr(q, ','))) {
*q++ = '\0';
*ep++ = p;
p = q;
@@ -418,8 +675,8 @@ makeenv(env)
* The routine below returns the terminal type mapped from derived speed.
*/
struct portselect {
- char *ps_baud;
- char *ps_type;
+ const char *ps_baud;
+ const char *ps_type;
} portspeeds[] = {
{ "B110", "std.110" },
{ "B134", "std.134" },
@@ -434,10 +691,11 @@ struct portselect {
{ 0 }
};
-char *
+const char *
portselector()
{
- char c, baud[20], *type = "default";
+ char c, baud[20];
+ const char *type = "default";
register struct portselect *ps;
int len;
@@ -469,15 +727,15 @@ portselector()
*/
#include <sys/time.h>
-char *
+const char *
autobaud()
{
int rfds;
struct timeval timeout;
- char c, *type = "9600-baud";
- int null = 0;
+ char c;
+ const char *type = "9600-baud";
- ioctl(0, TIOCFLUSH, &null);
+ (void)tcflush(0, TCIOFLUSH);
rfds = 1 << 0;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
@@ -490,7 +748,7 @@ autobaud()
timeout.tv_usec = 20;
(void) select(32, (fd_set *)NULL, (fd_set *)NULL,
(fd_set *)NULL, &timeout);
- ioctl(0, TIOCFLUSH, &null);
+ (void)tcflush(0, TCIOFLUSH);
switch (c & 0377) {
case 0200: /* 300-baud */
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index 8d31b23..7b65526 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -1,5 +1,5 @@
-.\" Copyright (c) 1985, 1991 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1985, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -29,9 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ttys.5 6.8 (Berkeley) 5/4/91
-.\"
-.Dd May 4, 1991
+.\" from: @(#)ttys.5 8.1 (Berkeley) 6/4/93
+.\" $Id: ttys.5,v 1.1.1.2 1996/04/13 15:33:16 joerg Exp $
+.\" "
+.Dd June 4, 1993
.Dt TTYS 5
.Os
.Sh NAME
@@ -96,6 +97,18 @@ should (should not) execute the command given in the second field,
while ``secure'' (if ``on'' is also specified) allows users with a
uid of 0 to login on
this line.
+The flags ``local'', ``rtscts'', ``mdmbuf'', and ``softcar''
+modify the default behaviour of the terminal line, and their actions
+are driver dependent.
+The ``local'' flag causes the driver to
+treat the line as if it locally connected.
+The ``rtscts'' flag
+instructs the driver to use RTS/CTS hardware flow control, if
+possible.
+The ``mdmbuf'' flag instructs the driver to use
+DTR/DCD flow control, if possible.
+The ``softcar'' flag causes the driver to ignore
+hardware carrier on the line.
These flag fields should not be quoted.
.Pp
The string ``window='' may be followed by a quoted command
@@ -132,6 +145,8 @@ ttyp1 none network off
.Xr termcap 5 ,
.Xr getty 8 ,
.Xr init 8
+.\".Xr init 8 ,
+.\".Xr ttyflags 8
.Sh HISTORY
A
.Nm
OpenPOWER on IntegriCloud