diff options
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -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 | ||