2 * Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 static char copyright[] =
36 "@(#) Copyright (c) 1980, 1987, 1988, 1991, 1993, 1994\n\
37 The Regents of the University of California. All rights reserved.\n";
42 static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
44 static const char rcsid[] =
50 * login -h hostname (for telnetd, etc.)
51 * login -f name (for pre-authenticated login: datakit, xterm, etc.)
54 #include <sys/copyright.h>
55 #include <sys/param.h>
57 #include <sys/socket.h>
59 #include <sys/resource.h>
61 #include <netinet/in.h>
62 #include <arpa/inet.h>
68 #include <login_cap.h>
82 #include <security/pam_appl.h>
83 #include <security/pam_misc.h>
87 #include "pathnames.h"
89 /* wrapper for KAME-special getnameinfo() */
90 #ifndef NI_WITHSCOPEID
91 #define NI_WITHSCOPEID 0
94 void badlogin __P((char *));
95 void checknologin __P((void));
96 void dolastlog __P((int));
97 void getloginname __P((void));
98 void motd __P((char *));
99 int rootterm __P((char *));
100 void sigint __P((int));
101 void sleepexit __P((int));
102 void refused __P((char *,char *,int));
103 char *stypeof __P((char *));
104 void timedout __P((int));
105 int login_access __P((char *, char *));
106 void login_fbtab __P((char *, uid_t, gid_t));
109 static int auth_pam __P((void));
110 static int export_pam_environment __P((void));
111 static int ok_to_export __P((const char *));
113 static pam_handle_t *pamh = NULL;
114 static char **environ_pam;
117 if ((e = pam_setcred(pamh, PAM_DELETE_CRED)) != PAM_SUCCESS) \
118 syslog(LOG_ERR, "pam_setcred: %s", pam_strerror(pamh, e)); \
119 if ((e = pam_close_session(pamh,0)) != PAM_SUCCESS) \
120 syslog(LOG_ERR, "pam_close_session: %s", pam_strerror(pamh, e)); \
121 if ((e = pam_end(pamh, e)) != PAM_SUCCESS) \
122 syslog(LOG_ERR, "pam_end: %s", pam_strerror(pamh, e)); \
125 static int auth_traditional __P((void));
126 extern void login __P((struct utmp *));
127 static void usage __P((void));
129 #define TTYGRPNAME "tty" /* name of group to own ttys */
130 #define DEFAULT_BACKOFF 3
131 #define DEFAULT_RETRIES 10
132 #define DEFAULT_PROMPT "login: "
133 #define DEFAULT_PASSWD_PROMPT "Password:"
136 * This bounds the time given to login. Not a define so it can
137 * be patched on machines where it's too small.
141 /* Buffer for signal handling of timeout */
146 char *term, *envinit[1], *hostname, *passwd_prompt, *prompt, *tty, *username;
147 char full_hostname[MAXHOSTNAMELEN];
154 extern char **environ;
159 int rootok, retries, backoff;
160 int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval;
166 char tbuf[MAXPATHLEN + 2];
167 char tname[sizeof(_PATH_TTY) + 10];
169 login_cap_t *lc = NULL;
175 (void)signal(SIGQUIT, SIG_IGN);
176 (void)signal(SIGINT, SIG_IGN);
177 (void)signal(SIGHUP, SIG_IGN);
178 if (setjmp(timeout_buf)) {
181 (void)fprintf(stderr, "Login timed out after %d seconds\n",
185 (void)signal(SIGALRM, timedout);
186 (void)alarm(timeout);
187 (void)setpriority(PRIO_PROCESS, 0, 0);
189 openlog("login", LOG_ODELAY, LOG_AUTH);
192 * -p is used by getty to tell login not to destroy the environment
193 * -f is used to skip a second login authentication
194 * -h is used by other servers to pass the name of the remote
195 * host to login so that it may be placed in utmp and wtmp
197 *full_hostname = '\0';
200 fflag = hflag = pflag = 0;
204 while ((ch = getopt(argc, argv, "fh:p")) != -1)
211 errx(1, "-h option: %s", strerror(EPERM));
213 strncpy(full_hostname, optarg, sizeof(full_hostname)-1);
215 trimdomain(optarg, UT_HOSTSIZE);
217 if (strlen(optarg) > UT_HOSTSIZE) {
218 struct addrinfo hints, *res;
221 memset(&hints, 0, sizeof(hints));
222 hints.ai_family = AF_UNSPEC;
223 ga_err = getaddrinfo(optarg, NULL, &hints,
226 char hostbuf[MAXHOSTNAMELEN];
228 getnameinfo(res->ai_addr,
231 sizeof(hostbuf), NULL, 0,
234 optarg = strdup(hostbuf);
236 optarg = "invalid hostname";
248 syslog(LOG_ERR, "invalid flag %c", ch);
260 for (cnt = getdtablesize(); cnt > 2; cnt--)
263 ttyn = ttyname(STDIN_FILENO);
264 if (ttyn == NULL || *ttyn == '\0') {
265 (void)snprintf(tname, sizeof(tname), "%s??", _PATH_TTY);
268 if ((tty = strrchr(ttyn, '/')) != NULL)
274 * Get "login-retries" & "login-backoff" from default class
276 lc = login_getclass(NULL);
277 prompt = login_getcapstr(lc, "prompt", DEFAULT_PROMPT, DEFAULT_PROMPT);
278 passwd_prompt = login_getcapstr(lc, "passwd_prompt",
279 DEFAULT_PASSWD_PROMPT, DEFAULT_PASSWD_PROMPT);
280 retries = login_getcapnum(lc, "login-retries", DEFAULT_RETRIES,
282 backoff = login_getcapnum(lc, "login-backoff", DEFAULT_BACKOFF,
287 for (cnt = 0;; ask = 1) {
293 rootok = rootterm(tty); /* Default (auth may change) */
295 if (strlen(username) > UT_NAMESIZE)
296 username[UT_NAMESIZE] = '\0';
299 * Note if trying multiple user names; log failures for
300 * previous user name, but don't bother logging one failure
301 * for nonexistent name (mistyped username).
303 if (failures && strcmp(tbuf, username)) {
304 if (failures > (pwd ? 0 : 1))
307 (void)strncpy(tbuf, username, sizeof tbuf-1);
308 tbuf[sizeof tbuf-1] = '\0';
310 pwd = getpwnam(username);
313 * if we have a valid account name, and it doesn't have a
314 * password, or the -f option was specified and the caller
315 * is root or the caller isn't changing their uid, don't
319 if (pwd->pw_uid == 0)
322 if (fflag && (uid == (uid_t)0 ||
323 uid == (uid_t)pwd->pw_uid)) {
324 /* already authenticated */
326 } else if (pwd->pw_passwd[0] == '\0') {
327 if (!rootlogin || rootok) {
328 /* pretend password okay */
337 (void)setpriority(PRIO_PROCESS, 0, -4);
341 * Try to authenticate using PAM. If a PAM system error
342 * occurs, perhaps because of a botched configuration,
343 * then fall back to using traditional Unix authentication.
345 if ((rval = auth_pam()) == -1)
347 rval = auth_traditional();
349 (void)setpriority(PRIO_PROCESS, 0, 0);
353 * PAM authentication may have changed "pwd" to the
354 * entry for the template user. Check again to see if
355 * this is a root login after all.
357 if (pwd != NULL && pwd->pw_uid == 0)
363 * If trying to log in as root without Kerberos,
364 * but with insecure terminal, refuse the login attempt.
367 if (rootlogin && !rootok)
368 refused(NULL, "NOROOT", 0);
369 else /* valid password & authenticated */
373 (void)printf("Login incorrect\n");
377 * we allow up to 'retry' (10) tries,
378 * but after 'backoff' (3) we start backing off
380 if (++cnt > backoff) {
381 if (cnt >= retries) {
385 sleep((u_int)((cnt - backoff) * 5));
389 /* committed to login -- turn off timeout */
390 (void)alarm((u_int)0);
391 (void)signal(SIGHUP, SIG_DFL);
396 * Establish the login class.
398 lc = login_getpwclass(pwd);
400 /* if user not super-user, check for disabled logins */
402 auth_checknologin(lc);
404 quietlog = login_getcapbool(lc, "hushlogin", 0);
405 /* Switching needed for NFS with root access disabled */
406 (void)setegid(pwd->pw_gid);
407 (void)seteuid(rootlogin ? 0 : pwd->pw_uid);
408 if (!*pwd->pw_dir || chdir(pwd->pw_dir) < 0) {
409 if (login_getcapbool(lc, "requirehome", 0))
410 refused("Home directory not available", "HOMEDIR", 1);
412 refused("Cannot find root directory", "ROOTDIR", 1);
413 if (!quietlog || *pwd->pw_dir)
414 printf("No home directory.\nLogging in with home = \"/\".\n");
420 quietlog = access(_PATH_HUSHLOGIN, F_OK) == 0;
422 if (pwd->pw_change || pwd->pw_expire)
423 (void)gettimeofday(&tp, (struct timezone *)NULL);
425 #define DEFAULT_WARN (2L * 7L * 86400L) /* Two weeks */
427 warntime = login_getcaptime(lc, "warnexpire", DEFAULT_WARN,
430 if (pwd->pw_expire) {
431 if (tp.tv_sec >= pwd->pw_expire) {
432 refused("Sorry -- your account has expired", "EXPIRED",
434 } else if (pwd->pw_expire - tp.tv_sec < warntime && !quietlog)
435 (void)printf("Warning: your account expires on %s",
436 ctime(&pwd->pw_expire));
439 warntime = login_getcaptime(lc, "warnpassword", DEFAULT_WARN,
443 if (pwd->pw_change) {
444 if (tp.tv_sec >= pwd->pw_change) {
445 (void)printf("Sorry -- your password has expired.\n");
447 syslog(LOG_INFO, "%s Password expired - forcing change",
449 } else if (pwd->pw_change - tp.tv_sec < warntime && !quietlog)
450 (void)printf("Warning: your password expires on %s",
451 ctime(&pwd->pw_change));
456 struct addrinfo hints, *res;
459 memset(&hints, 0, sizeof(hints));
460 hints.ai_family = AF_UNSPEC;
461 ga_err = getaddrinfo(full_hostname, NULL, &hints,
464 char hostbuf[MAXHOSTNAMELEN];
466 getnameinfo(res->ai_addr, res->ai_addrlen,
467 hostbuf, sizeof(hostbuf), NULL, 0,
468 NI_NUMERICHOST|NI_WITHSCOPEID);
469 optarg = strdup(hostbuf);
474 if (!auth_hostok(lc, full_hostname, optarg))
475 refused("Permission denied", "HOST", 1);
478 if (!auth_ttyok(lc, tty))
479 refused("Permission denied", "TTY", 1);
481 if (!auth_timeok(lc, time(NULL)))
482 refused("Logins not available right now", "TIME", 1);
484 shell = login_getcapstr(lc, "shell", pwd->pw_shell, pwd->pw_shell);
485 if (*pwd->pw_shell == '\0')
486 pwd->pw_shell = _PATH_BSHELL;
487 if (*shell == '\0') /* Not overridden */
488 shell = pwd->pw_shell;
489 if ((shell = strdup(shell)) == NULL) {
490 syslog(LOG_NOTICE, "memory allocation error");
495 if (login_access(pwd->pw_name, hostname ? full_hostname : tty) == 0)
496 refused("Permission denied", "ACCESS", 1);
497 #endif /* LOGIN_ACCESS */
499 /* Nothing else left to fail -- really log in. */
500 memset((void *)&utmp, 0, sizeof(utmp));
501 (void)time(&utmp.ut_time);
502 (void)strncpy(utmp.ut_name, username, sizeof(utmp.ut_name));
504 (void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
505 (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
511 * Set device protections, depending on what terminal the
512 * user is logged in. This feature is used on Suns to give
513 * console users better privacy.
515 login_fbtab(tty, pwd->pw_uid, pwd->pw_gid);
518 * Clear flags of the tty. None should be set, and when the
519 * user sets them otherwise, this can cause the chown to fail.
520 * Since it isn't clear that flags are useful on character
521 * devices, we just clear them.
523 if (chflags(ttyn, 0) && errno != EOPNOTSUPP)
524 syslog(LOG_ERR, "chmod(%s): %m", ttyn);
525 if (chown(ttyn, pwd->pw_uid,
526 (gr = getgrnam(TTYGRPNAME)) ? gr->gr_gid : pwd->pw_gid))
527 syslog(LOG_ERR, "chmod(%s): %m", ttyn);
531 * Preserve TERM if it happens to be already set.
533 if ((term = getenv("TERM")) != NULL)
537 * Exclude cons/vt/ptys only, assume dialup otherwise
538 * TODO: Make dialup tty determination a library call
539 * for consistency (finger etc.)
541 if (hostname==NULL && isdialuptty(tty))
542 syslog(LOG_INFO, "DIALUP %s, %s", tty, pwd->pw_name);
546 * Syslog each successful login, so we don't have to watch hundreds
547 * of wtmp or lastlogin files.
550 syslog(LOG_INFO, "login from %s on %s as %s",
551 full_hostname, tty, pwd->pw_name);
553 syslog(LOG_INFO, "login on %s as %s",
558 * If fflag is on, assume caller/authenticator has logged root login.
560 if (rootlogin && fflag == 0)
563 syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s FROM %s",
564 username, tty, full_hostname);
566 syslog(LOG_NOTICE, "ROOT LOGIN (%s) ON %s",
571 * Destroy environment unless user has requested its preservation.
572 * We need to do this before setusercontext() because that may
573 * set or reset some environment variables.
580 * Add any environmental variables that the
581 * PAM modules may have set.
584 environ_pam = pam_getenvlist(pamh);
586 export_pam_environment();
591 * PAM modules might add supplementary groups during pam_setcred().
593 if (setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETGROUP) != 0) {
594 syslog(LOG_ERR, "setusercontext() failed - exiting");
600 if ((e = pam_open_session(pamh, 0)) != PAM_SUCCESS) {
601 syslog(LOG_ERR, "pam_open_session: %s",
602 pam_strerror(pamh, e));
603 } else if ((e = pam_setcred(pamh, PAM_ESTABLISH_CRED))
605 syslog(LOG_ERR, "pam_setcred: %s",
606 pam_strerror(pamh, e));
610 * We must fork() before setuid() because we need to call
611 * pam_close_session() as root.
619 /* parent - wait for child to finish, then cleanup
625 if ((e = pam_end(pamh, PAM_DATA_SILENT)) != PAM_SUCCESS)
626 syslog(LOG_ERR, "pam_end: %s",
627 pam_strerror(pamh, e));
633 * We don't need to be root anymore, so
634 * set the user and session context
636 if (setlogin(username) != 0) {
637 syslog(LOG_ERR, "setlogin(%s): %m - exiting", username);
640 if (setusercontext(lc, pwd, pwd->pw_uid,
641 LOGIN_SETALL & ~(LOGIN_SETLOGIN|LOGIN_SETGROUP)) != 0) {
642 syslog(LOG_ERR, "setusercontext() failed - exiting");
646 (void)setenv("SHELL", pwd->pw_shell, 1);
647 (void)setenv("HOME", pwd->pw_dir, 1);
648 if (term != NULL && *term != '\0')
649 (void)setenv("TERM", term, 1); /* Preset overrides */
651 (void)setenv("TERM", stypeof(tty), 0); /* Fallback doesn't */
653 (void)setenv("LOGNAME", username, 1);
654 (void)setenv("USER", username, 1);
655 (void)setenv("PATH", rootlogin ? _PATH_STDPATH : _PATH_DEFPATH, 0);
660 cw = login_getcapstr(lc, "copyright", NULL, NULL);
661 if (cw != NULL && access(cw, F_OK) == 0)
664 (void)printf("%s\n\t%s %s\n",
665 "Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994",
666 "The Regents of the University of California. ",
667 "All rights reserved.");
671 cw = login_getcapstr(lc, "welcome", NULL, NULL);
672 if (cw == NULL || access(cw, F_OK) != 0)
676 cw = getenv("MAIL"); /* $MAIL may have been set by class */
678 strncpy(tbuf, cw, sizeof(tbuf));
679 tbuf[sizeof(tbuf)-1] = '\0';
681 snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR,
683 if (stat(tbuf, &st) == 0 && st.st_size != 0)
684 (void)printf("You have %smail.\n",
685 (st.st_mtime > st.st_atime) ? "new " : "");
690 (void)signal(SIGALRM, SIG_DFL);
691 (void)signal(SIGQUIT, SIG_DFL);
692 (void)signal(SIGINT, SIG_DFL);
693 (void)signal(SIGTSTP, SIG_IGN);
696 if (system(_PATH_CHPASS) != 0)
701 * Login shells have a leading '-' in front of argv[0]
704 (void)strcpy(tbuf + 1,
705 (p = strrchr(pwd->pw_shell, '/')) ? p + 1 : pwd->pw_shell);
707 execlp(shell, tbuf, 0);
720 salt = pwd != NULL ? pwd->pw_passwd : "xx";
722 p = getpass(passwd_prompt);
726 if (!p[0] && pwd->pw_passwd[0])
728 if (strcmp(ep, pwd->pw_passwd) == 0)
732 /* clear entered password */
733 memset(p, 0, strlen(p));
739 * Attempt to authenticate the user using PAM. Returns 0 if the user is
740 * authenticated, or 1 if not authenticated. If some sort of PAM system
741 * error occurs (e.g., the "/etc/pam.conf" file is missing) then this
742 * function returns -1. This can be used as an indication that we should
743 * fall back to a different authentication mechanism.
748 const char *tmpl_user;
752 static struct pam_conv conv = { misc_conv, NULL };
754 if ((e = pam_start("login", username, &conv, &pamh)) != PAM_SUCCESS) {
755 syslog(LOG_ERR, "pam_start: %s", pam_strerror(pamh, e));
758 if ((e = pam_set_item(pamh, PAM_TTY, tty)) != PAM_SUCCESS) {
759 syslog(LOG_ERR, "pam_set_item(PAM_TTY): %s",
760 pam_strerror(pamh, e));
763 if (hostname != NULL &&
764 (e = pam_set_item(pamh, PAM_RHOST, full_hostname)) != PAM_SUCCESS) {
765 syslog(LOG_ERR, "pam_set_item(PAM_RHOST): %s",
766 pam_strerror(pamh, e));
769 e = pam_authenticate(pamh, 0);
774 * With PAM we support the concept of a "template"
775 * user. The user enters a login name which is
776 * authenticated by PAM, usually via a remote service
777 * such as RADIUS or TACACS+. If authentication
778 * succeeds, a different but related "template" name
779 * is used for setting the credentials, shell, and
780 * home directory. The name the user enters need only
781 * exist on the remote authentication server, but the
782 * template name must be present in the local password
785 * This is supported by two various mechanisms in the
786 * individual modules. However, from the application's
787 * point of view, the template user is always passed
788 * back as a changed value of the PAM_USER item.
790 if ((e = pam_get_item(pamh, PAM_USER, &item)) ==
792 tmpl_user = (const char *) item;
793 if (strcmp(username, tmpl_user) != 0)
794 pwd = getpwnam(tmpl_user);
796 syslog(LOG_ERR, "Couldn't get PAM_USER: %s",
797 pam_strerror(pamh, e));
802 case PAM_USER_UNKNOWN:
808 syslog(LOG_ERR, "pam_authenticate: %s", pam_strerror(pamh, e));
814 e = pam_acct_mgmt(pamh, 0);
815 if (e == PAM_NEW_AUTHTOK_REQD) {
816 e = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
817 if (e != PAM_SUCCESS) {
818 syslog(LOG_ERR, "pam_chauthtok: %s",
819 pam_strerror(pamh, e));
822 } else if (e != PAM_SUCCESS) {
828 if ((e = pam_end(pamh, e)) != PAM_SUCCESS) {
829 syslog(LOG_ERR, "pam_end: %s", pam_strerror(pamh, e));
837 export_pam_environment()
841 for (pp = environ_pam; *pp != NULL; pp++) {
842 if (ok_to_export(*pp))
850 * Sanity checks on PAM environmental variables:
851 * - Make sure there is an '=' in the string.
852 * - Make sure the string doesn't run on too long.
853 * - Do not export certain variables. This list was taken from the
854 * Solaris pam_putenv(3) man page.
860 static const char *noexport[] = {
861 "SHELL", "HOME", "LOGNAME", "MAIL", "CDPATH",
867 if (strlen(s) > 1024 || strchr(s, '=') == NULL)
869 if (strncmp(s, "LD_", 3) == 0)
871 for (pp = noexport; *pp != NULL; pp++) {
873 if (s[n] == '=' && strncmp(s, *pp, n) == 0)
884 (void)fprintf(stderr, "usage: login [-fp] [-h hostname] [username]\n");
889 * Allow for authentication style and/or kerberos instance
892 #define NBUFSIZ UT_NAMESIZE + 64
899 static char nbuf[NBUFSIZ];
902 (void)printf(prompt);
903 for (p = nbuf; (ch = getchar()) != '\n'; ) {
908 if (p < nbuf + (NBUFSIZ - 1))
913 (void)fprintf(stderr,
914 "login names may not start with '-'.\n");
930 return ((t = getttynam(ttyn)) && t->ty_status & TTY_SECURE);
933 volatile int motdinterrupt;
951 if ((fd = open(motdfile, O_RDONLY, 0)) < 0)
954 oldint = signal(SIGINT, sigint);
955 while ((nchars = read(fd, tbuf, sizeof(tbuf))) > 0 && !motdinterrupt)
956 (void)write(fileno(stdout), tbuf, nchars);
957 (void)signal(SIGINT, oldint);
967 longjmp(timeout_buf, signo);
978 if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) >= 0) {
979 (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
981 if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
983 (void)printf("Last login: %.*s ",
984 24-5, (char *)ctime(&ll.ll_time));
985 if (*ll.ll_host != '\0')
986 (void)printf("from %.*s\n",
987 (int)sizeof(ll.ll_host),
990 (void)printf("on %.*s\n",
991 (int)sizeof(ll.ll_line),
994 (void)lseek(fd, (off_t)pwd->pw_uid * sizeof(ll), L_SET);
996 memset((void *)&ll, 0, sizeof(ll));
997 (void)time(&ll.ll_time);
998 (void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
1000 (void)strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
1001 (void)write(fd, (char *)&ll, sizeof(ll));
1014 syslog(LOG_NOTICE, "%d LOGIN FAILURE%s FROM %s",
1015 failures, failures > 1 ? "S" : "", full_hostname);
1016 syslog(LOG_AUTHPRIV|LOG_NOTICE,
1017 "%d LOGIN FAILURE%s FROM %s, %s",
1018 failures, failures > 1 ? "S" : "", full_hostname, name);
1020 syslog(LOG_NOTICE, "%d LOGIN FAILURE%s ON %s",
1021 failures, failures > 1 ? "S" : "", tty);
1022 syslog(LOG_AUTHPRIV|LOG_NOTICE,
1023 "%d LOGIN FAILURE%s ON %s, %s",
1024 failures, failures > 1 ? "S" : "", tty, name);
1030 #define UNKNOWN "su"
1038 return (ttyid && (t = getttynam(ttyid)) ? t->ty_type : UNKNOWN);
1042 refused(msg, rtype, lout)
1049 printf("%s.\n", msg);
1051 syslog(LOG_NOTICE, "LOGIN %s REFUSED (%s) FROM %s ON TTY %s",
1052 pwd->pw_name, rtype, full_hostname, tty);
1054 syslog(LOG_NOTICE, "LOGIN %s REFUSED (%s) ON TTY %s",
1055 pwd->pw_name, rtype, tty);