… | |
… | |
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 |
47 | int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); |
48 | int rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu); |
48 | void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); |
49 | void rxvt_update_wtmp (const char *fname, const struct utmp *putmp); |
|
|
50 | #endif |
|
|
51 | |
49 | void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); |
52 | void rxvt_update_lastlog (const char *fname, const char *pty, const char *host); |
50 | |
53 | |
51 | /* |
54 | /* |
52 | * BSD style utmp entry |
55 | * BSD style utmp entry |
53 | * ut_line, ut_name, ut_host, ut_time |
56 | * ut_line, ut_name, ut_host, ut_time |
… | |
… | |
70 | struct utmpx *utx = &this->utx; |
73 | struct utmpx *utx = &this->utx; |
71 | #endif |
74 | #endif |
72 | #ifdef HAVE_UTMP_PID |
75 | #ifdef HAVE_UTMP_PID |
73 | int i; |
76 | int i; |
74 | #endif |
77 | #endif |
75 | struct passwd *pwent = getpwuid (getuid ()); |
78 | struct passwd *pwent = getpwuid (getuid ()); |
76 | |
79 | |
77 | if (!strncmp (pty, "/dev/", 5)) |
80 | if (!strncmp (pty, "/dev/", 5)) |
78 | pty += 5; /* skip /dev/ prefix */ |
81 | pty += 5; /* skip /dev/ prefix */ |
79 | |
82 | |
80 | #ifdef HAVE_UTMP_PID |
83 | #ifdef HAVE_UTMP_PID |
… | |
… | |
212 | # endif |
215 | # endif |
213 | # endif |
216 | # endif |
214 | # ifdef HAVE_STRUCT_UTMPX |
217 | # ifdef HAVE_STRUCT_UTMPX |
215 | # if HAVE_UPDWTMPX |
218 | # if HAVE_UPDWTMPX |
216 | updwtmpx (RXVT_WTMPX_FILE, utx); |
219 | updwtmpx (RXVT_WTMPX_FILE, utx); |
|
|
220 | # else |
|
|
221 | pututxline (utx); |
217 | # endif |
222 | # endif |
218 | # endif |
223 | # endif |
219 | } |
224 | } |
220 | #endif |
225 | #endif |
221 | #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) |
226 | #if defined(LASTLOG_SUPPORT) && defined(RXVT_LASTLOG_FILE) |
… | |
… | |
291 | # endif |
296 | # endif |
292 | # endif |
297 | # endif |
293 | # ifdef HAVE_STRUCT_UTMPX |
298 | # ifdef HAVE_STRUCT_UTMPX |
294 | # if HAVE_UPDWTMPX |
299 | # if HAVE_UPDWTMPX |
295 | updwtmpx (RXVT_WTMPX_FILE, utx); |
300 | updwtmpx (RXVT_WTMPX_FILE, utx); |
|
|
301 | # else |
|
|
302 | pututxline (utx); |
296 | # endif |
303 | # endif |
297 | # endif |
304 | # endif |
298 | } |
305 | } |
299 | #endif |
306 | #endif |
300 | |
307 | |
… | |
… | |
321 | /* ------------------------------------------------------------------------- */ |
328 | /* ------------------------------------------------------------------------- */ |
322 | /* |
329 | /* |
323 | * Write a BSD style utmp entry |
330 | * Write a BSD style utmp entry |
324 | */ |
331 | */ |
325 | #ifdef HAVE_UTMP_H |
332 | #ifdef HAVE_UTMP_H |
326 | /* INTPROTO */ |
|
|
327 | int |
333 | int |
328 | rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) |
334 | rxvt_write_bsd_utmp (int utmp_pos, struct utmp *wu) |
329 | { |
335 | { |
330 | int fd; |
336 | int fd; |
331 | |
337 | |
… | |
… | |
341 | |
347 | |
342 | /* ------------------------------------------------------------------------- */ |
348 | /* ------------------------------------------------------------------------- */ |
343 | /* |
349 | /* |
344 | * Update a BSD style wtmp entry |
350 | * Update a BSD style wtmp entry |
345 | */ |
351 | */ |
346 | #if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) |
352 | #if defined(WTMP_SUPPORT) && !defined(HAVE_UPDWTMP) && defined(HAVE_STRUCT_UTMP) |
347 | /* INTPROTO */ |
|
|
348 | void |
353 | void |
349 | rxvt_update_wtmp (const char *fname, const struct utmp *putmp) |
354 | rxvt_update_wtmp (const char *fname, const struct utmp *putmp) |
350 | { |
355 | { |
351 | int fd, gotlock, retry; |
356 | int fd, gotlock, retry; |
352 | struct flock lck; /* fcntl locking scheme */ |
357 | struct flock lck; /* fcntl locking scheme */ |
… | |
… | |
384 | } |
389 | } |
385 | #endif |
390 | #endif |
386 | |
391 | |
387 | /* ------------------------------------------------------------------------- */ |
392 | /* ------------------------------------------------------------------------- */ |
388 | #ifdef LASTLOG_SUPPORT |
393 | #ifdef LASTLOG_SUPPORT |
389 | /* INTPROTO */ |
|
|
390 | void |
394 | void |
391 | rxvt_update_lastlog (const char *fname, const char *pty, const char *host) |
395 | rxvt_update_lastlog (const char *fname, const char *pty, const char *host) |
392 | { |
396 | { |
393 | # ifdef HAVE_STRUCT_LASTLOGX |
397 | # ifdef HAVE_STRUCT_LASTLOGX |
394 | struct lastlogx llx; |
398 | struct lastlogx llx; |