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.28 by root, Tue Jan 17 10:19:13 2006 UTC vs.
Revision 1.32 by ayin, Wed Jan 18 08:40:44 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.
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_ptytty::login (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; 62 const char *pty = name;
63 63
64 if (!pty || !*pty) 64 if (!pty || !*pty)
65 return; 65 return;
163 endutxent (); /* close the file */ 163 endutxent (); /* close the file */
164 utmp_pos = 0; 164 utmp_pos = 0;
165#endif 165#endif
166 166
167#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID) 167#if defined(HAVE_STRUCT_UTMP) && !defined(HAVE_UTMP_PID)
168
169 { 168 {
170# ifdef HAVE_TTYSLOT 169# ifdef HAVE_TTYSLOT
170 int fdstdin = dup (STDIN_FILENO);
171 dup2 (pty->tty, STDIN_FILENO);
172
171 i = ttyslot (); 173 i = ttyslot ();
172 if (rxvt_write_bsd_utmp (i, ut)) 174 if (rxvt_write_bsd_utmp (i, ut))
173 utmp_pos = i; 175 utmp_pos = i;
176
177 dup2 (fdstdin, STDIN_FILENO);
178 close (fdstdin);
174# else 179# else
175 FILE *fd0; 180 FILE *fd0;
176 181
177 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL) 182 if ((fd0 = fopen (TTYTAB_FILENAME, "r")) != NULL)
178 { 183 {
179 char buf[256], name[256]; 184 char buf[256], name[256];
180 185
198# endif 203# endif
199 } 204 }
200#endif 205#endif
201 206
202#ifdef WTMP_SUPPORT 207#ifdef WTMP_SUPPORT
203# ifdef WTMP_ONLY_ON_LOGIN
204 if (login_shell) 208 if (login_shell)
205# endif
206 { 209 {
207# ifdef HAVE_STRUCT_UTMP 210# ifdef HAVE_STRUCT_UTMP
208# ifdef HAVE_UPDWTMP 211# ifdef HAVE_UPDWTMP
209 updwtmp (RXVT_WTMP_FILE, ut); 212 updwtmp (RXVT_WTMP_FILE, ut);
210# else 213# else
225/* ------------------------------------------------------------------------- */ 228/* ------------------------------------------------------------------------- */
226/* 229/*
227 * remove utmp and wtmp entries 230 * remove utmp and wtmp entries
228 */ 231 */
229void 232void
230rxvt_ptytty::logout () 233rxvt_ptytty_unix::logout ()
231{ 234{
232 if (!cmd_pid) 235 if (!cmd_pid)
233 return; 236 return;
234 237
235#ifdef HAVE_STRUCT_UTMP 238#ifdef HAVE_STRUCT_UTMP
274 277
275 /* 278 /*
276 * Write ending wtmp entry 279 * Write ending wtmp entry
277 */ 280 */
278#ifdef WTMP_SUPPORT 281#ifdef WTMP_SUPPORT
279# ifdef WTMP_ONLY_ON_LOGIN
280 if (login_shell) 282 if (login_shell)
281# endif
282 { 283 {
283# ifdef HAVE_STRUCT_UTMP 284# ifdef HAVE_STRUCT_UTMP
284# ifdef HAVE_UPDWTMP 285# ifdef HAVE_UPDWTMP
285 updwtmp (RXVT_WTMP_FILE, ut); 286 updwtmp (RXVT_WTMP_FILE, ut);
286# else 287# else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines