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.12 by root, Wed Jan 19 15:20:47 2005 UTC vs.
Revision 1.15 by root, Wed Feb 16 21:21:43 2005 UTC

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
47int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
48void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
49void 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
71 struct passwd *pwent = getpwuid (getuid ()); 75 struct passwd *pwent = getpwuid (getuid ());
72 76
73 if (!strncmp (pty, "/dev/", 5)) 77 if (!strncmp (pty, "/dev/", 5))
74 pty += 5; /* skip /dev/ prefix */ 78 pty += 5; /* skip /dev/ prefix */
75 79
80#ifdef HAVE_UTMP_PID
76 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3)) 81 if (!strncmp (pty, "pty", 3) || !strncmp (pty, "tty", 3))
77 strncpy (ut_id, (pty + 3), sizeof (ut_id)); 82 strncpy (ut_id, pty + 3, sizeof (ut_id));
78#ifdef HAVE_UTMP_PID
79 else if (sscanf (pty, "pts/%d", &i) == 1) 83 else if (sscanf (pty, "pts/%d", &i) == 1)
80 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ 84 sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */
81#endif
82 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) 85 else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3))
83 { 86 {
84 rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); 87 rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty);
85 return; 88 return;
86 } 89 }
90#endif
87 91
88#ifdef HAVE_STRUCT_UTMP 92#ifdef HAVE_STRUCT_UTMP
89 memset (ut, 0, sizeof (struct utmp)); 93 memset (ut, 0, sizeof (struct utmp));
90# ifdef HAVE_UTMP_PID 94# ifdef HAVE_UTMP_PID
91 setutent (); 95 setutent ();
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 /*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines