1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: logging.c |
2 | * File: logging.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
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 | * |
18 | * |
18 | * 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 |
19 | * 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 |
20 | * the Free Software Foundation; either version 2 of the License, or |
21 | * the Free Software Foundation; either version 2 of the License, or |
21 | * (at your option) any later version. |
22 | * (at your option) any later version. |
… | |
… | |
81 | else if (sscanf (pty, "pts/%d", &i) == 1) |
82 | else if (sscanf (pty, "pts/%d", &i) == 1) |
82 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
83 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
83 | #endif |
84 | #endif |
84 | else if (STRNCMP (pty, "pty", 3) && STRNCMP (pty, "tty", 3)) |
85 | else if (STRNCMP (pty, "pty", 3) && STRNCMP (pty, "tty", 3)) |
85 | { |
86 | { |
86 | rxvt_print_error ("can't parse tty name \"%s\"", pty); |
87 | rxvt_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); |
87 | return; |
88 | return; |
88 | } |
89 | } |
89 | |
90 | |
90 | #ifdef HAVE_STRUCT_UTMP |
91 | #ifdef HAVE_STRUCT_UTMP |
91 | MEMSET (ut, 0, sizeof (struct utmp)); |
92 | MEMSET (ut, 0, sizeof (struct utmp)); |
… | |
… | |
403 | |
404 | |
404 | # ifdef HAVE_STRUCT_LASTLOG |
405 | # ifdef HAVE_STRUCT_LASTLOG |
405 | pwent = getpwuid (getuid ()); |
406 | pwent = getpwuid (getuid ()); |
406 | if (!pwent) |
407 | if (!pwent) |
407 | { |
408 | { |
408 | rxvt_print_error ("no entry in password file"); |
409 | rxvt_warn ("no entry in password file, not updating lastlog.\n"); |
409 | return; |
410 | return; |
410 | } |
411 | } |
|
|
412 | |
411 | MEMSET (&ll, 0, sizeof (ll)); |
413 | MEMSET (&ll, 0, sizeof (ll)); |
412 | ll.ll_time = time (NULL); |
414 | ll.ll_time = time (NULL); |
413 | STRNCPY (ll.ll_line, pty, sizeof (ll.ll_line)); |
415 | STRNCPY (ll.ll_line, pty, sizeof (ll.ll_line)); |
414 | STRNCPY (ll.ll_host, host, sizeof (ll.ll_host)); |
416 | STRNCPY (ll.ll_host, host, sizeof (ll.ll_host)); |
415 | # ifdef LASTLOG_IS_DIR |
417 | # ifdef LASTLOG_IS_DIR |