Cleanup import, merge local changes.

This commit is contained in:
pk 1994-08-17 20:10:27 +00:00
parent af080bda6b
commit fe82241620
10 changed files with 199 additions and 121 deletions

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.12 (Berkeley) 1/21/91
# $Id: Makefile,v 1.4 1994/03/09 04:59:55 cgd Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
# $Id: Makefile,v 1.5 1994/08/17 20:10:27 pk Exp $
PROG= getty
SRCS= main.c init.c subr.c

View File

@ -30,7 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)extern.h 8.1 (Berkeley) 6/4/93
* from: @(#)extern.h 8.1 (Berkeley) 6/4/93
* $Id: extern.h,v 1.2 1994/08/17 20:10:29 pk Exp $
*/
struct delayval;
@ -50,7 +51,7 @@ char *portselector __P((void));
void set_ttydefaults __P((int));
void setchars __P((void));
void setdefaults __P((void));
long setflags __P((int));
void setflags __P((int));
int speed __P((int));
int login_tty __P((int)); /* From libutil. */

View File

@ -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,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)getty.8 6.6 (Berkeley) 4/25/91
.\" $Id: getty.8,v 1.2 1993/08/01 07:40:16 mycroft Exp $
.\" from: @(#)getty.8 8.1 (Berkeley) 6/4/93
.\" $Id: getty.8,v 1.3 1994/08/17 20:10:30 pk Exp $
.\"
.Dd April 25, 1991
.Dd June 4, 1993
.Dt GETTY 8
.Os BSD 4
.Sh NAME

View File

@ -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,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)gettytab.5 6.7 (Berkeley) 5/10/91
.\" $Id: gettytab.5,v 1.8 1994/04/29 21:48:49 cgd Exp $
.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
.\" $Id: gettytab.5,v 1.9 1994/08/17 20:10:31 pk Exp $
.\"
.Dd May 10, 1991
.Dd April 19, 1994
.Dt GETTYTAB 5
.Os BSD 4.2
.Sh NAME
@ -102,7 +102,7 @@ after login prompt
.Pq Dv EOF
character
.It "ev str" Ta Dv NULL Ta
.No "initial enviroment"
.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"
@ -199,7 +199,7 @@ for input of the login name,
and to leave the terminal set as upon completion,
are derived from the boolean flags specified.
If the derivation should prove inadequate,
any (or all) of these three may be overriden
any (or all) of these three may be overridden
with one of the
.Em \&c0 ,
.Em \&c1 ,
@ -295,7 +295,7 @@ in the
string (usually
.Dq Pa /usr/bin/login ) ,
it will have set
the enviroment to include the terminal type, as indicated
the environment to include the terminal type, as indicated
by the
.Em \&tt
string (if it exists).

View File

@ -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,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)gettytab.h 5.5 (Berkeley) 3/27/91
* $Id: gettytab.h,v 1.6 1994/04/28 22:12:28 pk Exp $
* from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
* $Id: gettytab.h,v 1.7 1994/08/17 20:10:34 pk Exp $
*/
/*
@ -160,10 +160,10 @@ struct gettyflags {
#define NP gettyflags[21].value
#define MB gettyflags[22].value
int getent();
long getnum();
int getflag();
char *getstr();
int getent __P((char *, char *));
long getnum __P((char *));
int getflag __P((char *));
char *getstr __P((char *, char **));
extern struct gettyflags gettyflags[];
extern struct gettynums gettynums[];

View File

@ -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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)init.c 5.6 (Berkeley) 3/27/91";*/
static char rcsid[] = "$Id: init.c,v 1.5 1994/04/28 22:12:29 pk Exp $";
/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$Id: init.c,v 1.6 1994/08/17 20:10:35 pk Exp $";
#endif /* not lint */
/*

View File

@ -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,35 +32,46 @@
*/
#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[] = "from: @(#)main.c 5.16 (Berkeley) 3/27/91";*/
static char rcsid[] = "$Id: main.c,v 1.7 1994/04/28 22:12:30 pk Exp $";
/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/
static char rcsid[] = "$Id: main.c,v 1.8 1994/08/17 20:10:37 pk Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/termios.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <signal.h>
#include <fcntl.h>
#include <time.h>
#include <ctype.h>
#include <fcntl.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 <time.h>
#include <unistd.h>
#include "gettytab.h"
#include "pathnames.h"
#include "extern.h"
struct termios tmode;
/*
* Set the amount of running time that getty should accumulate
* before deciding that something is wrong and exit.
*/
#define GETTY_TIMEOUT 60 /* seconds */
struct termios tmode, omode;
int crmod, digit, lower, upper;
@ -124,14 +135,36 @@ interrupt()
longjmp(intrupt, 1);
}
/*
* Action to take when getty is running too long.
*/
void
timeoverrun(signo)
int signo;
{
syslog(LOG_ERR, "getty exiting due to excessive running time\n");
exit(1);
}
static int getname __P((void));
static void oflush __P((void));
static void prompt __P((void));
static void putchr __P((int));
static void putf __P((char *));
static void putpad __P((char *));
static void puts __P((char *));
int
main(argc, argv)
int argc;
char **argv;
char *argv[];
{
extern char **environ;
extern char **environ;
char *tname;
long allflags;
int repcnt = 0;
struct rlimit limit;
signal(SIGINT, SIG_IGN);
/*
@ -142,6 +175,15 @@ main(argc, argv)
if (hostname[0] == '\0')
strcpy(hostname, "Amnesiac");
uname(&kerninfo);
/*
* 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.
@ -181,6 +223,7 @@ main(argc, argv)
syslog(LOG_ERR, "%s: %m", ttyn);
exit(1);
}
omode = tmode;
gettable("default", defent);
gendefaults();
@ -188,12 +231,13 @@ main(argc, argv)
if (argc > 1)
tname = argv[1];
for (;;) {
int off = 0;
int off;
gettable(tname, tabent);
if (OPset || EPset || APset)
APset++, OPset++, EPset++;
setdefaults();
off = 0;
ioctl(0, TIOCFLUSH, &off); /* clear out the crap */
ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
ioctl(0, FIOASYNC, &off); /* ditto for async mode */
@ -267,6 +311,10 @@ main(argc, argv)
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);
@ -279,6 +327,7 @@ main(argc, argv)
}
}
static int
getname()
{
register int c;
@ -365,6 +414,7 @@ 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;
{
@ -406,6 +456,7 @@ putpad(s)
putchr(*PC);
}
static void
puts(s)
register char *s;
{
@ -416,7 +467,9 @@ puts(s)
char outbuf[OBUFSIZ];
int obufcnt = 0;
static void
putchr(cc)
int cc;
{
char c;
@ -434,6 +487,7 @@ putchr(cc)
write(STDOUT_FILENO, &c, 1);
}
static void
oflush()
{
if (obufcnt)
@ -441,6 +495,7 @@ oflush()
obufcnt = 0;
}
static void
prompt()
{
@ -449,6 +504,7 @@ prompt()
putchr('\n');
}
static void
putf(cp)
register char *cp;
{
@ -464,7 +520,7 @@ putf(cp)
switch (*++cp) {
case 't':
slash = rindex(ttyn, '/');
slash = strrchr(ttyn, '/');
if (slash == (char *) 0)
puts(ttyn);
else

View File

@ -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,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)pathnames.h 5.3 (Berkeley) 6/1/90
* $Id: pathnames.h,v 1.2 1993/08/01 18:30:27 mycroft Exp $
* from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93
* $Id: pathnames.h,v 1.3 1994/08/17 20:10:39 pk Exp $
*/
#include <paths.h>

View File

@ -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,8 +32,8 @@
*/
#ifndef lint
/*static char sccsid[] = "from: @(#)subr.c 5.10 (Berkeley) 2/26/91";*/
static char rcsid[] = "$Id: subr.c,v 1.8 1994/08/15 15:46:44 pk Exp $";
/*static char sccsid[] = "from: @(#)subr.c 8.1 (Berkeley) 6/4/93";*/
static char rcsid[] = "$Id: subr.c,v 1.9 1994/08/17 20:10:40 pk Exp $";
#endif /* not lint */
/*
@ -48,13 +48,16 @@ static char rcsid[] = "$Id: subr.c,v 1.8 1994/08/15 15:46:44 pk Exp $";
#include "gettytab.h"
#include "pathnames.h"
#include "extern.h"
extern struct termios tmode;
extern struct termios tmode, omode;
static void compatflags __P((long));
/*
* Get a table entry.
*/
void
gettable(name, buf)
char *name, *buf;
{
@ -94,12 +97,13 @@ gettable(name, buf)
for (np = gettynums; np->field; np++)
printf("cgetnum: %s=%d\n", np->field, np->value);
for (fp = gettyflags; fp->field; fp++)
printf("cgetflags: %s='%c' set='%c'\n", fp->field,
fp->value + '0', fp->set + '0');
printf("cgetflags: %s='%c' set='%c'\n", fp->field,
fp->value + '0', fp->set + '0');
exit(1);
#endif /* DEBUG */
}
void
gendefaults()
{
register struct gettystrs *sp;
@ -119,6 +123,7 @@ gendefaults()
fp->defalt = fp->invrt;
}
void
setdefaults()
{
register struct gettystrs *sp;
@ -151,6 +156,7 @@ charvars[] = {
&tmode.c_cc[VWERASE], &tmode.c_cc[VLNEXT], 0
};
void
setchars()
{
register int i;
@ -167,6 +173,7 @@ setchars()
void
setflags(n)
int n;
{
register tcflag_t iflag, oflag, cflag, lflag;
@ -223,25 +230,28 @@ setflags(n)
break;
}
iflag = (BRKINT|ICRNL|IMAXBEL|IXON|IXANY);
oflag = (OPOST|ONLCR|OXTABS);
cflag = (CREAD);
lflag = (ICANON|ISIG|IEXTEN);
#define BIC(v,c) (v) &= ~(c)
#define BIS(v,s) (v) |= (s)
#define BICS(v,c,s) BIC(v,c),BIS(v,s)
iflag = omode.c_iflag;
oflag = omode.c_oflag;
cflag = omode.c_cflag;
lflag = omode.c_lflag;
if (NP) {
iflag |= IGNPAR;
cflag |= CS8;
BIC(iflag, ISTRIP|INPCK|IGNPAR);
BICS(cflag, CSIZE|PARENB|PARODD, CS8);
} else if (OP && !EP) {
iflag |= INPCK|ISTRIP;
cflag |= PARENB|PARODD|CS7;
BIS(iflag, ISTRIP|INPCK|IGNPAR);
BICS(cflag, CSIZE, PARENB|PARODD|CS7);
} else if (EP && !OP) {
iflag |= INPCK|ISTRIP;
cflag |= PARENB|CS7;
} else {
/* Other combinations, including `AP' and `EP && OP' */
iflag |= IGNPAR|ISTRIP;
cflag |= CS7;
}
BIS(iflag, ISTRIP|INPCK|IGNPAR);
BICS(cflag, CSIZE|PARODD, PARENB|CS7);
} else if (AP || EP && OP) {
BICS(iflag, INPCK|IGNPAR, ISTRIP);
BICS(cflag, CSIZE|PARODD, PARENB|CS7);
} /* else, leave as is */
#if 0
if (UC)
@ -250,6 +260,8 @@ setflags(n)
if (HC)
cflag |= HUPCL;
else
cflag &= ~HUPCL;
if (NL) {
iflag |= ICRNL;
@ -272,7 +284,9 @@ setflags(n)
goto out;
}
if (!HT)
if (HT)
oflag &= ~OXTABS;
else
oflag |= OXTABS;
if (n == 0)
@ -303,6 +317,8 @@ setflags(n)
if (MB)
cflag |= MDMBUF;
else
cflag &= ~MDMBUF;
out:
tmode.c_iflag = iflag;
@ -457,44 +473,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);
@ -504,6 +521,7 @@ delaybits()
return (f);
}
int
adelay(ms, dp)
register ms;
register struct delayval *dp;
@ -518,6 +536,7 @@ adelay(ms, dp)
char editedhost[32];
void
edithost(pat)
register char *pat;
{
@ -561,30 +580,32 @@ 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;
@ -598,13 +619,13 @@ 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) {
@ -613,7 +634,7 @@ makeenv(env)
}
if (p = EV) {
q = p;
while (q = index(q, ',')) {
while (q = strchr(q, ',')) {
*q++ = '\0';
*ep++ = p;
p = q;

View File

@ -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,10 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ttys.5 6.8 (Berkeley) 5/4/91
.\" $Id: ttys.5,v 1.5 1994/03/21 00:57:43 cgd Exp $
.\" from: @(#)ttys.5 8.1 (Berkeley) 6/4/93
.\" $Id: ttys.5,v 1.6 1994/08/17 20:10:41 pk Exp $
.\"
.Dd May 4, 1991
.Dd June 4, 1993
.Dt TTYS 5
.Os
.Sh NAME