diff options
Diffstat (limited to 'login.c')
-rw-r--r-- | login.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "includes.h" | 20 | #include "includes.h" |
21 | RCSID("$Id: login.c,v 1.9 1999/12/21 10:30:56 damien Exp $"); | 21 | RCSID("$Id: login.c,v 1.10 1999/12/22 05:09:48 damien Exp $"); |
22 | 22 | ||
23 | #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) | 23 | #if defined(HAVE_UTMPX_H) && defined(USE_UTMPX) |
24 | # include <utmpx.h> | 24 | # include <utmpx.h> |
@@ -53,7 +53,7 @@ unsigned long | |||
53 | get_last_login_time(uid_t uid, const char *logname, | 53 | get_last_login_time(uid_t uid, const char *logname, |
54 | char *buf, unsigned int bufsize) | 54 | char *buf, unsigned int bufsize) |
55 | { | 55 | { |
56 | #if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) | 56 | #if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) |
57 | struct lastlog ll; | 57 | struct lastlog ll; |
58 | char *lastlog; | 58 | char *lastlog; |
59 | int fd; | 59 | int fd; |
@@ -76,7 +76,7 @@ get_last_login_time(uid_t uid, const char *logname, | |||
76 | buf[bufsize - 1] = 0; | 76 | buf[bufsize - 1] = 0; |
77 | return ll.ll_time; | 77 | return ll.ll_time; |
78 | 78 | ||
79 | #else /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */ | 79 | #else /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ |
80 | /* Look in wtmp for the last login */ | 80 | /* Look in wtmp for the last login */ |
81 | struct utmp wt; | 81 | struct utmp wt; |
82 | char *wt_file = _PATH_WTMP; | 82 | char *wt_file = _PATH_WTMP; |
@@ -101,10 +101,14 @@ get_last_login_time(uid_t uid, const char *logname, | |||
101 | if ( wt.ut_type == USER_PROCESS) { | 101 | if ( wt.ut_type == USER_PROCESS) { |
102 | if ( !strncmp(logname, wt.ut_user, 8) ) { | 102 | if ( !strncmp(logname, wt.ut_user, 8) ) { |
103 | t = (unsigned long) wt.ut_time; | 103 | t = (unsigned long) wt.ut_time; |
104 | #ifdef HAVE_HOST_IN_UTMP | ||
104 | if (bufsize > sizeof(wt.ut_host) + 1) | 105 | if (bufsize > sizeof(wt.ut_host) + 1) |
105 | bufsize = sizeof(wt.ut_host) + 1; | 106 | bufsize = sizeof(wt.ut_host) + 1; |
106 | strncpy(buf, wt.ut_host, bufsize - 1); | 107 | strncpy(buf, wt.ut_host, bufsize - 1); |
107 | buf[bufsize - 1] = 0; | 108 | buf[bufsize - 1] = 0; |
109 | #else /* HAVE_HOST_IN_UTMP */ | ||
110 | buf[0] = 0; | ||
111 | #endif /* HAVE_HOST_IN_UTMP */ | ||
108 | } | 112 | } |
109 | } | 113 | } |
110 | 114 | ||
@@ -113,7 +117,7 @@ get_last_login_time(uid_t uid, const char *logname, | |||
113 | } while (t == 0); | 117 | } while (t == 0); |
114 | 118 | ||
115 | return t; | 119 | return t; |
116 | #endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */ | 120 | #endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ |
117 | } | 121 | } |
118 | 122 | ||
119 | /* | 123 | /* |
@@ -125,10 +129,10 @@ void | |||
125 | record_login(int pid, const char *ttyname, const char *user, uid_t uid, | 129 | record_login(int pid, const char *ttyname, const char *user, uid_t uid, |
126 | const char *host, struct sockaddr_in * addr) | 130 | const char *host, struct sockaddr_in * addr) |
127 | { | 131 | { |
128 | #if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) | 132 | #if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) |
129 | struct lastlog ll; | 133 | struct lastlog ll; |
130 | char *lastlog; | 134 | char *lastlog; |
131 | #endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */ | 135 | #endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ |
132 | struct UTMP_STR u; | 136 | struct UTMP_STR u; |
133 | const char *utmp, *wtmp; | 137 | const char *utmp, *wtmp; |
134 | 138 | ||
@@ -152,7 +156,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, | |||
152 | 156 | ||
153 | login(&u); | 157 | login(&u); |
154 | 158 | ||
155 | #if defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) | 159 | #if defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) |
156 | lastlog = _PATH_LASTLOG; | 160 | lastlog = _PATH_LASTLOG; |
157 | 161 | ||
158 | /* Update lastlog unless actually recording a logout. */ | 162 | /* Update lastlog unless actually recording a logout. */ |
@@ -176,7 +180,7 @@ record_login(int pid, const char *ttyname, const char *user, uid_t uid, | |||
176 | close(fd); | 180 | close(fd); |
177 | } | 181 | } |
178 | } | 182 | } |
179 | #endif /* defined(HAVE_LASTLOG_H) && !defined(DISABLE_LASTLOG) */ | 183 | #endif /* defined(_PATH_LASTLOG) && !defined(DISABLE_LASTLOG) */ |
180 | } | 184 | } |
181 | 185 | ||
182 | /* Records that the user has logged out. */ | 186 | /* Records that the user has logged out. */ |