log root unlock attempts

PR:	bin/13932
This commit is contained in:
Jacques Vidrine 1999-10-12 13:33:48 +00:00
parent 4b12dfb184
commit 65c543c764
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52158

View File

@ -59,6 +59,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <err.h>
#include <ctype.h>
@ -67,7 +68,9 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <varargs.h>
#define TIMEOUT 15
@ -91,11 +94,13 @@ main(argc, argv)
time_t timval_sec;
struct itimerval ntimer, otimer;
struct tm *timp;
int ch, sectimeout, usemine;
int ch, failures, sectimeout, usemine;
char *ap, *mypw, *ttynam, *tzn;
char hostname[MAXHOSTNAMELEN], s[BUFSIZ], s1[BUFSIZ];
char *crypt(), *ttyname();
openlog("lock", LOG_ODELAY, LOG_AUTH);
sectimeout = TIMEOUT;
mypw = NULL;
usemine = 0;
@ -181,6 +186,7 @@ main(argc, argv)
(void)printf("lock: %s on %s. timeout in %d minutes\ntime now is %.20s%s%s",
ttynam, hostname, sectimeout, ap, tzn, ap + 19);
}
failures = 0;
for (;;) {
(void)printf("Key: ");
@ -197,9 +203,17 @@ main(argc, argv)
else if (!strcmp(s, s1))
break;
(void)printf("\07\n");
failures++;
if (getuid() == 0)
syslog(LOG_NOTICE, "%d ROOT UNLOCK FAILURE%s (%s on %s)",
failures, failures > 1 ? "S": "", ttynam, hostname);
if (ioctl(0, TIOCGETP, &ntty))
exit(1);
sleep(1); /* to discourage guessing */
}
if (getuid() == 0)
syslog(LOG_NOTICE, "ROOT UNLOCK ON hostname %s port %s",
hostname, ttynam);
quit();
return(0); /* not reached */
}