… | |
… | |
31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
32 | *----------------------------------------------------------------------*/ |
32 | *----------------------------------------------------------------------*/ |
33 | |
33 | |
34 | #include "../config.h" |
34 | #include "../config.h" |
35 | #include "rxvt.h" |
35 | #include "rxvt.h" |
36 | #include "logging.h" |
36 | #include "ptytty.h" |
37 | |
37 | |
38 | #ifdef UTMP_SUPPORT |
38 | #if UTMP_SUPPORT |
39 | |
39 | |
40 | #if HAVE_STRUCT_UTMP |
40 | #if HAVE_STRUCT_UTMP |
41 | static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); |
41 | static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); |
42 | static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); |
42 | static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); |
43 | #endif |
43 | #endif |
… | |
… | |
55 | |
55 | |
56 | /* |
56 | /* |
57 | * make and write utmp and wtmp entries |
57 | * make and write utmp and wtmp entries |
58 | */ |
58 | */ |
59 | void |
59 | void |
60 | rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname) |
60 | rxvt_ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) |
61 | { |
61 | { |
|
|
62 | const char *pty = name; |
|
|
63 | |
|
|
64 | if (!pty || !*pty) |
|
|
65 | return; |
|
|
66 | |
62 | this->cmd_pid = cmd_pid; |
67 | this->cmd_pid = cmd_pid; |
63 | this->login_shell = login_shell; |
68 | this->login_shell = login_shell; |
64 | |
69 | |
65 | #ifdef HAVE_STRUCT_UTMP |
70 | #ifdef HAVE_STRUCT_UTMP |
66 | struct utmp *ut = &this->ut; |
71 | struct utmp *ut = &this->ut; |
… | |
… | |
220 | /* ------------------------------------------------------------------------- */ |
225 | /* ------------------------------------------------------------------------- */ |
221 | /* |
226 | /* |
222 | * remove utmp and wtmp entries |
227 | * remove utmp and wtmp entries |
223 | */ |
228 | */ |
224 | void |
229 | void |
225 | rxvt_session::logout () |
230 | rxvt_ptytty_unix::logout () |
226 | { |
231 | { |
|
|
232 | if (!cmd_pid) |
|
|
233 | return; |
|
|
234 | |
227 | #ifdef HAVE_STRUCT_UTMP |
235 | #ifdef HAVE_STRUCT_UTMP |
228 | struct utmp *tmput, *ut = &this->ut; |
236 | struct utmp *tmput, *ut = &this->ut; |
229 | #endif |
237 | #endif |
230 | #ifdef HAVE_STRUCT_UTMPX |
238 | #ifdef HAVE_STRUCT_UTMPX |
231 | struct utmpx *tmputx, *utx = &this->utx; |
239 | struct utmpx *tmputx, *utx = &this->utx; |
… | |
… | |
301 | #ifdef HAVE_STRUCT_UTMPX |
309 | #ifdef HAVE_STRUCT_UTMPX |
302 | if (utx->ut_pid == cmd_pid) |
310 | if (utx->ut_pid == cmd_pid) |
303 | pututxline (utx); |
311 | pututxline (utx); |
304 | endutxent (); |
312 | endutxent (); |
305 | #endif |
313 | #endif |
|
|
314 | |
|
|
315 | cmd_pid = 0; |
306 | } |
316 | } |
307 | |
317 | |
308 | /* ------------------------------------------------------------------------- */ |
318 | /* ------------------------------------------------------------------------- */ |
309 | /* |
319 | /* |
310 | * Write a BSD style utmp entry |
320 | * Write a BSD style utmp entry |