|
|
1 | // This file is part of libptytty. Do not make local modifications. |
|
|
2 | // http://software.schmorp.de/pkg/libptytty |
|
|
3 | |
1 | /*--------------------------------*-C-*---------------------------------* |
4 | /*----------------------------------------------------------------------* |
2 | * File: logging.C |
5 | * File: logging.C |
3 | *----------------------------------------------------------------------* |
6 | *----------------------------------------------------------------------* |
4 | * |
7 | * |
5 | * All portions of code are copyright by their respective author/s. |
8 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey <jdb@ukc.ac.uk> |
9 | * Copyright (c) 1992 John Bovey <jdb@ukc.ac.uk> |
… | |
… | |
31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
32 | *----------------------------------------------------------------------*/ |
35 | *----------------------------------------------------------------------*/ |
33 | |
36 | |
34 | #include "../config.h" |
37 | #include "../config.h" |
35 | |
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 | |
36 | #include "ptytty.h" |
47 | #include "ptytty.h" |
37 | |
48 | |
38 | #if UTMP_SUPPORT |
49 | #if UTMP_SUPPORT |
39 | |
50 | |
40 | #if HAVE_STRUCT_UTMP |
51 | #if HAVE_STRUCT_UTMP |
… | |
… | |
84 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
95 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
85 | else if (sscanf (pty, "pts/%d", &i) == 1) |
96 | else if (sscanf (pty, "pts/%d", &i) == 1) |
86 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
97 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
87 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
98 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
88 | { |
99 | { |
89 | 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); |
90 | return; |
101 | return; |
91 | } |
102 | } |
92 | #endif |
103 | #endif |
93 | |
104 | |
94 | #ifdef HAVE_STRUCT_UTMP |
105 | #ifdef HAVE_STRUCT_UTMP |
… | |
… | |
414 | |
425 | |
415 | # ifdef HAVE_STRUCT_LASTLOG |
426 | # ifdef HAVE_STRUCT_LASTLOG |
416 | pwent = getpwuid (getuid ()); |
427 | pwent = getpwuid (getuid ()); |
417 | if (!pwent) |
428 | if (!pwent) |
418 | { |
429 | { |
419 | warn ("no entry in password file, not updating lastlog.\n"); |
430 | ptytty_warn ("no entry in password file, not updating lastlog.\n"); |
420 | return; |
431 | return; |
421 | } |
432 | } |
422 | |
433 | |
423 | memset (&ll, 0, sizeof (ll)); |
434 | memset (&ll, 0, sizeof (ll)); |
424 | ll.ll_time = time (NULL); |
435 | ll.ll_time = time (NULL); |
… | |
… | |
445 | } |
456 | } |
446 | # endif /* LASTLOG_IS_DIR */ |
457 | # endif /* LASTLOG_IS_DIR */ |
447 | # endif /* HAVE_STRUCT_LASTLOG */ |
458 | # endif /* HAVE_STRUCT_LASTLOG */ |
448 | } |
459 | } |
449 | #endif /* LASTLOG_SUPPORT */ |
460 | #endif /* LASTLOG_SUPPORT */ |
450 | /* ------------------------------------------------------------------------- */ |
|
|
451 | |
461 | |
452 | #else |
462 | #else |
453 | |
|
|
454 | void |
463 | void |
455 | ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) |
464 | ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) |
456 | { |
465 | { |
457 | } |
466 | } |
458 | |
|
|
459 | #endif |
467 | #endif |
460 | |
468 | |