* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)main.c 5.5 (Berkeley) 1/23/86";
* getty -- adapt to terminal speed on dialup, and call login
* Melbourne getty, June 83, kre.
char ctty
[] = "/dev/console";
0001,0201,0201,0001,0201,0001,0001,0201,
0202,0004,0003,0205,0005,0206,0201,0001,
0201,0001,0001,0201,0001,0201,0201,0001,
0001,0201,0201,0001,0201,0001,0001,0201,
0200,0000,0000,0200,0000,0200,0200,0000,
0000,0200,0200,0000,0200,0000,0000,0200,
0000,0200,0200,0000,0200,0000,0000,0200,
0200,0000,0000,0200,0000,0200,0200,0000,
0200,0000,0000,0200,0000,0200,0200,0000,
0000,0200,0200,0000,0200,0000,0000,0200,
0000,0200,0200,0000,0200,0000,0000,0200,
0200,0000,0000,0200,0000,0200,0200,0000,
0000,0200,0200,0000,0200,0000,0000,0200,
0200,0000,0000,0200,0000,0200,0200,0000,
0200,0000,0000,0200,0000,0200,0200,0000,
0000,0200,0200,0000,0200,0000,0000,0201
#define ERASE tmode.sg_erase
#define KILL tmode.sg_kill
signal(SIGALRM
, SIG_DFL
);
signal(SIGINT
, interrupt
);
signal(SIGQUIT, SIG_DFL);
openlog("getty", LOG_ODELAY
|LOG_CONS
, LOG_AUTH
);
gethostname(hostname
, sizeof(hostname
));
strcpy(hostname
, "Amnesiac");
* The following is a work around for vhangup interactions
* which cause great problems getting window systems started.
* If the tty line is "-", we do the old style getty presuming
* that the file descriptors are already set up for us.
* J. Gettys - MIT Project Athena.
if (argc
<= 2 || strcmp(argv
[2], "-") == 0)
strcpy(ttyn
, ttyname(0));
strncat(ttyn
, argv
[2], sizeof(ttyn
)-sizeof(dev
));
if (strcmp(argv
[0], "+") != 0) {
* Delay the open so DTR stays down long enough to be detected.
while (open(ttyn
, O_RDWR
) != 0) {
syslog(LOG_ERR
, "%s: %m", ttyn
);
(void) open(ttyn
, O_RDWR
);
gettable("default", defent
, defstrs
);
gettable(tname
, tabent
, tabstrs
);
if (OPset
|| EPset
|| APset
)
APset
++, OPset
++, EPset
++;
ioctl(0, TIOCFLUSH
, 0); /* clear out the crap */
tmode
.sg_ispeed
= speed(IS
);
tmode
.sg_ispeed
= speed(SP
);
tmode
.sg_ospeed
= speed(OS
);
tmode
.sg_ospeed
= speed(SP
);
tmode
.sg_flags
= setflags(0);
ioctl(0, TIOCSETP
, &tmode
);
ioctl(0, TIOCSETD
, &ldisp
);
tmode
.sg_ispeed
= tmode
.sg_ospeed
= 0;
ioctl(0, TIOCSETP
, &tmode
);
signal(SIGALRM
, dingdong
);
signal(SIGALRM
, SIG_DFL
);
if (!(upper
|| lower
|| digit
))
tmode
.sg_flags
= allflags
& 0xffff;
tmode
.sg_flags
&= ~LCASE
;
ioctl(0, TIOCSETP
, &tmode
);
ioctl(0, TIOCSLTC
, <c
);
ioctl(0, TIOCLSET
, &allflags
);
for (i
= 0; environ
[i
] != (char *)0; i
++)
execle(LO
, "login", "-p", name
, (char *) 0, env
);
signal(SIGALRM
, SIG_DFL
);
* Interrupt may happen if we use CBREAK mode
signal(SIGINT
, interrupt
);
tmode
.sg_flags
= setflags(0);
ioctl(0, TIOCSETP
, &tmode
);
tmode
.sg_flags
= setflags(1);
ioctl(0, TIOCSETP
, &tmode
);
if (read(0, &cs
, 1) <= 0)
if (c
== '\r' || c
== '\n' || np
>= &name
[sizeof name
]) {
if (c
>= 'a' && c
<= 'z')
else if (c
>= 'A' && c
<= 'Z')
else if (c
== ERASE
|| c
== '#' || c
== '\b') {
if (tmode
.sg_ospeed
>= B1200
)
} else if (c
== KILL
|| c
== '@') {
if (tmode
.sg_ospeed
< B1200
)
/* this is the way they do it down under ... */
} else if (c
>= '0' && c
<= '9')
if (IG
&& (c
<= ' ' || c
> 0176))
if (upper
&& !lower
&& !LC
|| UC
)
for (np
= name
; *np
; np
++)
0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5, 15
if (*s
== '.' && isdigit(s
[1])) {
* If no delay needed, or output speed is
* not comprehensible, then don't try to delay.
if (tmode
.sg_ospeed
<= 0 ||
tmode
.sg_ospeed
>= (sizeof tmspc10
/ sizeof tmspc10
[0]))
* Round up by a half a character frame,
* Too bad there are no user program accessible programmed delays.
* Transmitting pad characters slows many
* terminals down and also loads the system.
mspc10
= tmspc10
[tmode
.sg_ospeed
];
for (pad
/= mspc10
; pad
> 0; pad
--)
c
|= partab
[c
&0177] & 0200;
write(1, outbuf
, obufcnt
);
extern char editedhost
[];
extern char *ttyname(), *rindex();
slash
= rindex(ttyn
, '/');