version 1.1, 1996/11/09 20:17:15 |
version 1.2, 1996/12/04 04:04:41 |
|
|
#include "pathnames.h" |
#include "pathnames.h" |
|
|
struct badlogin { |
struct badlogin { |
size_t count; /* number of bad logins */ |
|
time_t bl_time; /* time of the login attempt */ |
|
char bl_line[UT_LINESIZE]; /* tty used */ |
char bl_line[UT_LINESIZE]; /* tty used */ |
|
char bl_name[UT_NAMESIZE]; /* remote username */ |
char bl_host[UT_HOSTSIZE]; /* remote host */ |
char bl_host[UT_HOSTSIZE]; /* remote host */ |
|
time_t bl_time; /* time of the login attempt */ |
|
size_t count; /* number of bad logins */ |
}; |
}; |
|
|
/* |
/* |
* Log a bad login to the failedlogin file. |
* Log a bad login to the failedlogin file. |
*/ |
*/ |
void |
void |
log_failedlogin(uid, host, tty) |
log_failedlogin(uid, host, name, tty) |
uid_t uid; |
uid_t uid; |
char *host, *tty; |
char *host, *name, *tty; |
{ |
{ |
struct badlogin failedlogin; |
struct badlogin failedlogin; |
int fd; |
int fd; |
|
|
strncpy(failedlogin.bl_host, host, sizeof(failedlogin.bl_host)); |
strncpy(failedlogin.bl_host, host, sizeof(failedlogin.bl_host)); |
else |
else |
*failedlogin.bl_host = '\0'; /* NULL host field */ |
*failedlogin.bl_host = '\0'; /* NULL host field */ |
|
if (name) |
|
strncpy(failedlogin.bl_name, name, sizeof(failedlogin.bl_name)); |
|
else |
|
*failedlogin.bl_name = '\0'; /* NULL name field */ |
(void)write(fd, (char *)&failedlogin, sizeof(failedlogin)); |
(void)write(fd, (char *)&failedlogin, sizeof(failedlogin)); |
(void)close(fd); |
(void)close(fd); |
} |
} |
|
|
(int)sizeof(failedlogin.bl_line), |
(int)sizeof(failedlogin.bl_line), |
failedlogin.bl_line); |
failedlogin.bl_line); |
if (*failedlogin.bl_host != '\0') |
if (*failedlogin.bl_host != '\0') |
(void)printf(" from %.*s", |
if (*failedlogin.bl_name != '\0') |
(int)sizeof(failedlogin.bl_host), |
(void)printf(" from %.*s@%.*s", |
failedlogin.bl_host); |
(int)sizeof(failedlogin.bl_name), |
|
failedlogin.bl_name, |
|
(int)sizeof(failedlogin.bl_host), |
|
failedlogin.bl_host); |
|
else |
|
(void)printf(" from %.*s", |
|
(int)sizeof(failedlogin.bl_host), |
|
failedlogin.bl_host); |
(void)putchar('\n'); |
(void)putchar('\n'); |
|
|
/* Reset since this is a good login and write record */ |
/* Reset since this is a good login and write record */ |