diff options
Diffstat (limited to 'login.c')
-rw-r--r-- | login.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -18,9 +18,14 @@ on a tty. | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "includes.h" | 20 | #include "includes.h" |
21 | RCSID("$Id: login.c,v 1.1 1999/10/27 03:42:44 damien Exp $"); | 21 | RCSID("$Id: login.c,v 1.2 1999/11/10 23:40:23 damien Exp $"); |
22 | 22 | ||
23 | #include <utmp.h> | 23 | #include <utmp.h> |
24 | |||
25 | #ifdef HAVE_LASTLOG_H | ||
26 | # include <lastlog.h> | ||
27 | #endif | ||
28 | |||
24 | #include "ssh.h" | 29 | #include "ssh.h" |
25 | 30 | ||
26 | /* Returns the time when the user last logged in. Returns 0 if the | 31 | /* Returns the time when the user last logged in. Returns 0 if the |
@@ -76,7 +81,9 @@ void record_login(int pid, const char *ttyname, const char *user, uid_t uid, | |||
76 | strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); | 81 | strncpy(u.ut_line, ttyname + 5, sizeof(u.ut_line)); |
77 | u.ut_time = time(NULL); | 82 | u.ut_time = time(NULL); |
78 | strncpy(u.ut_name, user, sizeof(u.ut_name)); | 83 | strncpy(u.ut_name, user, sizeof(u.ut_name)); |
84 | #ifdef HAVE_HOST_IN_UTMP | ||
79 | strncpy(u.ut_host, host, sizeof(u.ut_host)); | 85 | strncpy(u.ut_host, host, sizeof(u.ut_host)); |
86 | #endif | ||
80 | 87 | ||
81 | /* Figure out the file names. */ | 88 | /* Figure out the file names. */ |
82 | utmp = _PATH_UTMP; | 89 | utmp = _PATH_UTMP; |
@@ -108,11 +115,14 @@ void record_login(int pid, const char *ttyname, const char *user, uid_t uid, | |||
108 | } | 115 | } |
109 | } | 116 | } |
110 | 117 | ||
111 | /* Records that the user has logged out. */ | ||
112 | |||
113 | void record_logout(int pid, const char *ttyname) | 118 | void record_logout(int pid, const char *ttyname) |
114 | { | 119 | { |
120 | #ifdef HAVE_LIBUTIL_LOGIN | ||
115 | const char *line = ttyname + 5; /* /dev/ttyq8 -> ttyq8 */ | 121 | const char *line = ttyname + 5; /* /dev/ttyq8 -> ttyq8 */ |
116 | if (logout(line)) | 122 | if (logout(line)) |
117 | logwtmp(line, "", ""); | 123 | logwtmp(line, "", ""); |
124 | #else /* HAVE_LIBUTIL_LOGIN */ | ||
125 | record_login(pid, ttyname, "", -1, "", NULL); | ||
126 | #endif /* HAVE_LIBUTIL_LOGIN */ | ||
118 | } | 127 | } |
128 | |||