version 1.7, 2003/06/12 07:57:38 |
version 1.8, 2004/06/21 17:36:31 |
|
|
* systems were more standardized. |
* systems were more standardized. |
*/ |
*/ |
void |
void |
record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid, |
record_login(pid_t pid, const char *tty, const char *user, uid_t uid, |
const char *host, struct sockaddr * addr, socklen_t addrlen) |
const char *host, struct sockaddr * addr, socklen_t addrlen) |
{ |
{ |
int fd; |
int fd; |
|
|
|
|
/* Construct an utmp/wtmp entry. */ |
/* Construct an utmp/wtmp entry. */ |
memset(&u, 0, sizeof(u)); |
memset(&u, 0, sizeof(u)); |
strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); |
strncpy(u.ut_line, tty + 5, sizeof(u.ut_line)); |
u.ut_time = time(NULL); |
u.ut_time = time(NULL); |
strncpy(u.ut_name, user, sizeof(u.ut_name)); |
strncpy(u.ut_name, user, sizeof(u.ut_name)); |
strncpy(u.ut_host, host, sizeof(u.ut_host)); |
strncpy(u.ut_host, host, sizeof(u.ut_host)); |
|
|
|
|
/* Update lastlog. */ |
/* Update lastlog. */ |
ll.ll_time = time(NULL); |
ll.ll_time = time(NULL); |
strncpy(ll.ll_line, ttyname + 5, sizeof(ll.ll_line)); |
strncpy(ll.ll_line, tty + 5, sizeof(ll.ll_line)); |
strncpy(ll.ll_host, host, sizeof(ll.ll_host)); |
strncpy(ll.ll_host, host, sizeof(ll.ll_host)); |
fd = open(lastlog, O_RDWR); |
fd = open(lastlog, O_RDWR); |
if (fd >= 0) { |
if (fd >= 0) { |
|
|
|
|
/* Records that the user has logged out. */ |
/* Records that the user has logged out. */ |
void |
void |
record_logout(pid_t pid, const char *ttyname) |
record_logout(pid_t pid, const char *tty) |
{ |
{ |
const char *line = ttyname + 5; /* /dev/ttyq8 -> ttyq8 */ |
const char *line = tty + 5; /* /dev/ttyq8 -> ttyq8 */ |
if (logout(line)) |
if (logout(line)) |
logwtmp(line, "", ""); |
logwtmp(line, "", ""); |
} |
} |