summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>1997-05-11 05:28:54 +0000
committerDavid Nugent <davidn@FreeBSD.org>1997-05-11 05:28:54 +0000
commite2708d8dab64d8e17ed6370aacd6c03a77aa4af1 (patch)
tree40d4f87171447738dd4eceda24a56cd34ca52d14 /libexec
parent4e66f8c158131ec5f00c647bb7029653bae65b58 (diff)
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getty/Makefile4
-rw-r--r--libexec/getty/extern.h4
-rw-r--r--libexec/getty/getty.88
-rw-r--r--libexec/getty/gettytab.5125
-rw-r--r--libexec/getty/gettytab.h10
-rw-r--r--libexec/getty/init.c9
-rw-r--r--libexec/getty/main.c254
-rw-r--r--libexec/getty/subr.c15
-rw-r--r--libexec/getty/ttys.557
9 files changed, 389 insertions, 97 deletions
diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile
index 96f7f7ed17b5..8686b458cca6 100644
--- a/libexec/getty/Makefile
+++ b/libexec/getty/Makefile
@@ -1,8 +1,8 @@
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
-# $Id: Makefile,v 1.1.1.2 1996/04/13 15:33:02 joerg Exp $
+# $Id: Makefile,v 1.5 1996/05/05 19:01:06 joerg Exp $
PROG= getty
-SRCS= main.c init.c subr.c
+SRCS= main.c init.c subr.c chat.c
DPADD= ${LIBUTIL}
LDADD= -lutil
MAN5= gettytab.5 ttys.5
diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h
index bcffdae3d04d..32fd6135bc3b 100644
--- a/libexec/getty/extern.h
+++ b/libexec/getty/extern.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)extern.h 8.1 (Berkeley) 6/4/93
- * $Id: extern.h,v 1.1.1.4 1996/04/13 15:33:04 joerg Exp $
+ * $Id: extern.h,v 1.2 1996/05/05 19:01:07 joerg Exp $
*/
struct delayval;
@@ -60,3 +60,5 @@ void setchars __P((void));
void setdefaults __P((void));
void setflags __P((int));
int speed __P((int));
+int getty_chat __P((char *, int, int));
+
diff --git a/libexec/getty/getty.8 b/libexec/getty/getty.8
index bc0e05082fe9..227e7141b924 100644
--- a/libexec/getty/getty.8
+++ b/libexec/getty/getty.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" 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 $
+.\" $Id: getty.8,v 1.4 1996/05/05 19:01:07 joerg Exp $
.\" "
.Dd June 4, 1993
.Dt GETTY 8
@@ -115,12 +115,12 @@ does not exist.
.It Pa /etc/gettytab
.El
.Sh SEE ALSO
-.Xr gettytab 5 ,
-.Xr init 8 ,
.Xr login 1 ,
.Xr ioctl 2 ,
.Xr tty 4 ,
-.Xr ttys 5
+.Xr gettytab 5 ,
+.Xr ttys 5 ,
+.Xr init 8
.Sh HISTORY
A
.Nm getty
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index 87f283242c5a..34a4961807e8 100644
--- a/libexec/getty/gettytab.5
+++ b/libexec/getty/gettytab.5
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
-.\" $Id: gettytab.5,v 1.7.2.2 1996/12/22 23:05:11 mpp Exp $
+.\" $Id: gettytab.5,v 1.7.2.3 1996/12/31 05:50:26 msmith Exp $
.\" "
.Dd April 19, 1994
.Dt GETTYTAB 5
@@ -76,6 +76,7 @@ no entry in the table obtained, nor one in the special
table.
.Bl -column Namexx /usr/bin/login Default
.It Sy Name Type Default Description
+.It "ac str unused expect-send chat script for modem answer"
.It "ap bool false terminal uses any parity"
.It "bk str 0377 alternate end of line character (input break)"
.It "c0 num unused tty control flags to write messages"
@@ -88,7 +89,9 @@ table.
.It "co bool false console - add"
.Ql \en
after login prompt
-.It "de num 0 delay secs before writing first prompt"
+.It "ct num 10 chat timeout for ac/ic scripts"
+.It "dc num 0 chat debug bitmask"
+.It "de num 0 delay secs and flush input before writing first prompt"
.It "ds str" Ta So Li ^Y Sc Ta
.No "delayed suspend character"
.It "dx bool false set"
@@ -116,9 +119,12 @@ hangup line on last close
.No "hostname editing string"
.It "hn str hostname hostname"
.It "ht bool false terminal has real tabs"
+.It "hw bool false do cts/rts hardware flow control"
.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 "ic str unused expect-send chat script for modem initialization"
+.It "if str unused display named file before prompt"
.It "ig bool false ignore garbage characters in login name"
.It "im str" Ta Dv NULL Ta
.No "initial (banner) message"
@@ -157,6 +163,7 @@ port selector
.No "quit character"
.It "rp str" Ta So Li ^R Sc Ta
.No "line retype character"
+.It "rt num unused ring timeout when using ac"
.It "rw bool false do"
.Tn NOT
use raw for input, use cbreak
@@ -269,7 +276,7 @@ information about the environment in which
.Xr getty 8
is running.
.Pp
-.Bl -tag -width \&%xxx -compact
+.Bl -tag -offset indent -width \&%xxxxxxxxxxxxxx
.It \&%d
The current date and time in the locale's representation as of the
.Em \&Lo
@@ -364,12 +371,122 @@ If
string is specified and a PPP link bringup sequence is recognized,
getty will invoke the program referenced by the pp option. This
can be used to handle incoming PPP calls.
+.Pp
+.Nm getty
+provides some basic intelligent modem handling by providing a chat
+script feature available via two capabilities:
+.Pp
+.Bl -tag -offset indent -width \&xxxxxxxx -compact
+.It ic
+Chat script to initialize modem.
+.It ac
+Chat script to answer a call.
+.El
+.Pp
+A chat script is a set of expect/send string pairs.
+When a chat string starts,
+.Nm Getty
+will wait for the first string, and if it finds it, will send the
+second, and so on.
+Strings specified are separated by one or more tabs or spaces.
+Strings may contain standard ascii characters and special 'escapes',
+which consist of a backslash character followed by one or more
+characters which are interpreted as follows:
+.Pp
+.Bl -tag -offset indent -width \&xxxxxxxx -compact
+.It \ea
+bell character.
+.It \eb
+backspace.
+.It \en
+newline.
+.It \ee
+escape.
+.It \ef
+formfeed.
+.It \ep
+half-second pause.
+.It \er
+carriage return.
+.It \eS, \es
+space character.
+.It \et
+tab.
+.It \exNN
+hexadecimal byte value.
+.It \e0NNN
+octal byte value.
+.El
+.Pp
+Note that the
+.Ql \ep
+sequence is only valid for send strings and causes a half-second
+pause between sending the previous and next characters.
+Hexidecimal values are, at most, 2 hex digits long, and octal
+values are a maximum of 3 octal digits.
+.Pp
+The
+.Em \&ic
+chat sequence is used to initialize a modem or similar device.
+A typical example of an init chat script for a modem with a
+hayes compatible command set might look like this:
+.Pp
+.Dl :ic="" ATE0Q0V1\er OK\er ATS0=0\er OK\er:
+.Pp
+This script waits for nothing (which always succeeds), sends
+a sequence to ensure that the modem is in the correct mode
+(suppress command echo, send responses in verbose mode),
+and then disables auto-answer.
+It waits for an "OK" response before it terminates.
+The init sequence is used to check modem responses to ensure that
+the modem is functioning correctly.
+If the init script fails to complete,
+.Nm getty
+considers this to be fatal, and results in an error logged via
+.Xr syslogd 8 ,
+and exiting.
+.Pp
+Similarly, an answer chat script is used to manually answer the
+phone in response to (usually) a "RING".
+When run with an answer script,
+.Nm getty
+opens the port in non-blocking mode, clears any extraneous input
+and waits for data on the port.
+As soon as any data is available, the answer chat script is
+started and scanned for a string, and responds according to
+the answer chat script.
+With a hayes compatible modem, this would normally look something
+like:
+.Pp
+.Dl :ac=RING\er ATA\er CONNECT:
+.Pp
+This causes the modem to answer the call via the "ATA" command,
+then scans input for a "CONNECT" string.
+If this is received before a
+.Em \&ct timeout, then a normal login sequence commences.
+.Pp
+The
+.Em \&ct
+capability specifies a timeout for all send and expect strings.
+This timeout is set individually for each expect wait and send
+string and must be at least as long as the time it takes for
+a connection to be established between a remote and local
+modem (usually around 10 seconds).
+.Pp
+In most situations, you will want to flush any additional
+input after the connection has been detected, and the
+.Em \&de
+capability may be used to do that, as well as delay for a
+short time after the connection has been established during
+which all of the connection data has been sent by the modem.
+.Pp
.Sh SEE ALSO
.Xr login 1 ,
.Xr gethostname 3 ,
.Xr uname 3 ,
.Xr termcap 5 ,
-.Xr getty 8 .
+.Xr getty 8 ,
+.Xr telnetd 8 .
.Sh BUGS
The special characters (erase, kill, etc.) are reset to system defaults
by
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index 92ec3d2d2a2a..7ed2e4ce9c71 100644
--- a/libexec/getty/gettytab.h
+++ b/libexec/getty/gettytab.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
- * $Id: gettytab.h,v 1.3.2.1 1996/11/16 21:07:00 phk Exp $
+ * $Id: gettytab.h,v 1.3.2.2 1996/12/31 05:50:27 msmith Exp $
*/
/*
@@ -87,6 +87,9 @@ struct gettyflags {
#define LN gettystrs[23].value
#define Lo gettystrs[24].value
#define PP gettystrs[25].value
+#define IF gettystrs[26].value
+#define IC gettystrs[27].value
+#define AC gettystrs[28].value
/*
* Numeric definitions.
@@ -132,6 +135,10 @@ struct gettyflags {
#define O2 gettynums[24].value
#define O2set gettynums[24].set
#define DE gettynums[25].value
+#define RTset gettynums[26].set
+#define RT gettynums[26].value
+#define CT gettynums[27].value
+#define DC gettynums[28].value
/*
* Boolean values.
@@ -162,4 +169,5 @@ struct gettyflags {
#define DX gettyflags[20].value
#define NP gettyflags[21].value
#define MB gettyflags[22].value
+#define HW gettyflags[23].value
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index 0390f293a1a0..7e1f570ba4ea 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$Id: init.c,v 1.3.2.1 1996/11/16 21:07:02 phk Exp $";
+static char rcsid[] = "$Id: init.c,v 1.3.2.2 1996/12/31 05:50:28 msmith Exp $";
#endif /* not lint */
/*
@@ -77,6 +77,9 @@ struct gettystrs gettystrs[] = {
{ "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
{ "Lo" }, /* locale for strftime() */
{ "pp" }, /* ppp login program */
+ { "if" }, /* sysv-like 'issue' filename */
+ { "ic" }, /* modem init-chat */
+ { "ac" }, /* modem answer-chat */
{ 0 }
};
@@ -107,6 +110,9 @@ struct gettynums gettynums[] = {
{ "o1" }, /* input o_flags */
{ "o2" }, /* user mode o_flags */
{ "de" }, /* delay before sending 1st prompt */
+ { "rt" }, /* reset timeout */
+ { "ct" }, /* chat script timeout */
+ { "dc" }, /* debug chat script value */
{ 0 }
};
@@ -135,5 +141,6 @@ struct gettyflags gettyflags[] = {
{ "dx", 0 }, /* set decctlq */
{ "np", 0 }, /* no parity at all (8bit chars) */
{ "mb", 0 }, /* do MDMBUF flow control */
+ { "hw", 0 }, /* do CTSRTS flow control */
{ 0 }
};
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index 0c52e28f847f..7b708a941947 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/
-static char rcsid[] = "$Id: main.c,v 1.10.2.1 1996/11/16 21:07:03 phk Exp $";
+static char rcsid[] = "$Id: main.c,v 1.10.2.2 1996/12/31 05:50:28 msmith Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -93,8 +93,7 @@ struct termios tmode, omode;
int crmod, digit, lower, upper;
char hostname[MAXHOSTNAMELEN];
-struct utsname kerninfo;
-char name[16];
+char name[MAXLOGNAME*3];
char dev[] = _PATH_DEV;
char ttyn[32];
@@ -129,8 +128,6 @@ char partab[] = {
#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));
@@ -141,9 +138,15 @@ static void putf __P((const char *));
static void putpad __P((const char *));
static void puts __P((const char *));
static void timeoverrun __P((int));
+static char *getline __P((int));
+static void setttymode __P((const char *, int));
+static void setdefttymode __P((const char *));
+static int opentty __P((const char *, int));
int main __P((int, char **));
+jmp_buf timeout;
+
static void
dingdong(signo)
int signo;
@@ -181,6 +184,7 @@ main(argc, argv)
extern char **environ;
const char *tname;
int repcnt = 0, failopenlogged = 0;
+ int first_sleep = 1, first_time = 1;
struct rlimit limit;
int rval;
@@ -200,6 +204,12 @@ main(argc, argv)
limit.rlim_cur = GETTY_TIMEOUT;
(void)setrlimit(RLIMIT_CPU, &limit);
+ gettable("default", defent);
+ gendefaults();
+ tname = "default";
+ if (argc > 1)
+ tname = argv[1];
+
/*
* The following is a work around for vhangup interactions
* which cause great problems getting window systems started.
@@ -208,7 +218,7 @@ main(argc, argv)
* J. Gettys - MIT Project Athena.
*/
if (argc <= 2 || strcmp(argv[2], "-") == 0)
- strcpy(ttyn, ttyname(0));
+ strcpy(ttyn, ttyname(STDIN_FILENO));
else {
int i;
@@ -218,23 +228,57 @@ main(argc, argv)
chown(ttyn, 0, 0);
chmod(ttyn, 0600);
revoke(ttyn);
- while ((i = open(ttyn, O_RDWR)) == -1) {
- if ((repcnt % 10 == 0) &&
- (errno != ENXIO || !failopenlogged)) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- closelog();
- failopenlogged = 1;
+
+ gettable(tname, tabent);
+
+ /* Init modem sequence has been specified
+ */
+ if (IC) {
+ if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
+ exit(1);
+ setdefttymode(tname);
+ if (getty_chat(IC, CT, DC) > 0) {
+ syslog(LOG_ERR, "modem init problem on %s", ttyn);
+ (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
+ exit(1);
}
- repcnt++;
- sleep(60);
}
- login_tty(i);
+
+ if (AC) {
+ int i, rfds;
+ struct timeval timeout;
+
+ if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
+ exit(1);
+ setdefttymode(tname);
+ rfds = 1 << 0; /* FD_SET */
+ timeout.tv_sec = RT;
+ timeout.tv_usec = 0;
+ i = select(32, (fd_set*)&rfds, (fd_set*)NULL,
+ (fd_set*)NULL, RT ? &timeout : NULL);
+ if (i < 0) {
+ syslog(LOG_ERR, "select %s: %m", ttyn);
+ } else if (i == 0) {
+ syslog(LOG_NOTICE, "recycle tty %s", ttyn);
+ (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
+ exit(0); /* recycle for init */
+ }
+ i = getty_chat(AC, CT, DC);
+ if (i > 0) {
+ syslog(LOG_ERR, "modem answer problem on %s", ttyn);
+ (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
+ exit(1);
+ }
+ } else { /* blocking open */
+ if (!opentty(ttyn, O_RDWR))
+ exit(1);
+ }
}
}
/* Start with default tty settings */
- if (tcgetattr(0, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
+ if (tcgetattr(STDIN_FILENO, &tmode) < 0) {
+ syslog(LOG_ERR, "tcgetattr %s: %m", ttyn);
exit(1);
}
/*
@@ -250,37 +294,20 @@ main(argc, argv)
tmode.c_cflag = TTYDEF_CFLAG;
omode = tmode;
- gettable("default", defent);
- gendefaults();
- tname = "default";
- if (argc > 1)
- tname = argv[1];
for (;;) {
- int off = 0;
-
- gettable(tname, tabent);
- if (OPset || EPset || APset)
- APset++, OPset++, EPset++;
- setdefaults();
- 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 */
- if (IS)
- cfsetispeed(&tmode, speed(IS));
- else if (SP)
- cfsetispeed(&tmode, speed(SP));
- if (OS)
- cfsetospeed(&tmode, speed(OS));
- else if (SP)
- cfsetospeed(&tmode, speed(SP));
- setflags(0);
- setchars();
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- exit(1);
+ /*
+ * if a delay was specified then sleep for that
+ * number of seconds before writing the initial prompt
+ */
+ if (first_sleep && DE) {
+ sleep(DE);
+ /* remove any noise */
+ (void)tcflush(STDIN_FILENO, TCIOFLUSH);
}
+ first_sleep = 0;
+
+ setttymode(tname, 0);
if (AB) {
tname = autobaud();
continue;
@@ -293,17 +320,28 @@ main(argc, argv)
putpad(CL);
edithost(HE);
- /* if a delay was specified then sleep for that
- number of seconds before writing the initial prompt */
- if(DE)
- sleep(DE);
+ /* if this is the first time through this, and an
+ issue file has been given, then send it */
+ if (first_time && IF) {
+ int fd;
+
+ if ((fd = open(IF, O_RDONLY)) != -1) {
+ char * cp;
+
+ while ((cp = getline(fd)) != NULL) {
+ putf(cp);
+ }
+ close(fd);
+ }
+ }
+ first_time = 0;
if (IM && *IM)
putf(IM);
if (setjmp(timeout)) {
cfsetispeed(&tmode, B0);
cfsetospeed(&tmode, B0);
- (void)tcsetattr(0, TCSANOW, &tmode);
+ (void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
exit(1);
}
if (TO) {
@@ -337,8 +375,8 @@ main(argc, argv)
if (lower || LC)
tmode.sg_flags &= ~LCASE;
#endif
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
+ if (tcsetattr(STDIN_FILENO, TCSANOW, &tmode) < 0) {
+ syslog(LOG_ERR, "tcsetattr %s: %m", ttyn);
exit(1);
}
signal(SIGINT, SIG_DFL);
@@ -362,12 +400,87 @@ main(argc, argv)
}
static int
+opentty(const char *ttyn, int flags)
+{
+ int i, j = 0;
+ int failopenlogged = 0;
+
+ while (j < 10 && (i = open(ttyn, flags)) == -1)
+ {
+ if (((j % 10) == 0) && (errno != ENXIO || !failopenlogged)) {
+ syslog(LOG_ERR, "open %s: %m", ttyn);
+ failopenlogged = 1;
+ }
+ j++;
+ sleep(60);
+ }
+ if (i == -1) {
+ syslog(LOG_ERR, "open %s: %m", ttyn);
+ return 0;
+ }
+ else {
+ login_tty(i);
+ return 1;
+ }
+}
+
+static void
+setdefttymode(tname)
+ const char * tname;
+{
+ if (tcgetattr(STDIN_FILENO, &tmode) < 0) {
+ syslog(LOG_ERR, "tcgetattr %s: %m", ttyn);
+ exit(1);
+ }
+ tmode.c_iflag = TTYDEF_IFLAG;
+ tmode.c_oflag = TTYDEF_OFLAG;
+ tmode.c_lflag = TTYDEF_LFLAG;
+ tmode.c_cflag = TTYDEF_CFLAG;
+ omode = tmode;
+ setttymode(tname, 1);
+}
+
+static void
+setttymode(tname, raw)
+ const char * tname;
+ int raw;
+{
+ int off = 0;
+
+ gettable(tname, tabent);
+ if (OPset || EPset || APset)
+ APset++, OPset++, EPset++;
+ setdefaults();
+ (void)tcflush(STDIN_FILENO, TCIOFLUSH); /* clear out the crap */
+ ioctl(STDIN_FILENO, FIONBIO, &off); /* turn off non-blocking mode */
+ ioctl(STDIN_FILENO, FIOASYNC, &off); /* ditto for async mode */
+
+ if (IS)
+ cfsetispeed(&tmode, speed(IS));
+ else if (SP)
+ cfsetispeed(&tmode, speed(SP));
+ if (OS)
+ cfsetospeed(&tmode, speed(OS));
+ else if (SP)
+ cfsetospeed(&tmode, speed(SP));
+ setflags(0);
+ setchars();
+ if (raw)
+ cfmakeraw(&tmode);
+ if (tcsetattr(STDIN_FILENO, TCSANOW, &tmode) < 0) {
+ syslog(LOG_ERR, "tcsetattr %s: %m", ttyn);
+ exit(1);
+ }
+}
+
+
+static int
getname()
{
register int c;
register char *np;
unsigned char cs;
- int ppp_state;
+ int ppp_state = 0;
int ppp_connection = 0;
/*
@@ -385,7 +498,7 @@ getname()
sleep(PF);
PF = 0;
}
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
+ if (tcsetattr(STDIN_FILENO, TCSANOW, &tmode) < 0) {
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}
@@ -427,7 +540,7 @@ getname()
if (c == EOT || c == CTRL('d'))
exit(1);
- if (c == '\r' || c == '\n' || np >= &name[sizeof name]) {
+ if (c == '\r' || c == '\n' || np >= &name[sizeof name-1]) {
putf("\r\n");
break;
}
@@ -558,6 +671,32 @@ prompt()
putchr('\n');
}
+
+static char *
+getline(fd)
+ int fd;
+{
+ int i = 0;
+ static char linebuf[512];
+
+ /*
+ * This is certainly slow, but it avoids having to include
+ * stdio.h unnecessarily. Issue files should be small anyway.
+ */
+ while (i < (sizeof linebuf - 3) && read(fd, linebuf+i, 1)==1) {
+ if (linebuf[i] == '\n') {
+ /* Don't rely on newline mode, assume raw */
+ linebuf[i++] = '\r';
+ linebuf[i++] = '\n';
+ linebuf[i] = '\0';
+ return linebuf;
+ }
+ ++i;
+ }
+ linebuf[i] = '\0';
+ return i ? linebuf : 0;
+}
+
static void
putf(cp)
register const char *cp;
@@ -566,6 +705,11 @@ putf(cp)
time_t t;
char *slash, db[100];
+ static struct utsname kerninfo;
+
+ if (!*kerninfo.sysname)
+ uname(&kerninfo);
+
while (*cp) {
if (*cp != '%') {
putchr(*cp++);
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index 171860552c71..b9bf6999a38f 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -33,7 +33,7 @@
#ifndef lint
/*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 $";
+static char rcsid[] = "$Id: subr.c,v 1.6 1996/05/05 19:01:11 joerg Exp $";
#endif /* not lint */
/*
@@ -75,13 +75,13 @@ gettable(name, buf)
dba[0] = _PATH_GETTYTAB;
dba[1] = 0;
- if (cgetent(&buf, dba, name) != 0)
+ if (cgetent(&buf, (char**)dba, (char*)name) != 0)
return;
for (sp = gettystrs; sp->field; sp++)
- cgetstr(buf, sp->field, &sp->value);
+ cgetstr(buf, (char*)sp->field, &sp->value);
for (np = gettynums; np->field; np++) {
- if (cgetnum(buf, np->field, &n) == -1)
+ if (cgetnum(buf, (char*)np->field, &n) == -1)
np->set = 0;
else {
np->set = 1;
@@ -89,7 +89,7 @@ gettable(name, buf)
}
}
for (fp = gettyflags; fp->field; fp++) {
- if (cgetcap(buf, fp->field, ':') == NULL)
+ if (cgetcap(buf, (char*)fp->field, ':') == NULL)
fp->set = 0;
else {
fp->set = 1;
@@ -284,6 +284,11 @@ setflags(n)
else
CLR(cflag, MDMBUF);
+ if (HW)
+ SET(cflag, CRTSCTS);
+ else
+ CLR(cflag, CRTSCTS);
+
if (NL) {
SET(iflag, ICRNL);
SET(oflag, ONLCR|OPOST);
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index 7b655265da3f..fe4a95742b2d 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -30,9 +30,9 @@
.\" SUCH DAMAGE.
.\"
.\" 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 $
+.\" $Id: ttys.5,v 1.3 1996/05/05 19:01:13 joerg Exp $
.\" "
-.Dd June 4, 1993
+.Dd November 17, 1996
.Dt TTYS 5
.Os
.Sh NAME
@@ -86,10 +86,17 @@ or
The remaining fields set flags in the
.Fa ty_status
entry (see
-.Xr getttyent 3 )
-or specify a window system process that
+.Xr getttyent 3 ),
+specify a window system process that
.Xr init 8
-will maintain for the terminal line.
+will maintain for the terminal line, optionally determine the
+type of tty (whether dialin, network or otherwise),
+or specify a tty group
+name that allows the login class database (see
+.Xr login.conf 5 )
+to refer to many ttys as a group, to selectively allow or
+deny access or enable or disable accounting facilities for
+ttys as a group.
.Pp
As flag values, the strings ``on'' and ``off'' specify that
.Xr init
@@ -97,41 +104,42 @@ 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 flag ``dialin'' indicates that a tty entry describes a dialin
+line, and ``network'' indicates that a tty entry provides a
+network connection.
+Either of these strings may also be specified in the terminal type
+field.
The string ``window='' may be followed by a quoted command
string which
.Xr init
will execute
.Em before
starting the command specified by the second field.
+.Pp
+The string ``group='' may be followed by a group name comprised of
+alphanumeric characters that can be used by
+.Xr login.group 5
+to refer to many tty lines as a group to enable or disable access
+and accounting facilities.
+If no group is specified, then the tty becomes a member of the group
+"none".
+For backwards compatibility, the ``group='' should appear last on the
+line, immediately before the optional comment.
.Sh EXAMPLES
.Bd -literal
# root login on console at 1200 baud
console "/usr/libexec/getty std.1200" vt100 on secure
# dialup at 1200 baud, no root logins
-ttyd0 "/usr/libexec/getty d1200" dialup on # 555-1234
+ttyd0 "/usr/libexec/getty d1200" dialup on group=dialup # 555-1234
# Mike's terminal: hp2621
-ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on # 457 Evans
+ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on group=dialup # 457 Evans
# John's terminal: vt100
-ttyh1 "/usr/libexec/getty std.9600" vt100 on # 459 Evans
+ttyh1 "/usr/libexec/getty std.9600" vt100 on group=dialup # 459 Evans
# terminal emulate/window system
ttyv0 "/usr/new/xterm -L :0" vs100 on window="/usr/new/Xvs100 0"
# Network pseudo ttys -- don't enable getty
-ttyp0 none network
-ttyp1 none network off
+ttyp0 none network group=pty
+ttyp1 none network off group=pty
.Ed
.Sh FILES
.Bl -tag -width /etc/ttys -compact
@@ -142,6 +150,7 @@ ttyp1 none network off
.Xr getttyent 3 ,
.Xr ttyslot 3 ,
.Xr gettytab 5 ,
+.Xr login.conf 5 ,
.Xr termcap 5 ,
.Xr getty 8 ,
.Xr init 8