xref: /csrg-svn/usr.bin/login/login.c.1 (revision 14897)
112678Ssam#ifndef lint
2*14897Sedwardstatic	char *sccsid = "@(#)login.c.1	4.33 (Berkeley) 83/09/02";
312678Ssam#endif
412678Ssam
51043Sbill/*
61043Sbill * login [ name ]
712687Ssam * login -r hostname (for rlogind)
812687Ssam * login -h hostname (for telnetd, etc.)
91043Sbill */
101043Sbill
1112984Ssam#include <sys/param.h>
1212687Ssam#include <sys/quota.h>
1312687Ssam#include <sys/stat.h>
1412687Ssam#include <sys/time.h>
1512687Ssam#include <sys/resource.h>
1612687Ssam
171043Sbill#include <sgtty.h>
181043Sbill#include <utmp.h>
191043Sbill#include <signal.h>
201043Sbill#include <pwd.h>
211043Sbill#include <stdio.h>
221043Sbill#include <lastlog.h>
2312678Ssam#include <errno.h>
241043Sbill
252822Swnj#define	SCPYN(a, b)	strncpy(a, b, sizeof(a))
262822Swnj
276197Sroot#define NMAX	sizeof(utmp.ut_name)
281043Sbill
292822Swnj#define	FALSE	0
302822Swnj#define	TRUE	-1
312822Swnj
322822Swnjchar	nolog[] =	"/etc/nologin";
332822Swnjchar	qlog[]  =	".hushlogin";
342822Swnjchar	securetty[] =	"/etc/securetty";
351043Sbillchar	maildir[30] =	"/usr/spool/mail/";
361043Sbillchar	lastlog[] =	"/usr/adm/lastlog";
379867Ssamstruct	passwd nouser = {"", "nope", -1, -1, -1, "", "", "", "" };
381043Sbillstruct	sgttyb ttyb;
391043Sbillstruct	utmp utmp;
401043Sbillchar	minusnam[16] = "-";
4112687Ssam/*
4212687Ssam * This bounds the time given to login.  We initialize it here
4312687Ssam * so it can be patched on machines where it's too small.
4412687Ssam */
4512687Ssamint	timeout = 60;
466005Swnj
471043Sbillchar	homedir[64] = "HOME=";
481043Sbillchar	shell[64] = "SHELL=";
491043Sbillchar	term[64] = "TERM=";
502822Swnjchar	user[20] = "USER=";
516005Swnj
526005Swnjchar	*envinit[] =
5312687Ssam    { homedir, shell, "PATH=:/usr/ucb:/bin:/usr/bin", term, user, 0 };
546005Swnj
551043Sbillstruct	passwd *pwd;
561043Sbillstruct	passwd *getpwnam();
576005Swnjchar	*strcat(), *rindex(), *index();
581043Sbillint	setpwent();
5912687Ssamint	timedout();
601043Sbillchar	*ttyname();
611043Sbillchar	*crypt();
621043Sbillchar	*getpass();
631043Sbillchar	*stypeof();
641043Sbillextern	char **environ;
6512678Ssamextern	int errno;
661043Sbill
6713074Ssamstruct	tchars tc = {
6813074Ssam	CINTR, CQUIT, CSTART, CSTOP, CEOT, CBRK
691365Sbill};
7013074Ssamstruct	ltchars ltc = {
7113074Ssam	CSUSP, CDSUSP, CRPRNT, CFLUSH, CWERASE, CLNEXT
7213074Ssam};
731365Sbill
746005Swnjint	rflag;
756197Srootchar	rusername[NMAX+1], lusername[NMAX+1];
766005Swnjchar	rpassword[NMAX+1];
776878Smckusickchar	name[NMAX+1];
786197Srootchar	*rhost;
796005Swnj
801043Sbillmain(argc, argv)
8112687Ssam	char *argv[];
821043Sbill{
831043Sbill	register char *namep;
8412687Ssam	int t, f, c, i;
8512687Ssam	int invalid, quietlog;
862822Swnj	FILE *nlfd;
871043Sbill	char *ttyn;
886197Sroot	int ldisc = 0, zero = 0;
891043Sbill
9012687Ssam	signal(SIGALRM, timedout);
9112687Ssam	alarm(timeout);
921043Sbill	signal(SIGQUIT, SIG_IGN);
931043Sbill	signal(SIGINT, SIG_IGN);
9412687Ssam	setpriority(PRIO_PROCESS, 0, 0);
9512678Ssam	quota(Q_SETUID, 0, 0, 0);
9612687Ssam	/*
9712687Ssam	 * -r is used by rlogind to cause the autologin protocol;
9812687Ssam	 * -h is used by other servers to pass the name of the
9912687Ssam	 * remote host to login so that it may be placed in utmp and wtmp
10012687Ssam	 */
10112687Ssam	if (argc > 1) {
10212687Ssam		if (strcmp(argv[1], "-r") == 0) {
10312687Ssam			rflag = doremotelogin(argv[2]);
10412687Ssam			SCPYN(utmp.ut_host, argv[2]);
10512687Ssam			argc = 0;
1066197Sroot		}
10712687Ssam		if (strcmp(argv[1], "-h") == 0 && getuid() == 0) {
10812687Ssam			SCPYN(utmp.ut_host, argv[2]);
10912687Ssam			argc = 0;
1106197Sroot		}
1116005Swnj	}
11213074Ssam	ioctl(0, TIOCLSET, &zero);
1131547Sbill	ioctl(0, TIOCNXCL, 0);
1146329Swnj	ioctl(0, FIONBIO, &zero);
1156329Swnj	ioctl(0, FIOASYNC, &zero);
11613074Ssam	ioctl(0, TIOCGETP, &ttyb);
11712687Ssam	/*
11812687Ssam	 * If talking to an rlogin process,
11912687Ssam	 * propagate the terminal type and
12012687Ssam	 * baud rate across the network.
12112687Ssam	 */
12212687Ssam	if (rflag)
12312687Ssam		doremoteterm(term, &ttyb);
12413074Ssam	ioctl(0, TIOCSLTC, &ltc);
12513074Ssam	ioctl(0, TIOCSETC, &tc);
12613074Ssam	ioctl(0, TIOCSETP, &ttyb);
12712687Ssam	for (t = getdtablesize(); t > 3; t--)
1281043Sbill		close(t);
1291043Sbill	ttyn = ttyname(0);
1302822Swnj	if (ttyn==(char *)0)
1311043Sbill		ttyn = "/dev/tty??";
1322822Swnj	do {
1332822Swnj		ldisc = 0;
1342822Swnj		ioctl(0, TIOCSETD, &ldisc);
1352822Swnj		invalid = FALSE;
1362822Swnj		SCPYN(utmp.ut_name, "");
13712687Ssam		/*
13812687Ssam		 * Name specified, take it.
13912687Ssam		 */
14012687Ssam		if (argc > 1) {
1412822Swnj			SCPYN(utmp.ut_name, argv[1]);
1422822Swnj			argc = 0;
1431043Sbill		}
14412687Ssam		/*
14512687Ssam		 * If remote login take given name,
14612687Ssam		 * otherwise prompt user for something.
14712687Ssam		 */
1486329Swnj		if (rflag) {
1499867Ssam			SCPYN(utmp.ut_name, lusername);
15012687Ssam			/* autologin failed, prompt for passwd */
1516329Swnj			if (rflag == -1)
1526329Swnj				rflag = 0;
15313470Ssam		} else
15412687Ssam			getloginname(&utmp);
1552822Swnj		if (!strcmp(pwd->pw_shell, "/bin/csh")) {
1562822Swnj			ldisc = NTTYDISC;
1572822Swnj			ioctl(0, TIOCSETD, &ldisc);
1582822Swnj		}
15912687Ssam		/*
16012687Ssam		 * If no remote login authentication and
16112687Ssam		 * a password exists for this user, prompt
16212687Ssam		 * for one and verify it.
16312687Ssam		 */
16412687Ssam		if (!rflag && *pwd->pw_passwd != '\0') {
16512687Ssam			char *pp;
16612687Ssam
16712687Ssam			setpriority(PRIO_PROCESS, 0, -4);
16812687Ssam			pp = getpass("Password:");
16912687Ssam			namep = crypt(pp, pwd->pw_passwd);
17012687Ssam			setpriority(PRIO_PROCESS, 0, 0);
17112687Ssam			if (strcmp(namep, pwd->pw_passwd))
17212687Ssam				invalid = TRUE;
1732822Swnj		}
17412687Ssam		/*
17512687Ssam		 * If user not super-user, check for logins disabled.
17612687Ssam		 */
1772822Swnj		if (pwd->pw_uid != 0 && (nlfd = fopen(nolog, "r")) > 0) {
1782822Swnj			while ((c = getc(nlfd)) != EOF)
1792822Swnj				putchar(c);
1802822Swnj			fflush(stdout);
1812822Swnj			sleep(5);
1822822Swnj			exit(0);
1832822Swnj		}
18412687Ssam		/*
18512687Ssam		 * If valid so far and root is logging in,
18612687Ssam		 * see if root logins on this terminal are permitted.
18712687Ssam		 */
1882822Swnj		if (!invalid && pwd->pw_uid == 0 &&
1892822Swnj		    !rootterm(ttyn+sizeof("/dev/")-1)) {
1906329Swnj			logerr("ROOT LOGIN REFUSED %s",
1916329Swnj			    ttyn+sizeof("/dev/")-1);
1922822Swnj			invalid = TRUE;
1932822Swnj		}
1942822Swnj		if (invalid) {
1951043Sbill			printf("Login incorrect\n");
1966329Swnj			if (ttyn[sizeof("/dev/tty")-1] == 'd')
19713486Ssam				logerr("BADDIALUP %s %s",
1986329Swnj				    ttyn+sizeof("/dev/")-1, utmp.ut_name);
1991043Sbill		}
2002822Swnj		if (*pwd->pw_shell == '\0')
2012822Swnj			pwd->pw_shell = "/bin/sh";
2022822Swnj		i = strlen(pwd->pw_shell);
2032822Swnj		if (chdir(pwd->pw_dir) < 0 && !invalid ) {
2042822Swnj			if (chdir("/") < 0) {
2052822Swnj				printf("No directory!\n");
2062822Swnj				invalid = TRUE;
2072822Swnj			} else {
20812687Ssam				printf("No directory! %s\n",
20912687Ssam				   "Logging in with home=/");
2102822Swnj				pwd->pw_dir = "/";
2112822Swnj			}
2121043Sbill		}
21312687Ssam		/*
21412687Ssam		 * Remote login invalid must have been because
21512687Ssam		 * of a restriction of some sort, no extra chances.
21612687Ssam		 */
2176005Swnj		if (rflag && invalid)
2186005Swnj			exit(1);
2192822Swnj	} while (invalid);
22012687Ssam/* committed to login turn off timeout */
22112687Ssam	alarm(0);
2221043Sbill
22312678Ssam	if (quota(Q_SETUID, pwd->pw_uid, 0, 0) < 0) {
22412678Ssam		if (errno == EUSERS)
22512678Ssam			printf("%s.\n%s.\n",
22612678Ssam			   "Too many users logged on already",
22712678Ssam			   "Try again later");
22812678Ssam		else if (errno == EPROCLIM)
22912678Ssam			printf("You have too many processes running.\n");
23012678Ssam		else
23112678Ssam			perror("setuid");
23212678Ssam		sleep(5);
23312678Ssam		exit(0);
23412678Ssam	}
2351043Sbill	time(&utmp.ut_time);
2361043Sbill	t = ttyslot();
23712687Ssam	if (t > 0 && (f = open("/etc/utmp", 1)) >= 0) {
2381043Sbill		lseek(f, (long)(t*sizeof(utmp)), 0);
2391043Sbill		SCPYN(utmp.ut_line, rindex(ttyn, '/')+1);
2401043Sbill		write(f, (char *)&utmp, sizeof(utmp));
2411043Sbill		close(f);
2421043Sbill	}
24312687Ssam	if (t > 0 && (f = open("/usr/adm/wtmp", 1)) >= 0) {
2441043Sbill		lseek(f, 0L, 2);
2451043Sbill		write(f, (char *)&utmp, sizeof(utmp));
2461043Sbill		close(f);
2471043Sbill	}
24812687Ssam	quietlog = access(qlog, 0) == 0;
2496329Swnj	if ((f = open(lastlog, 2)) >= 0) {
2502822Swnj		struct lastlog ll;
2512822Swnj
2522822Swnj		lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
2532822Swnj		if (read(f, (char *) &ll, sizeof ll) == sizeof ll &&
25412687Ssam		    ll.ll_time != 0 && !quietlog) {
25512687Ssam			printf("Last login: %.*s ",
25612687Ssam			    24-5, (char *)ctime(&ll.ll_time));
25712687Ssam			if (*ll.ll_host != '\0')
25812687Ssam				printf("from %.*s\n",
25912687Ssam				    sizeof (ll.ll_host), ll.ll_host);
26012687Ssam			else
26112687Ssam				printf("on %.*s\n",
26212687Ssam				    sizeof (ll.ll_line), ll.ll_line);
2632822Swnj		}
2642822Swnj		lseek(f, (long)pwd->pw_uid * sizeof (struct lastlog), 0);
2652822Swnj		time(&ll.ll_time);
2662822Swnj		SCPYN(ll.ll_line, rindex(ttyn, '/')+1);
26712687Ssam		SCPYN(ll.ll_host, utmp.ut_host);
2682822Swnj		write(f, (char *) &ll, sizeof ll);
2692822Swnj		close(f);
2702822Swnj	}
2711043Sbill	chown(ttyn, pwd->pw_uid, pwd->pw_gid);
2729867Ssam	chmod(ttyn, 0622);
2731043Sbill	setgid(pwd->pw_gid);
2746878Smckusick	strncpy(name, utmp.ut_name, NMAX);
2756878Smckusick	name[NMAX] = '\0';
2769224Ssam	initgroups(name, pwd->pw_gid);
27712678Ssam	quota(Q_DOWARN, pwd->pw_uid, (dev_t)-1, 0);
2781043Sbill	setuid(pwd->pw_uid);
2791043Sbill	environ = envinit;
2801043Sbill	strncat(homedir, pwd->pw_dir, sizeof(homedir)-6);
2811043Sbill	strncat(shell, pwd->pw_shell, sizeof(shell)-7);
2826329Swnj	if (term[strlen("TERM=")] == 0)
2836005Swnj		strncat(term, stypeof(ttyn), sizeof(term)-6);
2842822Swnj	strncat(user, pwd->pw_name, sizeof(user)-6);
2851043Sbill	if ((namep = rindex(pwd->pw_shell, '/')) == NULL)
2861043Sbill		namep = pwd->pw_shell;
2871043Sbill	else
2881043Sbill		namep++;
2891043Sbill	strcat(minusnam, namep);
2906197Sroot	umask(022);
2916329Swnj	if (ttyn[sizeof("/dev/tty")-1] == 'd')
29213486Ssam		logerr("DIALUP %s %s",
29313486Ssam		    ttyn+sizeof("/dev/")-1, pwd->pw_name);
2946329Swnj	if (!quietlog) {
2952822Swnj		showmotd();
2962822Swnj		strcat(maildir, pwd->pw_name);
2972822Swnj		if (access(maildir,4)==0) {
2982822Swnj			struct stat statb;
2992822Swnj			stat(maildir, &statb);
3002822Swnj			if (statb.st_size)
3012822Swnj				printf("You have mail.\n");
3022822Swnj		}
3032822Swnj	}
30412687Ssam	signal(SIGALRM, SIG_DFL);
3051043Sbill	signal(SIGQUIT, SIG_DFL);
3061043Sbill	signal(SIGINT, SIG_DFL);
3073935Sroot	signal(SIGTSTP, SIG_IGN);
3081043Sbill	execlp(pwd->pw_shell, minusnam, 0);
3092822Swnj	perror(pwd->pw_shell);
3101043Sbill	printf("No shell\n");
3111043Sbill	exit(0);
3121043Sbill}
3131043Sbill
31412687Ssamgetloginname(up)
31512687Ssam	register struct utmp *up;
31612687Ssam{
31712687Ssam	register char *namep;
31812712Ssam	char c;
31912687Ssam
32012687Ssam	while (up->ut_name[0] == '\0') {
321*14897Sedward		namep = up->ut_name;
32212712Ssam		printf("login: ");
32312687Ssam		while ((c = getchar()) != '\n') {
32412687Ssam			if (c == ' ')
32512687Ssam				c = '_';
32612687Ssam			if (c == EOF)
32712687Ssam				exit(0);
32812687Ssam			if (namep < up->ut_name+NMAX)
32912687Ssam				*namep++ = c;
33012687Ssam		}
33112687Ssam	}
332*14897Sedward	strncpy(lusername, up->ut_name, NMAX);
333*14897Sedward	lusername[NMAX] = 0;
33412687Ssam	setpwent();
335*14897Sedward	if ((pwd = getpwnam(lusername)) == NULL)
33612687Ssam		pwd = &nouser;
33712687Ssam	endpwent();
33812687Ssam}
33912687Ssam
34012687Ssamtimedout()
34112687Ssam{
34212687Ssam
34312687Ssam	printf("Login timed out after %d seconds\n", timeout);
34412687Ssam	exit(0);
34512687Ssam}
34612687Ssam
3471043Sbillint	stopmotd;
3481043Sbillcatch()
3491043Sbill{
3506466Swnj
3511043Sbill	signal(SIGINT, SIG_IGN);
3521043Sbill	stopmotd++;
3531043Sbill}
3541043Sbill
3552822Swnjrootterm(tty)
3566466Swnj	char *tty;
3572822Swnj{
3582822Swnj	register FILE *fd;
3596466Swnj	char buf[100];
3602822Swnj
3612822Swnj	if ((fd = fopen(securetty, "r")) == NULL)
3622822Swnj		return(1);
3632822Swnj	while (fgets(buf, sizeof buf, fd) != NULL) {
3642822Swnj		buf[strlen(buf)-1] = '\0';
3652822Swnj		if (strcmp(tty, buf) == 0) {
3662822Swnj			fclose(fd);
3672822Swnj			return(1);
3682822Swnj		}
3692822Swnj	}
3702822Swnj	fclose(fd);
3712822Swnj	return(0);
3722822Swnj}
3732822Swnj
3741043Sbillshowmotd()
3751043Sbill{
3761043Sbill	FILE *mf;
3771043Sbill	register c;
3781043Sbill
3791043Sbill	signal(SIGINT, catch);
3802822Swnj	if ((mf = fopen("/etc/motd","r")) != NULL) {
3812822Swnj		while ((c = getc(mf)) != EOF && stopmotd == 0)
3821043Sbill			putchar(c);
3831043Sbill		fclose(mf);
3841043Sbill	}
3851043Sbill	signal(SIGINT, SIG_IGN);
3861043Sbill}
3871043Sbill
3882822Swnj#undef	UNKNOWN
3891043Sbill#define UNKNOWN "su"
3901043Sbill
3911043Sbillchar *
3921043Sbillstypeof(ttyid)
39312687Ssam	char *ttyid;
3941043Sbill{
39512687Ssam	static char typebuf[16];
39612687Ssam	char buf[50];
39712687Ssam	register FILE *f;
39812687Ssam	register char *p, *t, *q;
3991043Sbill
4001043Sbill	if (ttyid == NULL)
4011043Sbill		return (UNKNOWN);
4021043Sbill	f = fopen("/etc/ttytype", "r");
4031043Sbill	if (f == NULL)
4041043Sbill		return (UNKNOWN);
4051043Sbill	/* split off end of name */
4061043Sbill	for (p = q = ttyid; *p != 0; p++)
4071043Sbill		if (*p == '/')
4081043Sbill			q = p + 1;
4091043Sbill
4101043Sbill	/* scan the file */
41112687Ssam	while (fgets(buf, sizeof buf, f) != NULL) {
41212687Ssam		for (t = buf; *t != ' ' && *t != '\t'; t++)
4131043Sbill			;
4141043Sbill		*t++ = 0;
4152822Swnj		while (*t == ' ' || *t == '\t')
4162822Swnj			t++;
41712687Ssam		for (p = t; *p > ' '; p++)
4181043Sbill			;
4191043Sbill		*p = 0;
42012687Ssam		if (strcmp(q,t) == 0) {
4211043Sbill			strcpy(typebuf, buf);
4221043Sbill			fclose(f);
4231043Sbill			return (typebuf);
4241043Sbill		}
4251043Sbill	}
4261043Sbill	fclose (f);
4271043Sbill	return (UNKNOWN);
4281043Sbill}
4296005Swnj
43012687Ssamdoremotelogin(host)
43112687Ssam	char *host;
43212687Ssam{
43312687Ssam	FILE *hostf;
43412687Ssam	int first = 1;
43512687Ssam
43612687Ssam	getstr(rusername, sizeof (rusername), "remuser");
43712687Ssam	getstr(lusername, sizeof (lusername), "locuser");
43812687Ssam	getstr(term+5, sizeof(term)-5, "Terminal type");
43913470Ssam	if (getuid()) {
44013470Ssam		pwd = &nouser;
44112687Ssam		goto bad;
44213470Ssam	}
44312687Ssam	setpwent();
44412687Ssam	pwd = getpwnam(lusername);
44512687Ssam	endpwent();
44613470Ssam	if (pwd == NULL) {
44713470Ssam		pwd = &nouser;
44812687Ssam		goto bad;
44913470Ssam	}
45012687Ssam	hostf = pwd->pw_uid ? fopen("/etc/hosts.equiv", "r") : 0;
45112687Ssamagain:
45212687Ssam	if (hostf) {
45312687Ssam		char ahost[32];
45412687Ssam
45512687Ssam		while (fgets(ahost, sizeof (ahost), hostf)) {
45612687Ssam			char *user;
45712687Ssam
45812687Ssam			if ((user = index(ahost, '\n')) != 0)
45912687Ssam				*user++ = '\0';
46012687Ssam			if ((user = index(ahost, ' ')) != 0)
46112687Ssam				*user++ = '\0';
46212687Ssam			if (!strcmp(host, ahost) &&
46312687Ssam			    !strcmp(rusername, user ? user : lusername)) {
46412687Ssam				fclose(hostf);
46512687Ssam				return (1);
46612687Ssam			}
46712687Ssam		}
46812687Ssam		fclose(hostf);
46912687Ssam	}
47012687Ssam	if (first == 1) {
47112687Ssam		char *rhosts = ".rhosts";
47212687Ssam		struct stat sbuf;
47312687Ssam
47412687Ssam		first = 0;
47512687Ssam		if (chdir(pwd->pw_dir) < 0)
47612687Ssam			goto again;
47712687Ssam		if (lstat(rhosts, &sbuf) < 0)
47812687Ssam			goto again;
47912687Ssam		if ((sbuf.st_mode & S_IFMT) == S_IFLNK) {
48012687Ssam			printf("login: .rhosts is a soft link.\r\n");
48112687Ssam			goto bad;
48212687Ssam		}
48312687Ssam		hostf = fopen(rhosts, "r");
48412687Ssam		fstat(fileno(hostf), &sbuf);
48512687Ssam		if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) {
48612687Ssam			printf("login: Bad .rhosts ownership.\r\n");
48712687Ssam			fclose(hostf);
48812687Ssam			goto bad;
48912687Ssam		}
49012687Ssam		goto again;
49112687Ssam	}
49212687Ssambad:
49312687Ssam	return (-1);
49412687Ssam}
49512687Ssam
4966005Swnjgetstr(buf, cnt, err)
4976005Swnj	char *buf;
4986005Swnj	int cnt;
4996005Swnj	char *err;
5006005Swnj{
5016005Swnj	char c;
5026005Swnj
5036005Swnj	do {
5046005Swnj		if (read(0, &c, 1) != 1)
5056005Swnj			exit(1);
5066005Swnj		if (--cnt < 0) {
5076005Swnj			printf("%s too long\r\n", err);
5086005Swnj			exit(1);
5096005Swnj		}
5106005Swnj		*buf++ = c;
5116005Swnj	} while (c != 0);
5126005Swnj}
5136329Swnj
51412687Ssamchar	*speeds[] =
51512687Ssam    { "0", "50", "75", "110", "134", "150", "200", "300",
51612687Ssam      "600", "1200", "1800", "2400", "4800", "9600", "19200", "38400" };
51712687Ssam#define	NSPEEDS	(sizeof (speeds) / sizeof (speeds[0]))
51812687Ssam
51912687Ssamdoremoteterm(term, tp)
52012687Ssam	char *term;
52112687Ssam	struct sgttyb *tp;
52212687Ssam{
52312687Ssam	char *cp = index(term, '/');
52412687Ssam	register int i;
52512687Ssam
52612687Ssam	if (cp) {
52712687Ssam		*cp++ = 0;
52812687Ssam		for (i = 0; i < NSPEEDS; i++)
52912687Ssam			if (!strcmp(speeds[i], cp)) {
53012687Ssam				tp->sg_ispeed = tp->sg_ospeed = i;
53112687Ssam				break;
53212687Ssam			}
53312687Ssam	}
53412687Ssam	tp->sg_flags = ECHO|CRMOD|ANYP|XTABS;
53512687Ssam}
53612687Ssam
5376329Swnjlogerr(fmt, a1, a2, a3)
5386329Swnj	char *fmt, *a1, *a2, *a3;
5396329Swnj{
54012690Ssam#ifdef LOGERR
54112690Ssam	FILE *cons = fopen("/dev/console", "w");
5426329Swnj
54312690Ssam	if (cons != NULL) {
54412690Ssam		fprintf(cons, fmt, a1, a2, a3);
54513486Ssam		fprintf(cons, "\n\r");
54612690Ssam		fclose(cons);
54712690Ssam	}
54812690Ssam#endif
5496329Swnj}
550