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.13 by root, Fri Feb 4 04:16:05 2005 UTC vs.
Revision 1.16 by root, Wed Feb 16 21:37:10 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
47#if HAVE_STRUCT_UTMP
48int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu);
49void rxvt_update_wtmp (const char *fname, const struct utmp *putmp);
50#endif
51
52void rxvt_update_lastlog (const char *fname, const char *pty, const char *host);
53
47/* 54/*
48 * BSD style utmp entry 55 * BSD style utmp entry
49 * ut_line, ut_name, ut_host, ut_time 56 * ut_line, ut_name, ut_host, ut_time
50 * SYSV style utmp (and utmpx) entry 57 * SYSV style utmp (and utmpx) entry
51 * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time 58 * ut_user, ut_id, ut_line, ut_pid, ut_type, ut_exit, ut_time
133#ifdef HAVE_STRUCT_UTMPX 140#ifdef HAVE_STRUCT_UTMPX
134 strncpy (utx->ut_line, pty, sizeof (utx->ut_line)); 141 strncpy (utx->ut_line, pty, sizeof (utx->ut_line));
135 strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", 142 strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?",
136 sizeof (utx->ut_user)); 143 sizeof (utx->ut_user));
137 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 144 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
145# if HAVE_UTMPX_SESSION
138 utx->ut_session = getsid (0); 146 utx->ut_session = getsid (0);
147# endif
139 utx->ut_tv.tv_sec = time (NULL); 148 utx->ut_tv.tv_sec = time (NULL);
140 utx->ut_tv.tv_usec = 0; 149 utx->ut_tv.tv_usec = 0;
141 utx->ut_pid = cmd_pid; 150 utx->ut_pid = cmd_pid;
142# ifdef HAVE_UTMPX_HOST 151# ifdef HAVE_UTMPX_HOST
143 strncpy (utx->ut_host, hostname, sizeof (utx->ut_host)); 152 strncpy (utx->ut_host, hostname, sizeof (utx->ut_host));
204# else 213# else
205 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 214 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
206# endif 215# endif
207# endif 216# endif
208# ifdef HAVE_STRUCT_UTMPX 217# ifdef HAVE_STRUCT_UTMPX
218# if HAVE_UPDWTMPX
209 updwtmpx (RXVT_WTMPX_FILE, utx); 219 updwtmpx (RXVT_WTMPX_FILE, utx);
220# else
221 pututxline (utx);
222# endif
210# endif 223# endif
211 } 224 }
212#endif 225#endif
213#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) 226#if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE)
214 if (options & Opt_loginShell) 227 if (options & Opt_loginShell)
258 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 271 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
259 utx->ut_type = USER_PROCESS; 272 utx->ut_type = USER_PROCESS;
260 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */ 273 if ((tmputx = getutxid (utx))) /* position to entry in utmp file */
261 utx = tmputx; 274 utx = tmputx;
262 utx->ut_type = DEAD_PROCESS; 275 utx->ut_type = DEAD_PROCESS;
276# if HAVE_UTMPX_SESSION
263 utx->ut_session = getsid (0); 277 utx->ut_session = getsid (0);
278# endif
264 utx->ut_tv.tv_sec = time (NULL); 279 utx->ut_tv.tv_sec = time (NULL);
265 utx->ut_tv.tv_usec = 0; 280 utx->ut_tv.tv_usec = 0;
266#endif 281#endif
267 282
268 /* 283 /*
279# else 294# else
280 rxvt_update_wtmp (RXVT_WTMP_FILE, ut); 295 rxvt_update_wtmp (RXVT_WTMP_FILE, ut);
281# endif 296# endif
282# endif 297# endif
283# ifdef HAVE_STRUCT_UTMPX 298# ifdef HAVE_STRUCT_UTMPX
299# if HAVE_UPDWTMPX
284 updwtmpx (RXVT_WTMPX_FILE, utx); 300 updwtmpx (RXVT_WTMPX_FILE, utx);
301# else
302 pututxline (utx);
303# endif
285# endif 304# endif
286 } 305 }
287#endif 306#endif
288 307
289 /* 308 /*
309/* ------------------------------------------------------------------------- */ 328/* ------------------------------------------------------------------------- */
310/* 329/*
311 * Write a BSD style utmp entry 330 * Write a BSD style utmp entry
312 */ 331 */
313#ifdef HAVE_UTMP_H 332#ifdef HAVE_UTMP_H
314/* INTPROTO */
315int 333int
316rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) 334rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu)
317{ 335{
318 int fd; 336 int fd;
319 337
329 347
330/* ------------------------------------------------------------------------- */ 348/* ------------------------------------------------------------------------- */
331/* 349/*
332 * Update a BSD style wtmp entry 350 * Update a BSD style wtmp entry
333 */ 351 */
334#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) 352#if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP)
335/* INTPROTO */
336void 353void
337rxvt_update_wtmp (const char *fname, const struct utmp *putmp) 354rxvt_update_wtmp (const char *fname, const struct utmp *putmp)
338{ 355{
339 int fd, gotlock, retry; 356 int fd, gotlock, retry;
340 struct flock lck; /* fcntl locking scheme */ 357 struct flock lck; /* fcntl locking scheme */
372} 389}
373#endif 390#endif
374 391
375/* ------------------------------------------------------------------------- */ 392/* ------------------------------------------------------------------------- */
376#ifdef LASTLOG_SUPPORT 393#ifdef LASTLOG_SUPPORT
377/* INTPROTO */
378void 394void
379rxvt_update_lastlog (const char *fname, const char *pty, const char *host) 395rxvt_update_lastlog (const char *fname, const char *pty, const char *host)
380{ 396{
381# ifdef HAVE_STRUCT_LASTLOGX 397# ifdef HAVE_STRUCT_LASTLOGX
382 struct lastlogx llx; 398 struct lastlogx llx;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines