version 1.1, 2001/03/04 01:46:30 |
version 1.2, 2001/03/24 16:43:27 |
|
|
* The host the user logged in from will be returned in buf. |
* The host the user logged in from will be returned in buf. |
*/ |
*/ |
|
|
/* |
|
* Returns the time when the user last logged in (or 0 if no previous login |
|
* is found). The name of the host used last time is returned in buf. |
|
*/ |
|
|
|
u_long |
u_long |
get_last_login_time(uid_t uid, const char *logname, |
get_last_login_time(uid_t uid, const char *logname, |
char *buf, u_int bufsize) |
char *buf, u_int bufsize) |
|
|
struct lastlog ll; |
struct lastlog ll; |
char *lastlog; |
char *lastlog; |
struct utmp u; |
struct utmp u; |
const char *utmp, *wtmp; |
|
|
|
/* Construct an utmp/wtmp entry. */ |
/* Construct an utmp/wtmp entry. */ |
memset(&u, 0, sizeof(u)); |
memset(&u, 0, sizeof(u)); |
|
|
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)); |
|
|
/* Figure out the file names. */ |
|
utmp = _PATH_UTMP; |
|
wtmp = _PATH_WTMP; |
|
|
|
login(&u); |
login(&u); |
lastlog = _PATH_LASTLOG; |
lastlog = _PATH_LASTLOG; |