ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/logging.C
(Generate patch)

Comparing rxvt-unicode/src/logging.C (file contents):
Revision 1.25 by root, Tue Jan 17 06:06:42 2006 UTC vs.
Revision 1.30 by root, Tue Jan 17 11:02:10 2006 UTC

12 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es> 12 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es>
13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
14 * - extensive modifications 14 * - extensive modifications
15 * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> 15 * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com>
16 * - lastlog support 16 * - lastlog support
17 * Copyright (c) 2004 Marc Lehmann <pcg@goof.com> 17 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com>
18 * 18 *
19 * This program is free software; you can redistribute it and/or modify 19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by 20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or 21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version. 22 * (at your option) any later version.
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
41static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); 41static int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
42static void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); 42static 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 */
59void 59void
60rxvt_session::login (const char *pty, int cmd_pid, bool login_shell, const char *hostname) 60rxvt_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 */
224void 229void
225rxvt_session::logout () 230rxvt_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 *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;
232#endif 240#endif
233 241
235# ifdef HAVE_UTMP_PID 243# ifdef HAVE_UTMP_PID
236 memset (ut, 0, sizeof (struct utmp)); 244 memset (ut, 0, sizeof (struct utmp));
237 setutent (); 245 setutent ();
238 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id)); 246 strncpy (ut->ut_id, this->ut_id, sizeof (ut->ut_id));
239 ut->ut_type = USER_PROCESS; 247 ut->ut_type = USER_PROCESS;
240 {
241 struct utmp *tmput = getutid (ut);
242
243 if (tmput) /* position to entry in utmp file */ 248 if ((tmput = getutid (ut))) /* position to entry in utmp file */
244 ut = tmput; 249 ut = tmput;
245 }
246 ut->ut_type = DEAD_PROCESS; 250 ut->ut_type = DEAD_PROCESS;
247# else 251# else
248 memset (ut->ut_name, 0, sizeof (ut->ut_name)); 252 memset (ut->ut_name, 0, sizeof (ut->ut_name));
249# ifdef HAVE_UTMP_HOST 253# ifdef HAVE_UTMP_HOST
250 memset (ut->ut_host, 0, sizeof (ut->ut_host)); 254 memset (ut->ut_host, 0, sizeof (ut->ut_host));
305#ifdef HAVE_STRUCT_UTMPX 309#ifdef HAVE_STRUCT_UTMPX
306 if (utx->ut_pid == cmd_pid) 310 if (utx->ut_pid == cmd_pid)
307 pututxline (utx); 311 pututxline (utx);
308 endutxent (); 312 endutxent ();
309#endif 313#endif
314
315 cmd_pid = 0;
310} 316}
311 317
312/* ------------------------------------------------------------------------- */ 318/* ------------------------------------------------------------------------- */
313/* 319/*
314 * Write a BSD style utmp entry 320 * Write a BSD style utmp entry

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines