… | |
… | |
16 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
16 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
17 | * - extensive modifications |
17 | * - extensive modifications |
18 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
18 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
19 | * - lastlog support |
19 | * - lastlog support |
20 | * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> |
20 | * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> |
|
|
21 | * Copyright (c) 2006 Emanuele Giaquinta <e.giaquinta@glauco.it> |
21 | * |
22 | * |
22 | * This program is free software; you can redistribute it and/or modify |
23 | * This program is free software; you can redistribute it and/or modify |
23 | * it under the terms of the GNU General Public License as published by |
24 | * it under the terms of the GNU General Public License as published by |
24 | * the Free Software Foundation; either version 2 of the License, or |
25 | * the Free Software Foundation; either version 2 of the License, or |
25 | * (at your option) any later version. |
26 | * (at your option) any later version. |
… | |
… | |
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 | *----------------------------------------------------------------------*/ |
36 | *----------------------------------------------------------------------*/ |
36 | |
37 | |
37 | #include "../config.h" |
38 | #include "../config.h" |
38 | |
39 | |
|
|
40 | #include <cstdio> |
|
|
41 | |
|
|
42 | #include <sys/types.h> |
|
|
43 | #include <sys/stat.h> |
|
|
44 | #include <sys/fcntl.h> |
|
|
45 | #include <unistd.h> |
|
|
46 | #include <time.h> |
|
|
47 | |
39 | #include "ptytty.h" |
48 | #include "ptytty.h" |
40 | |
49 | |
41 | #if UTMP_SUPPORT |
50 | #if UTMP_SUPPORT |
42 | |
51 | |
43 | #if HAVE_STRUCT_UTMP |
52 | #if HAVE_STRUCT_UTMP |
… | |
… | |
87 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
96 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
88 | else if (sscanf (pty, "pts/%d", &i) == 1) |
97 | else if (sscanf (pty, "pts/%d", &i) == 1) |
89 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
98 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
90 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
99 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
91 | { |
100 | { |
92 | warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); |
101 | ptytty_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); |
93 | return; |
102 | return; |
94 | } |
103 | } |
95 | #endif |
104 | #endif |
96 | |
105 | |
97 | #ifdef HAVE_STRUCT_UTMP |
106 | #ifdef HAVE_STRUCT_UTMP |
… | |
… | |
417 | |
426 | |
418 | # ifdef HAVE_STRUCT_LASTLOG |
427 | # ifdef HAVE_STRUCT_LASTLOG |
419 | pwent = getpwuid (getuid ()); |
428 | pwent = getpwuid (getuid ()); |
420 | if (!pwent) |
429 | if (!pwent) |
421 | { |
430 | { |
422 | warn ("no entry in password file, not updating lastlog.\n"); |
431 | ptytty_warn ("no entry in password file, not updating lastlog.\n"); |
423 | return; |
432 | return; |
424 | } |
433 | } |
425 | |
434 | |
426 | memset (&ll, 0, sizeof (ll)); |
435 | memset (&ll, 0, sizeof (ll)); |
427 | ll.ll_time = time (NULL); |
436 | ll.ll_time = time (NULL); |