summaryrefslogtreecommitdiffstats
path: root/usr.bin/login/login.c
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>1999-01-03 23:39:33 +0000
committereivind <eivind@FreeBSD.org>1999-01-03 23:39:33 +0000
commitc48f512ac80877fb7de0da14331853c7b5f7bc23 (patch)
tree5d4a9e8ce0e9caa14ae06b0c51cc67b2dd7f011d /usr.bin/login/login.c
parent97dd49d76d7a0d9dad9e5ab09cea3fff2457b023 (diff)
downloadFreeBSD-src-c48f512ac80877fb7de0da14331853c7b5f7bc23.zip
FreeBSD-src-c48f512ac80877fb7de0da14331853c7b5f7bc23.tar.gz
Make the timeout handler log any failed logins, to make sure failed
logins get logged.
Diffstat (limited to 'usr.bin/login/login.c')
-rw-r--r--usr.bin/login/login.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index bb33298..2cd1199 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -42,7 +42,7 @@ static char copyright[] =
static char sccsid[] = "@(#)login.c 8.4 (Berkeley) 4/2/94";
#endif
static const char rcsid[] =
- "$Id: login.c,v 1.42 1998/11/11 05:47:45 jdp Exp $";
+ "$Id: login.c,v 1.43 1998/11/21 02:22:14 jdp Exp $";
#endif /* not lint */
/*
@@ -111,6 +111,9 @@ static void usage __P((void));
*/
u_int timeout = 300;
+/* Buffer for signal handling of timeout */
+jmp_buf timeout_buf;
+
struct passwd *pwd;
int failures;
char *term, *envinit[1], *hostname, *username, *tty;
@@ -132,15 +135,23 @@ main(argc, argv)
time_t warntime;
uid_t uid, euid;
char *domain, *p, *ttyn;
- char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
+ char tbuf[MAXPATHLEN + 2];
+ char tname[sizeof(_PATH_TTY) + 10];
char localhost[MAXHOSTNAMELEN];
char *shell = NULL;
login_cap_t *lc = NULL;
- (void)signal(SIGALRM, timedout);
- (void)alarm(timeout);
(void)signal(SIGQUIT, SIG_IGN);
(void)signal(SIGINT, SIG_IGN);
+ if (setjmp(timeout_buf)) {
+ if (failures)
+ badlogin(tbuf);
+ (void)fprintf(stderr,
+ "Login timed out after %d seconds\n", timeout);
+ exit(0);
+ }
+ (void)signal(SIGALRM, timedout);
+ (void)alarm(timeout);
(void)setpriority(PRIO_PROCESS, 0, 0);
openlog("login", LOG_ODELAY, LOG_AUTH);
@@ -250,7 +261,6 @@ main(argc, argv)
if (failures && strcmp(tbuf, username)) {
if (failures > (pwd ? 0 : 1))
badlogin(tbuf);
- failures = 0;
}
(void)strncpy(tbuf, username, sizeof tbuf-1);
tbuf[sizeof tbuf-1] = '\0';
@@ -769,8 +779,7 @@ void
timedout(signo)
int signo;
{
- (void)fprintf(stderr, "Login timed out after %d seconds\n", timeout);
- exit(0);
+ longjmp(timeout_buf, signo);
}
@@ -829,6 +838,7 @@ badlogin(name)
"%d LOGIN FAILURE%s ON %s, %s",
failures, failures > 1 ? "S" : "", tty, name);
}
+ failures = 0;
}
#undef UNKNOWN
OpenPOWER on IntegriCloud