login.c revision 1.22 1 /* $NetBSD: login.c,v 1.22 1997/06/29 02:38:25 lukem Exp $ */
2
3 /*-
4 * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #ifndef lint
37 static char copyright[] =
38 "@(#) Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994\n\
39 The Regents of the University of California. All rights reserved.\n";
40 #endif /* not lint */
41
42 #ifndef lint
43 #if 0
44 static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
45 #endif
46 static char rcsid[] = "$NetBSD: login.c,v 1.22 1997/06/29 02:38:25 lukem Exp $";
47 #endif /* not lint */
48
49 /*
50 * login [ name ]
51 * login -h hostname (for telnetd, etc.)
52 * login -f name (for pre-authenticated login: datakit, xterm, etc.)
53 */
54
55 #include <sys/param.h>
56 #include <sys/stat.h>
57 #include <sys/time.h>
58 #include <sys/resource.h>
59 #include <sys/file.h>
60
61 #include <err.h>
62 #include <errno.h>
63 #include <grp.h>
64 #include <pwd.h>
65 #include <setjmp.h>
66 #include <signal.h>
67 #include <stdio.h>
68 #include <skey.h>
69 #include <stdlib.h>
70 #include <string.h>
71 #include <syslog.h>
72 #include <ttyent.h>
73 #include <tzfile.h>
74 #include <unistd.h>
75 #include <utmp.h>
76 #include <util.h>
77
78 #include "pathnames.h"
79
80 void badlogin __P((char *));
81 void checknologin __P((void));
82 void dolastlog __P((int));
83 void getloginname __P((void));
84 void motd __P((void));
85 int rootterm __P((char *));
86 void sigint __P((int));
87 void sleepexit __P((int));
88 char *stypeof __P((char *));
89 void timedout __P((int));
90 int pwcheck __P((char *, char *, char *, char *));
91 #if defined(KERBEROS) || defined(KERBEROS5)
92 int klogin __P((struct passwd *, char *, char *, char *));
93 void kdestroy __P((void));
94 void dofork __P((void));
95 #endif
96
97 extern void login __P((struct utmp *));
98
99 #define TTYGRPNAME "tty" /* name of group to own ttys */
100
101 /*
102 * This bounds the time given to login. Not a define so it can
103 * be patched on machines where it's too small.
104 */
105 u_int timeout = 300;
106
107 #if defined(KERBEROS) || defined(KERBEROS5)
108 int notickets = 1;
109 char *instance;
110 char *krbtkfile_env;
111 int authok;
112 #endif
113
114 struct passwd *pwd;
115 int failures;
116 char term[64], *envinit[1], *hostname, *username, *tty;
117 #ifdef SKEY
118 int used_skey = 0;
119 int require_skey = 0;
120 char skeypw[] = "s/key";
121 #endif
122
123 int
124 main(argc, argv)
125 int argc;
126 char *argv[];
127 {
128 extern char **environ;
129 struct group *gr;
130 struct stat st;
131 struct timeval tp;
132 struct utmp utmp;
133 int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval;
134 uid_t uid;
135 char *domain, *p, *salt, *ttyn, *pwprompt;
136 char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
137 char localhost[MAXHOSTNAMELEN];
138
139 tbuf[0] = '\0';
140 rval = 0;
141 pwprompt = NULL;
142
143 (void)signal(SIGALRM, timedout);
144 (void)alarm(timeout);
145 (void)signal(SIGQUIT, SIG_IGN);
146 (void)signal(SIGINT, SIG_IGN);
147 (void)setpriority(PRIO_PROCESS, 0, 0);
148
149 openlog("login", LOG_ODELAY, LOG_AUTH);
150
151 /*
152 * -p is used by getty to tell login not to destroy the environment
153 * -f is used to skip a second login authentication
154 * -h is used by other servers to pass the name of the remote
155 * host to login so that it may be placed in utmp and wtmp
156 * -s is used to force use of S/Key or equivalent.
157 */
158 domain = NULL;
159 if (gethostname(localhost, sizeof(localhost)) < 0)
160 syslog(LOG_ERR, "couldn't get local hostname: %m");
161 else
162 domain = strchr(localhost, '.');
163
164 fflag = hflag = pflag = 0;
165 uid = getuid();
166 while ((ch = getopt(argc, argv, "fh:ps")) != EOF)
167 switch (ch) {
168 case 'f':
169 fflag = 1;
170 break;
171 case 'h':
172 if (uid)
173 errx(1, "-h option: %s", strerror(EPERM));
174 hflag = 1;
175 if (domain && (p = strchr(optarg, '.')) &&
176 strcasecmp(p, domain) == 0)
177 *p = 0;
178 hostname = optarg;
179 break;
180 case 'p':
181 pflag = 1;
182 break;
183 case 's':
184 #ifdef SKEY
185 /*
186 * If -s given twice, use S/Key or no login
187 * otherwise just insist on S/Key if user has one.
188 */
189 require_skey++;
190 #endif
191 break;
192 case '?':
193 default:
194 if (!uid)
195 syslog(LOG_ERR, "invalid flag %c", ch);
196 (void)fprintf(stderr,
197 "usage: login [-fp] [-h hostname] [username]\n");
198 exit(1);
199 }
200 argc -= optind;
201 argv += optind;
202
203 if (*argv) {
204 username = *argv;
205 ask = 0;
206 } else
207 ask = 1;
208
209 for (cnt = getdtablesize(); cnt > 2; cnt--)
210 (void)close(cnt);
211
212 ttyn = ttyname(STDIN_FILENO);
213 if (ttyn == NULL || *ttyn == '\0') {
214 (void)snprintf(tname, sizeof(tname), "%s??", _PATH_TTY);
215 ttyn = tname;
216 }
217 if ((tty = strrchr(ttyn, '/')))
218 ++tty;
219 else
220 tty = ttyn;
221
222 for (cnt = 0;; ask = 1) {
223 #ifdef SKEY
224 used_skey = 0;
225 #endif
226 #if defined(KERBEROS) || defined(KERBEROS5)
227 kdestroy();
228 #endif
229 if (ask) {
230 fflag = 0;
231 getloginname();
232 }
233 rootlogin = 0;
234 #ifdef KERBEROS
235 if ((instance = strchr(username, '.')) != NULL) {
236 if (strncmp(instance, ".root", 5) == 0)
237 rootlogin = 1;
238 *instance++ = '\0';
239 } else
240 instance = "";
241 #endif
242 #ifdef KERBEROS5
243 if ((instance = strchr(username, '/')) != NULL) {
244 if (strncmp(instance, "/root", 5) == 0)
245 rootlogin = 1;
246 *instance++ = '\0';
247 } else
248 instance = "";
249 #endif
250 if (strlen(username) > MAXLOGNAME)
251 username[MAXLOGNAME] = '\0';
252
253 /*
254 * Note if trying multiple user names; log failures for
255 * previous user name, but don't bother logging one failure
256 * for nonexistent name (mistyped username).
257 */
258 if (failures && strcmp(tbuf, username)) {
259 if (failures > (pwd ? 0 : 1))
260 badlogin(tbuf);
261 failures = 0;
262 }
263 (void)strncpy(tbuf, username, sizeof(tbuf) - 1);
264
265 if ((pwd = getpwnam(username)))
266 salt = pwd->pw_passwd;
267 else
268 salt = "xx";
269
270 /*
271 * if we have a valid account name, and it doesn't have a
272 * password, or the -f option was specified and the caller
273 * is root or the caller isn't changing their uid, don't
274 * authenticate.
275 */
276 if (pwd) {
277 if (pwd->pw_uid == 0)
278 rootlogin = 1;
279
280 if (fflag && (uid == 0 || uid == pwd->pw_uid)) {
281 /* already authenticated */
282 break;
283 } else if (pwd->pw_passwd[0] == '\0') {
284 /* pretend password okay */
285 rval = 0;
286 goto ttycheck;
287 }
288 }
289
290 fflag = 0;
291
292 (void)setpriority(PRIO_PROCESS, 0, -4);
293
294 #ifdef SKEY
295 p = NULL;
296 pwprompt = "Password:";
297
298 if (require_skey > 1) /* -s -s */
299 p = skeypw;
300 else if (skey_haskey(username) == 0) {
301 if (require_skey > 0) /* -s */
302 p = skeypw;
303 else {
304 extern char *skey_keyinfo();
305 static char skprompt[80];
306 char *skinfo = skey_keyinfo(username);
307
308 (void)snprintf(skprompt, sizeof(skprompt)-1,
309 "Password [%s]:", skinfo);
310 pwprompt = skprompt;
311 }
312 }
313 if (p == NULL)
314 #endif
315 p = getpass(pwprompt);
316
317 if (pwd) {
318 #if defined(KERBEROS) || defined(KERBEROS5)
319 rval = klogin(pwd, instance, localhost, p);
320 if (rval != 0 && rootlogin && pwd->pw_uid != 0)
321 rootlogin = 0;
322 if (rval == 0)
323 authok = 1;
324 else if (rval == 1) {
325 if (pwd->pw_uid != 0)
326 rootlogin = 0;
327 rval = pwcheck(username, p, salt, pwd->pw_passwd);
328 }
329 #else
330 rval = pwcheck(username, p, salt, pwd->pw_passwd);
331 #endif
332 }
333 #ifdef SKEY
334 if (used_skey == 0 && p != skeypw)
335 #endif
336 memset(p, 0, strlen(p));
337
338 (void)setpriority(PRIO_PROCESS, 0, 0);
339
340 ttycheck:
341 /*
342 * If trying to log in as root without Kerberos,
343 * but with insecure terminal, refuse the login attempt.
344 */
345 #if defined(KERBEROS) || defined(KERBEROS5)
346 if (authok == 0)
347 #endif
348 if (pwd && !rval && rootlogin && !rootterm(tty)) {
349 (void)fprintf(stderr,
350 "%s login refused on this terminal.\n",
351 pwd->pw_name);
352 if (hostname)
353 syslog(LOG_NOTICE,
354 "LOGIN %s REFUSED FROM %s ON TTY %s",
355 pwd->pw_name, hostname, tty);
356 else
357 syslog(LOG_NOTICE,
358 "LOGIN %s REFUSED ON TTY %s",
359 pwd->pw_name, tty);
360 continue;
361 }
362
363 if (pwd && !rval)
364 break;
365
366 (void)printf("Login incorrect\n");
367 failures++;
368 /* we allow 10 tries, but after 3 we start backing off */
369 if (++cnt > 3) {
370 if (cnt >= 10) {
371 badlogin(username);
372 sleepexit(1);
373 }
374 sleep((u_int)((cnt - 3) * 5));
375 }
376 }
377
378 /* committed to login -- turn off timeout */
379 (void)alarm((u_int)0);
380
381 endpwent();
382
383 /* if user not super-user, check for disabled logins */
384 if (!rootlogin)
385 checknologin();
386
387 if (chdir(pwd->pw_dir) < 0) {
388 (void)printf("No home directory %s!\n", pwd->pw_dir);
389 if (chdir("/"))
390 exit(0);
391 pwd->pw_dir = "/";
392 (void)printf("Logging in with home = \"/\".\n");
393 }
394
395 quietlog = access(_PATH_HUSHLOGIN, F_OK) == 0;
396
397 if (pwd->pw_change || pwd->pw_expire)
398 (void)gettimeofday(&tp, (struct timezone *)NULL);
399 if (pwd->pw_change)
400 if (tp.tv_sec >= pwd->pw_change) {
401 (void)printf("Sorry -- your password has expired.\n");
402 sleepexit(1);
403 } else if (pwd->pw_change - tp.tv_sec <
404 _PASSWORD_WARNDAYS * SECSPERDAY && !quietlog)
405 (void)printf("Warning: your password expires on %s",
406 ctime(&pwd->pw_change));
407 if (pwd->pw_expire)
408 if (tp.tv_sec >= pwd->pw_expire) {
409 (void)printf("Sorry -- your account has expired.\n");
410 sleepexit(1);
411 } else if (pwd->pw_expire - tp.tv_sec <
412 _PASSWORD_WARNDAYS * SECSPERDAY && !quietlog)
413 (void)printf("Warning: your account expires on %s",
414 ctime(&pwd->pw_expire));
415
416 /* Nothing else left to fail -- really log in. */
417 memset((void *)&utmp, 0, sizeof(utmp));
418 (void)time(&utmp.ut_time);
419 (void)strncpy(utmp.ut_name, username, sizeof(utmp.ut_name));
420 if (hostname)
421 (void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
422 (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
423 login(&utmp);
424
425 dolastlog(quietlog);
426
427 (void)chown(ttyn, pwd->pw_uid,
428 (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid);
429
430 if (ttyaction(ttyn, "login", pwd->pw_name))
431 (void)printf("Warning: ttyaction failed.\n");
432
433 #if defined(KERBEROS) || defined(KERBEROS5)
434 /* Fork so that we can call kdestroy */
435 if (krbtkfile_env)
436 dofork();
437 #endif
438 (void)setgid(pwd->pw_gid);
439
440 initgroups(username, pwd->pw_gid);
441
442 if (*pwd->pw_shell == '\0')
443 pwd->pw_shell = _PATH_BSHELL;
444
445 /* Destroy environment unless user has requested its preservation. */
446 if (!pflag)
447 environ = envinit;
448 (void)setenv("HOME", pwd->pw_dir, 1);
449 (void)setenv("SHELL", pwd->pw_shell, 1);
450 if (term[0] == '\0')
451 (void)strncpy(term, stypeof(tty), sizeof(term));
452 (void)setenv("TERM", term, 0);
453 (void)setenv("LOGNAME", pwd->pw_name, 1);
454 (void)setenv("USER", pwd->pw_name, 1);
455 (void)setenv("PATH", _PATH_DEFPATH, 0);
456 #ifdef KERBEROS
457 if (krbtkfile_env)
458 (void)setenv("KRBTKFILE", krbtkfile_env, 1);
459 #endif
460 #ifdef KERBEROS5
461 if (krbtkfile_env)
462 (void)setenv("KRB5CCNAME", krbtkfile_env, 1);
463 #endif
464
465 if (tty[sizeof("tty")-1] == 'd')
466 syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
467
468 /* If fflag is on, assume caller/authenticator has logged root login. */
469 if (rootlogin && fflag == 0)
470 if (hostname)
471 syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s FROM %s",
472 username, tty, hostname);
473 else
474 syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s", username, tty);
475
476 #if defined(KERBEROS) || defined(KERBEROS5)
477 if (!quietlog && notickets == 1)
478 (void)printf("Warning: no Kerberos tickets issued.\n");
479 #endif
480
481 if (!quietlog) {
482 (void)printf("%s\n\t%s %s\n\n",
483 "Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994",
484 "The Regents of the University of California. ",
485 "All rights reserved.");
486 motd();
487 (void)snprintf(tbuf,
488 sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
489 if (stat(tbuf, &st) == 0 && st.st_size != 0)
490 (void)printf("You have %smail.\n",
491 (st.st_mtime > st.st_atime) ? "new " : "");
492 }
493
494 (void)signal(SIGALRM, SIG_DFL);
495 (void)signal(SIGQUIT, SIG_DFL);
496 (void)signal(SIGINT, SIG_DFL);
497 (void)signal(SIGTSTP, SIG_IGN);
498
499 tbuf[0] = '-';
500 (void)strncpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ?
501 p + 1 : pwd->pw_shell, sizeof(tbuf) - 2);
502
503 if (setlogin(pwd->pw_name) < 0)
504 syslog(LOG_ERR, "setlogin() failure: %m");
505
506 /* Discard permissions last so can't get killed and drop core. */
507 if (rootlogin)
508 (void) setuid(0);
509 else
510 (void) setuid(pwd->pw_uid);
511
512 execlp(pwd->pw_shell, tbuf, 0);
513 err(1, "%s", pwd->pw_shell);
514 }
515
516 int
517 pwcheck(user, p, salt, passwd)
518 char *user, *p, *salt, *passwd;
519 {
520 int sts = strcmp(crypt(p, salt), passwd);
521
522 #ifdef SKEY
523 if (sts) { /* wasn't passwd */
524 if (skey_haskey(user)) {
525 if (strcasecmp(p, skeypw) == 0)
526 return 1;
527 } else {
528 if (strcasecmp(p, skeypw) == 0) {
529 sts = skey_authenticate(user);
530 } else {
531 if ((sts = skey_passcheck(user, p)) != -1) {
532 sts = 0; /* ok */
533 }
534 }
535 }
536 if (sts == 0)
537 used_skey = 1;
538 }
539 #endif
540 return sts;
541 }
542
543 #if defined(KERBEROS) || defined(KERBEROS5)
544 #define NBUFSIZ (MAXLOGNAME + 1 + 5) /* .root suffix */
545 #else
546 #define NBUFSIZ (MAXLOGNAME + 1)
547 #endif
548
549 #if defined(KERBEROS) || defined(KERBEROS5)
550 /*
551 * This routine handles cleanup stuff, and the like.
552 * It exists only in the child process.
553 */
554 #include <sys/wait.h>
555 void
556 dofork()
557 {
558 int child;
559
560 if (!(child = fork()))
561 return; /* Child process */
562
563 /* Setup stuff? This would be things we could do in parallel with login */
564 (void) chdir("/"); /* Let's not keep the fs busy... */
565
566 /* If we're the parent, watch the child until it dies */
567 while (wait(0) != child)
568 ;
569
570 /* Cleanup stuff */
571 /* Run kdestroy to destroy tickets */
572 kdestroy();
573
574 /* Leave */
575 exit(0);
576 }
577 #endif
578
579 void
580 getloginname()
581 {
582 int ch;
583 char *p;
584 static char nbuf[NBUFSIZ];
585
586 for (;;) {
587 (void)printf("login: ");
588 for (p = nbuf; (ch = getchar()) != '\n'; ) {
589 if (ch == EOF) {
590 badlogin(username);
591 exit(0);
592 }
593 if (p < nbuf + (NBUFSIZ - 1))
594 *p++ = ch;
595 }
596 if (p > nbuf)
597 if (nbuf[0] == '-')
598 (void)fprintf(stderr,
599 "login names may not start with '-'.\n");
600 else {
601 *p = '\0';
602 username = nbuf;
603 break;
604 }
605 }
606 }
607
608 int
609 rootterm(ttyn)
610 char *ttyn;
611 {
612 struct ttyent *t;
613
614 return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);
615 }
616
617 jmp_buf motdinterrupt;
618
619 void
620 motd()
621 {
622 int fd, nchars;
623 sig_t oldint;
624 char tbuf[8192];
625
626 if ((fd = open(_PATH_MOTDFILE, O_RDONLY, 0)) < 0)
627 return;
628 oldint = signal(SIGINT, sigint);
629 if (setjmp(motdinterrupt) == 0)
630 while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
631 (void)write(fileno(stdout), tbuf, nchars);
632 (void)signal(SIGINT, oldint);
633 (void)close(fd);
634 }
635
636 /* ARGSUSED */
637 void
638 sigint(signo)
639 int signo;
640 {
641 longjmp(motdinterrupt, 1);
642 }
643
644 /* ARGSUSED */
645 void
646 timedout(signo)
647 int signo;
648 {
649 (void)fprintf(stderr, "Login timed out after %d seconds\n", timeout);
650 exit(0);
651 }
652
653 void
654 checknologin()
655 {
656 int fd, nchars;
657 char tbuf[8192];
658
659 if ((fd = open(_PATH_NOLOGIN, O_RDONLY, 0)) >= 0) {
660 while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0)
661 (void)write(fileno(stdout), tbuf, nchars);
662 sleepexit(0);
663 }
664 }
665
666 void
667 dolastlog(quiet)
668 int quiet;
669 {
670 struct lastlog ll;
671 int fd;
672
673 if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
674 (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
675 if (!quiet) {
676 if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
677 ll.ll_time != 0) {
678 (void)printf("Last login: %.*s ",
679 24-5, (char *)ctime(&ll.ll_time));
680 if (*ll.ll_host != '\0')
681 (void)printf("from %.*s\n",
682 (int)sizeof(ll.ll_host),
683 ll.ll_host);
684 else
685 (void)printf("on %.*s\n",
686 (int)sizeof(ll.ll_line),
687 ll.ll_line);
688 }
689 (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
690 }
691 memset((void *)&ll, 0, sizeof(ll));
692 (void)time(&ll.ll_time);
693 (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
694 if (hostname)
695 (void)strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
696 (void)write(fd, (char *)&ll, sizeof(ll));
697 (void)close(fd);
698 }
699 }
700
701 void
702 badlogin(name)
703 char *name;
704 {
705 if (failures == 0)
706 return;
707 if (hostname) {
708 syslog(LOG_NOTICE, "%d LOGIN FAILURE%s FROM %s",
709 failures, failures > 1 ? "S" : "", hostname);
710 syslog(LOG_AUTHPRIV|LOG_NOTICE,
711 "%d LOGIN FAILURE%s FROM %s, %s",
712 failures, failures > 1 ? "S" : "", hostname, name);
713 } else {
714 syslog(LOG_NOTICE, "%d LOGIN FAILURE%s ON %s",
715 failures, failures > 1 ? "S" : "", tty);
716 syslog(LOG_AUTHPRIV|LOG_NOTICE,
717 "%d LOGIN FAILURE%s ON %s, %s",
718 failures, failures > 1 ? "S" : "", tty, name);
719 }
720 }
721
722 #undef UNKNOWN
723 #define UNKNOWN "su"
724
725 char *
726 stypeof(ttyid)
727 char *ttyid;
728 {
729 struct ttyent *t;
730
731 return (ttyid && (t = getttynam(ttyid)) ? t->ty_type : UNKNOWN);
732 }
733
734 void
735 sleepexit(eval)
736 int eval;
737 {
738 (void)sleep(5);
739 exit(eval);
740 }
741