* Copyright (c) 1980 The Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)main.c 5.15 (Berkeley) %G%";
int crmod
, digit
, lower
, upper
;
char hostname
[MAXHOSTNAMELEN
];
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 ((i
= open(ttyn
, O_RDWR
)) == -1) {
syslog(LOG_ERR
, "%s: %m", ttyn
);
gettable("default", defent
, defstrs
);
gettable(tname
, tabent
, tabstrs
);
if (OPset
|| EPset
|| APset
)
APset
++, OPset
++, EPset
++;
ioctl(0, TIOCFLUSH
, 0); /* clear out the crap */
ioctl(0, FIONBIO
, &off
); /* turn off non-blocking mode */
ioctl(0, FIOASYNC
, &off
); /* ditto for async mode */
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
);
tmode
.sg_ispeed
= tmode
.sg_ospeed
= 0;
ioctl(0, TIOCSETP
, &tmode
);
signal(SIGALRM
, dingdong
);
signal(SIGALRM
, SIG_DFL
);
puts("user names may not start with '-'.");
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
++)
* this is what login was doing anyway.
* soon we rewrite getty completely.
execle(LO
, "login", "-p", name
, (char *) 0, env
);
syslog(LOG_ERR
, "%s: %m", LO
);
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
);
crmod
= digit
= lower
= upper
= 0;
if (read(STDIN_FILENO
, &cs
, 1) <= 0)
if (c
== '\r' || c
== '\n' || np
>= &name
[sizeof name
]) {
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 ... */
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, and then do the delay.
* Too bad there are no user program accessible programmed delays.
* Transmitting pad characters slows many terminals down and also
mspc10
= tmspc10
[tmode
.sg_ospeed
];
for (pad
/= mspc10
; pad
> 0; pad
--)
c
|= partab
[c
&0177] & 0200;
write(STDOUT_FILENO
, &c
, 1);
write(STDOUT_FILENO
, outbuf
, obufcnt
);
extern char editedhost
[];
slash
= rindex(ttyn
, '/');
static char fmt
[] = "%l:% %P on %A, %d %B %Y";
fmt
[4] = 'M'; /* I *hate* SCCS... */
(void)strftime(db
, sizeof(db
), fmt
, localtime(&t
));