|
|
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> |
… | |
… | |
13 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
16 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * - extensive modifications |
17 | * - extensive modifications |
15 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
18 | * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> |
16 | * - lastlog support |
19 | * - lastlog support |
17 | * 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> |
18 | * |
22 | * |
19 | * 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 |
20 | * 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 |
21 | * the Free Software Foundation; either version 2 of the License, or |
25 | * the Free Software Foundation; either version 2 of the License, or |
22 | * (at your option) any later version. |
26 | * (at your option) any later version. |
… | |
… | |
31 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
32 | *----------------------------------------------------------------------*/ |
36 | *----------------------------------------------------------------------*/ |
33 | |
37 | |
34 | #include "../config.h" |
38 | #include "../config.h" |
35 | |
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 | |
36 | #include "ptytty.h" |
48 | #include "ptytty.h" |
37 | |
49 | |
38 | #if UTMP_SUPPORT |
50 | #if UTMP_SUPPORT |
39 | |
51 | |
40 | #if HAVE_STRUCT_UTMP |
52 | #if HAVE_STRUCT_UTMP |
… | |
… | |
84 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
96 | strncpy (ut_id, pty + 3, sizeof (ut_id)); |
85 | else if (sscanf (pty, "pts/%d", &i) == 1) |
97 | else if (sscanf (pty, "pts/%d", &i) == 1) |
86 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
98 | sprintf (ut_id, "vt%02x", (i & 0xff)); /* sysv naming */ |
87 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
99 | else if (strncmp (pty, "pty", 3) && strncmp (pty, "tty", 3)) |
88 | { |
100 | { |
89 | 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); |
90 | return; |
102 | return; |
91 | } |
103 | } |
92 | #endif |
104 | #endif |
93 | |
105 | |
94 | #ifdef HAVE_STRUCT_UTMP |
106 | #ifdef HAVE_STRUCT_UTMP |
… | |
… | |
414 | |
426 | |
415 | # ifdef HAVE_STRUCT_LASTLOG |
427 | # ifdef HAVE_STRUCT_LASTLOG |
416 | pwent = getpwuid (getuid ()); |
428 | pwent = getpwuid (getuid ()); |
417 | if (!pwent) |
429 | if (!pwent) |
418 | { |
430 | { |
419 | warn ("no entry in password file, not updating lastlog.\n"); |
431 | ptytty_warn ("no entry in password file, not updating lastlog.\n"); |
420 | return; |
432 | return; |
421 | } |
433 | } |
422 | |
434 | |
423 | memset (&ll, 0, sizeof (ll)); |
435 | memset (&ll, 0, sizeof (ll)); |
424 | ll.ll_time = time (NULL); |
436 | ll.ll_time = time (NULL); |
… | |
… | |
445 | } |
457 | } |
446 | # endif /* LASTLOG_IS_DIR */ |
458 | # endif /* LASTLOG_IS_DIR */ |
447 | # endif /* HAVE_STRUCT_LASTLOG */ |
459 | # endif /* HAVE_STRUCT_LASTLOG */ |
448 | } |
460 | } |
449 | #endif /* LASTLOG_SUPPORT */ |
461 | #endif /* LASTLOG_SUPPORT */ |
450 | /* ------------------------------------------------------------------------- */ |
|
|
451 | |
462 | |
452 | #else |
463 | #else |
453 | |
|
|
454 | void |
464 | void |
455 | ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) |
465 | ptytty_unix::login (int cmd_pid, bool login_shell, const char *hostname) |
456 | { |
466 | { |
457 | } |
467 | } |
458 | |
|
|
459 | #endif |
468 | #endif |
460 | |
469 | |