Bug 84 - last command provides incorrect information on Solaris 8
Summary: last command provides incorrect information on Solaris 8
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: -current
Hardware: UltraSPARC Solaris
: P2 normal
Assignee: OpenSSH Bugzilla mailing list
URL:
Keywords:
: 122 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-01-30 06:57 AEDT by William Knox
Modified: 2004-04-14 12:24 AEST (History)
2 users (show)

See Also:


Attachments
Patch as attachment for easier use (2.01 KB, patch)
2002-02-14 07:27 AEDT, William Knox
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description William Knox 2002-01-30 06:57:13 AEDT
The utmpx entry done upon logout from ssh does not contain all the fields that
the login record does - this prevents the last command from working properly on
Solaris 8. I have created a patch to correct this (attached below). The problem
with last without this patch exhibits itself when you run "last username" -
entries come up indicating that you are still logged in because the last command
cannot find the logout for that login (it looks for an entry with the same
username, which is not being used in the logout utmpx entries currently). The
patch, which is against 3.0.2p1, merely puts all the same information into the
utmpx entry for both a login and a logout. This bugzilla entry duplicates an
e-mail I sent in in late November, in case this comes up as a duplicate of a
known issue.

--- loginrec.c~ Mon Oct 29 21:50:40 2001
+++ loginrec.c  Tue Jan 29 10:56:59 2002
@@ -701,6 +701,7 @@
        line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line));
        set_utmpx_time(li, utx);
        utx->ut_pid = li->pid;
+       strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name,
li->username));
 
        if (li->type == LTYPE_LOGOUT)
                return;
@@ -711,7 +712,6 @@
         */
 
        /* strncpy(): Don't necessarily want null termination */
-       strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name,
li->username));
 # ifdef HAVE_HOST_IN_UTMPX
        strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host,
li->hostname));
 # endif
@@ -942,9 +942,7 @@
 {
        struct utmpx utx;
 
-       memset(&utx, '\0', sizeof(utx));
-       set_utmpx_time(li, &utx);
-       line_stripname(utx.ut_line, li->line, sizeof(utx.ut_line));
+       construct_utmpx(li, &utx);
 # ifdef HAVE_ID_IN_UTMPX
        line_abbrevname(utx.ut_id, li->line, sizeof(utx.ut_id));
 # endif
--- session.c~  Sat Dec  1 18:37:08 2001
+++ session.c   Tue Jan 29 10:56:59 2002
@@ -1866,7 +1866,7 @@
 
        /* Record that the user has logged out. */
        if (s->pid != 0)
-               record_logout(s->pid, s->tty);
+               record_logout(s->pid, s->tty, s->pw->pw_name);
 
        /* Release the pseudo-tty. */
        pty_release(s->tty);
--- sshlogin.c~ Tue May  8 16:33:06 2001
+++ sshlogin.c  Tue Jan 29 10:56:59 2002
@@ -94,11 +94,11 @@
 /* Records that the user has logged out. */
 
 void
-record_logout(pid_t pid, const char *ttyname)
+record_logout(pid_t pid, const char *ttyname, const char *user)
 {
   struct logininfo *li;
 
-  li = login_alloc_entry(pid, NULL, NULL, ttyname);
+  li = login_alloc_entry(pid, user, NULL, ttyname);
   login_logout(li);
   login_free_entry(li);
 }
--- sshlogin.h~ Wed Jul  4 00:46:58 2001
+++ sshlogin.h  Tue Jan 29 10:56:59 2002
@@ -17,7 +17,7 @@
 void
 record_login(pid_t, const char *, const char *, uid_t,
     const char *, struct sockaddr *);
-void   record_logout(pid_t, const char *);
+void   record_logout(pid_t, const char *, const char *);
 u_long         get_last_login_time(uid_t, const char *, char *, u_int);
 
 #endif
Comment 1 William Knox 2002-02-14 07:27:53 AEDT
Created attachment 26 [details]
Patch as attachment for easier use
Comment 2 Tim Rice 2002-02-25 06:02:19 AEDT
*** Bug 122 has been marked as a duplicate of this bug. ***
Comment 3 Tim Rice 2002-02-25 13:03:46 AEDT
The patch works (thanks) and doesn't seem to break other platforms I've tested
so I'm commiting the patch to CVS.
Comment 4 Damien Miller 2002-10-16 13:08:57 AEST
*** Bug 301 has been marked as a duplicate of this bug. ***
Comment 5 Damien Miller 2004-04-14 12:24:17 AEST
Mass change of RESOLVED bugs to CLOSED