… | |
… | |
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 | *----------------------------------------------------------------------*/ |
35 | *----------------------------------------------------------------------*/ |
36 | |
36 | |
37 | #include "../config.h" |
37 | #include "../config.h" |
38 | |
38 | |
|
|
39 | #include <cstdio> |
|
|
40 | |
|
|
41 | #include <sys/types.h> |
|
|
42 | #include <sys/stat.h> |
|
|
43 | #include <sys/fcntl.h> |
|
|
44 | #include <unistd.h> |
|
|
45 | #include <time.h> |
|
|
46 | |
39 | #include "ptytty.h" |
47 | #include "ptytty.h" |
40 | |
48 | |
41 | #if UTMP_SUPPORT |
49 | #if UTMP_SUPPORT |
42 | |
50 | |
43 | #if HAVE_STRUCT_UTMP |
51 | #if HAVE_STRUCT_UTMP |
… | |
… | |
87 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
95 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
88 | else if (sscanf (pty, "pts/%d", &i) == 1) |
96 | else if (sscanf (pty, "pts/%d", &i) == 1) |
89 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
97 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
90 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
98 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
91 | { |
99 | { |
92 | warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); |
100 | ptytty_warn ("can't parse tty name \"%s\", not adding utmp entry.\n", pty); |
93 | return; |
101 | return; |
94 | } |
102 | } |
95 | #endif |
103 | #endif |
96 | |
104 | |
97 | #ifdef HAVE_STRUCT_UTMP |
105 | #ifdef HAVE_STRUCT_UTMP |
… | |
… | |
417 | |
425 | |
418 | # ifdef HAVE_STRUCT_LASTLOG |
426 | # ifdef HAVE_STRUCT_LASTLOG |
419 | pwent = getpwuid (getuid ()); |
427 | pwent = getpwuid (getuid ()); |
420 | if (!pwent) |
428 | if (!pwent) |
421 | { |
429 | { |
422 | warn ("no entry in password file, not updating lastlog.\n"); |
430 | ptytty_warn ("no entry in password file, not updating lastlog.\n"); |
423 | return; |
431 | return; |
424 | } |
432 | } |
425 | |
433 | |
426 | memset (&ll, 0, sizeof (ll)); |
434 | memset (&ll, 0, sizeof (ll)); |
427 | ll.ll_time = time (NULL); |
435 | ll.ll_time = time (NULL); |