diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | session.c | 26 | ||||
-rw-r--r-- | session.h | 5 |
3 files changed, 20 insertions, 16 deletions
@@ -10,6 +10,9 @@ | |||
10 | - markus@cvs.openbsd.org 2002/03/28 15:34:51 | 10 | - markus@cvs.openbsd.org 2002/03/28 15:34:51 |
11 | [session.c] | 11 | [session.c] |
12 | do not call record_login twice (for use_privsep) | 12 | do not call record_login twice (for use_privsep) |
13 | - markus@cvs.openbsd.org 2002/03/29 18:59:32 | ||
14 | [session.c session.h] | ||
15 | retrieve last login time before the pty is allocated, store per session | ||
13 | 16 | ||
14 | 20020401 | 17 | 20020401 |
15 | - (stevesk) [monitor.c] PAM should work again; will *not* work with | 18 | - (stevesk) [monitor.c] PAM should work again; will *not* work with |
@@ -8117,4 +8120,4 @@ | |||
8117 | - Wrote replacements for strlcpy and mkdtemp | 8120 | - Wrote replacements for strlcpy and mkdtemp |
8118 | - Released 1.0pre1 | 8121 | - Released 1.0pre1 |
8119 | 8122 | ||
8120 | $Id: ChangeLog,v 1.2009 2002/04/02 20:32:46 mouring Exp $ | 8123 | $Id: ChangeLog,v 1.2010 2002/04/02 20:35:35 mouring Exp $ |
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.133 2002/03/28 15:34:51 markus Exp $"); | 36 | RCSID("$OpenBSD: session.c,v 1.134 2002/03/29 18:59:31 markus Exp $"); |
37 | 37 | ||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "ssh1.h" | 39 | #include "ssh1.h" |
@@ -619,10 +619,8 @@ void | |||
619 | do_login(Session *s, const char *command) | 619 | do_login(Session *s, const char *command) |
620 | { | 620 | { |
621 | char *time_string; | 621 | char *time_string; |
622 | char hostname[MAXHOSTNAMELEN]; | ||
623 | socklen_t fromlen; | 622 | socklen_t fromlen; |
624 | struct sockaddr_storage from; | 623 | struct sockaddr_storage from; |
625 | time_t last_login_time; | ||
626 | struct passwd * pw = s->pw; | 624 | struct passwd * pw = s->pw; |
627 | pid_t pid = getpid(); | 625 | pid_t pid = getpid(); |
628 | 626 | ||
@@ -640,13 +638,6 @@ do_login(Session *s, const char *command) | |||
640 | } | 638 | } |
641 | } | 639 | } |
642 | 640 | ||
643 | /* Get the time and hostname when the user last logged in. */ | ||
644 | if (options.print_lastlog) { | ||
645 | hostname[0] = '\0'; | ||
646 | last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, | ||
647 | hostname, sizeof(hostname)); | ||
648 | } | ||
649 | |||
650 | /* Record that there was a login on that tty from the remote host. */ | 641 | /* Record that there was a login on that tty from the remote host. */ |
651 | if (!use_privsep) | 642 | if (!use_privsep) |
652 | record_login(pid, s->tty, pw->pw_name, pw->pw_uid, | 643 | record_login(pid, s->tty, pw->pw_name, pw->pw_uid, |
@@ -677,14 +668,15 @@ do_login(Session *s, const char *command) | |||
677 | printf("%s\n", aixloginmsg); | 668 | printf("%s\n", aixloginmsg); |
678 | #endif /* WITH_AIXAUTHENTICATE */ | 669 | #endif /* WITH_AIXAUTHENTICATE */ |
679 | 670 | ||
680 | if (options.print_lastlog && last_login_time != 0) { | 671 | if (options.print_lastlog && s->last_login_time != 0) { |
681 | time_string = ctime(&last_login_time); | 672 | time_string = ctime(&s->last_login_time); |
682 | if (strchr(time_string, '\n')) | 673 | if (strchr(time_string, '\n')) |
683 | *strchr(time_string, '\n') = 0; | 674 | *strchr(time_string, '\n') = 0; |
684 | if (strcmp(hostname, "") == 0) | 675 | if (strcmp(s->hostname, "") == 0) |
685 | printf("Last login: %s\r\n", time_string); | 676 | printf("Last login: %s\r\n", time_string); |
686 | else | 677 | else |
687 | printf("Last login: %s from %s\r\n", time_string, hostname); | 678 | printf("Last login: %s from %s\r\n", time_string, |
679 | s->hostname); | ||
688 | } | 680 | } |
689 | 681 | ||
690 | do_motd(); | 682 | do_motd(); |
@@ -1442,6 +1434,12 @@ session_pty_req(Session *s) | |||
1442 | packet_disconnect("Protocol error: you already have a pty."); | 1434 | packet_disconnect("Protocol error: you already have a pty."); |
1443 | return 0; | 1435 | return 0; |
1444 | } | 1436 | } |
1437 | /* Get the time and hostname when the user last logged in. */ | ||
1438 | if (options.print_lastlog) { | ||
1439 | s->hostname[0] = '\0'; | ||
1440 | s->last_login_time = get_last_login_time(s->pw->pw_uid, | ||
1441 | s->pw->pw_name, s->hostname, sizeof(s->hostname)); | ||
1442 | } | ||
1445 | 1443 | ||
1446 | s->term = packet_get_string(&len); | 1444 | s->term = packet_get_string(&len); |
1447 | 1445 | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: session.h,v 1.16 2002/03/19 10:35:39 markus Exp $ */ | 1 | /* $OpenBSD: session.h,v 1.17 2002/03/29 18:59:32 markus Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. |
@@ -39,6 +39,9 @@ struct Session { | |||
39 | int ptyfd, ttyfd, ptymaster; | 39 | int ptyfd, ttyfd, ptymaster; |
40 | int row, col, xpixel, ypixel; | 40 | int row, col, xpixel, ypixel; |
41 | char tty[TTYSZ]; | 41 | char tty[TTYSZ]; |
42 | /* last login */ | ||
43 | char hostname[MAXHOSTNAMELEN]; | ||
44 | time_t last_login_time; | ||
42 | /* X11 */ | 45 | /* X11 */ |
43 | int display_number; | 46 | int display_number; |
44 | char *display; | 47 | char *display; |