]> andersk Git - openssh.git/commitdiff
- markus@cvs.openbsd.org 2002/03/29 18:59:32
authormouring <mouring>
Tue, 2 Apr 2002 20:35:35 +0000 (20:35 +0000)
committermouring <mouring>
Tue, 2 Apr 2002 20:35:35 +0000 (20:35 +0000)
     [session.c session.h]
     retrieve last login time before the pty is allocated, store per session

ChangeLog
session.c
session.h

index a8f515d51d0c46551428d78efe679e8c01fade86..1e9318188e1fc1e18fc1b0f16114f665eecd554e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,9 @@
    - markus@cvs.openbsd.org 2002/03/28 15:34:51
      [session.c]
      do not call record_login twice (for use_privsep)
+   - 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
 
 20020401
  - (stevesk) [monitor.c] PAM should work again; will *not* work with
index 3daddbe11a0c2f2e80c8f1817733ce75d4f35b3f..6be7f99296fdc93c4c1d307d92746724e2538360 100644 (file)
--- a/session.c
+++ b/session.c
@@ -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);
 
index fad3abe1ca28c7d957fccf3c6bf63ff0b36753e2..2a7e4b224fd475d2c839497eb90683eda2999a85 100644 (file)
--- a/session.h
+++ b/session.h
@@ -1,4 +1,4 @@
-/*     $OpenBSD: session.h,v 1.16 2002/03/19 10:35:39 markus Exp $     */
+/*     $OpenBSD: session.h,v 1.17 2002/03/29 18:59:32 markus Exp $     */
 
 /*
  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
@@ -39,6 +39,9 @@ struct Session {
        int     ptyfd, ttyfd, ptymaster;
        int     row, col, xpixel, ypixel;
        char    tty[TTYSZ];
+       /* last login */
+       char    hostname[MAXHOSTNAMELEN];
+       time_t  last_login_time;
        /* X11 */
        int     display_number;
        char    *display;
This page took 0.081491 seconds and 5 git commands to generate.