diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2002-04-02 22:35:35 +0200 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2002-04-02 22:35:35 +0200 |
commit | c447fee9f1e45e35bc8ca6d25fba26ad2a098f0d (patch) | |
tree | a3dccc0564993cc09d3fa5bb8705d840fafe984c /session.c | |
parent | - markus@cvs.openbsd.org 2002/03/28 15:34:51 (diff) | |
download | openssh-c447fee9f1e45e35bc8ca6d25fba26ad2a098f0d.tar.xz openssh-c447fee9f1e45e35bc8ca6d25fba26ad2a098f0d.zip |
- markus@cvs.openbsd.org 2002/03/29 18:59:32
[session.c session.h]
retrieve last login time before the pty is allocated, store per session
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -33,7 +33,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: session.c,v 1.133 2002/03/28 15:34:51 markus Exp $"); +RCSID("$OpenBSD: session.c,v 1.134 2002/03/29 18:59:31 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -619,10 +619,8 @@ void do_login(Session *s, const char *command) { char *time_string; - char hostname[MAXHOSTNAMELEN]; socklen_t fromlen; struct sockaddr_storage from; - time_t last_login_time; struct passwd * pw = s->pw; pid_t pid = getpid(); @@ -640,13 +638,6 @@ do_login(Session *s, const char *command) } } - /* Get the time and hostname when the user last logged in. */ - if (options.print_lastlog) { - hostname[0] = '\0'; - last_login_time = get_last_login_time(pw->pw_uid, pw->pw_name, - hostname, sizeof(hostname)); - } - /* Record that there was a login on that tty from the remote host. */ if (!use_privsep) record_login(pid, s->tty, pw->pw_name, pw->pw_uid, @@ -677,14 +668,15 @@ do_login(Session *s, const char *command) printf("%s\n", aixloginmsg); #endif /* WITH_AIXAUTHENTICATE */ - if (options.print_lastlog && last_login_time != 0) { - time_string = ctime(&last_login_time); + if (options.print_lastlog && s->last_login_time != 0) { + time_string = ctime(&s->last_login_time); if (strchr(time_string, '\n')) *strchr(time_string, '\n') = 0; - if (strcmp(hostname, "") == 0) + if (strcmp(s->hostname, "") == 0) printf("Last login: %s\r\n", time_string); else - printf("Last login: %s from %s\r\n", time_string, hostname); + printf("Last login: %s from %s\r\n", time_string, + s->hostname); } do_motd(); @@ -1442,6 +1434,12 @@ session_pty_req(Session *s) packet_disconnect("Protocol error: you already have a pty."); return 0; } + /* Get the time and hostname when the user last logged in. */ + if (options.print_lastlog) { + s->hostname[0] = '\0'; + s->last_login_time = get_last_login_time(s->pw->pw_uid, + s->pw->pw_name, s->hostname, sizeof(s->hostname)); + } s->term = packet_get_string(&len); |