… | |
… | |
42 | #include "../config.h" /* NECESSARY */ |
42 | #include "../config.h" /* NECESSARY */ |
43 | #include "rxvt.h" /* NECESSARY */ |
43 | #include "rxvt.h" /* NECESSARY */ |
44 | #include "logging.h" |
44 | #include "logging.h" |
45 | #ifdef UTMP_SUPPORT |
45 | #ifdef UTMP_SUPPORT |
46 | |
46 | |
|
|
47 | int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); |
|
|
48 | void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); |
|
|
49 | void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); |
|
|
50 | |
47 | /* |
51 | /* |
48 | * BSD style utmp entry |
52 | * BSD style utmp entry |
49 | * ut_line, ut_name, ut_host, ut_time |
53 | * ut_line, ut_name, ut_host, ut_time |
50 | * SYSV style utmp (and utmpx) entry |
54 | * SYSV style utmp (and utmpx) entry |
51 | * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time |
55 | * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time |
… | |
… | |
133 | #ifdef HAVE_STRUCT_UTMPX |
137 | #ifdef HAVE_STRUCT_UTMPX |
134 | strncpy (utx->ut_line, pty, sizeof (utx->ut_line)); |
138 | strncpy (utx->ut_line, pty, sizeof (utx->ut_line)); |
135 | strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", |
139 | strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", |
136 | sizeof (utx->ut_user)); |
140 | sizeof (utx->ut_user)); |
137 | strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); |
141 | strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); |
|
|
142 | # if HAVE_UTMPX_SESSION |
138 | utx->ut_session = getsid (0); |
143 | utx->ut_session = getsid (0); |
|
|
144 | # endif |
139 | utx->ut_tv.tv_sec = time (NULL); |
145 | utx->ut_tv.tv_sec = time (NULL); |
140 | utx->ut_tv.tv_usec = 0; |
146 | utx->ut_tv.tv_usec = 0; |
141 | utx->ut_pid = cmd_pid; |
147 | utx->ut_pid = cmd_pid; |
142 | # ifdef HAVE_UTMPX_HOST |
148 | # ifdef HAVE_UTMPX_HOST |
143 | strncpy (utx->ut_host, hostname, sizeof (utx->ut_host)); |
149 | strncpy (utx->ut_host, hostname, sizeof (utx->ut_host)); |
… | |
… | |
204 | # else |
210 | # else |
205 | rxvt_update_wtmp (RXVT_WTMP_FILE, ut); |
211 | rxvt_update_wtmp (RXVT_WTMP_FILE, ut); |
206 | # endif |
212 | # endif |
207 | # endif |
213 | # endif |
208 | # ifdef HAVE_STRUCT_UTMPX |
214 | # ifdef HAVE_STRUCT_UTMPX |
|
|
215 | # if HAVE_UPDWTMPX |
209 | updwtmpx (RXVT_WTMPX_FILE, utx); |
216 | updwtmpx (RXVT_WTMPX_FILE, utx); |
|
|
217 | # endif |
210 | # endif |
218 | # endif |
211 | } |
219 | } |
212 | #endif |
220 | #endif |
213 | #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) |
221 | #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) |
214 | if (options & Opt_loginShell) |
222 | if (options & Opt_loginShell) |
… | |
… | |
258 | strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); |
266 | strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); |
259 | utx->ut_type = USER_PROCESS; |
267 | utx->ut_type = USER_PROCESS; |
260 | if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ |
268 | if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ |
261 | utx = tmputx; |
269 | utx = tmputx; |
262 | utx->ut_type = DEAD_PROCESS; |
270 | utx->ut_type = DEAD_PROCESS; |
|
|
271 | # if HAVE_UTMPX_SESSION |
263 | utx->ut_session = getsid (0); |
272 | utx->ut_session = getsid (0); |
|
|
273 | # endif |
264 | utx->ut_tv.tv_sec = time (NULL); |
274 | utx->ut_tv.tv_sec = time (NULL); |
265 | utx->ut_tv.tv_usec = 0; |
275 | utx->ut_tv.tv_usec = 0; |
266 | #endif |
276 | #endif |
267 | |
277 | |
268 | /* |
278 | /* |
… | |
… | |
279 | # else |
289 | # else |
280 | rxvt_update_wtmp (RXVT_WTMP_FILE, ut); |
290 | rxvt_update_wtmp (RXVT_WTMP_FILE, ut); |
281 | # endif |
291 | # endif |
282 | # endif |
292 | # endif |
283 | # ifdef HAVE_STRUCT_UTMPX |
293 | # ifdef HAVE_STRUCT_UTMPX |
|
|
294 | # if HAVE_UPDWTMPX |
284 | updwtmpx (RXVT_WTMPX_FILE, utx); |
295 | updwtmpx (RXVT_WTMPX_FILE, utx); |
|
|
296 | # endif |
285 | # endif |
297 | # endif |
286 | } |
298 | } |
287 | #endif |
299 | #endif |
288 | |
300 | |
289 | /* |
301 | /* |