From nobody@FreeBSD.org  Sun May 20 18:21:30 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 498E937B424
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 20 May 2001 18:21:30 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.1/8.11.1) id f4L1LUt08681;
	Sun, 20 May 2001 18:21:30 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200105210121.f4L1LUt08681@freefall.freebsd.org>
Date: Sun, 20 May 2001 18:21:30 -0700 (PDT)
To: freebsd-gnats-submit@FreeBSD.org
Subject: /var/log/wtmp is not updated on logout
X-Send-Pr-Version: www-1.0

>Number:         27482
>Category:       bin
>Synopsis:       /var/log/wtmp is not updated on logout
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 20 18:30:01 PDT 2001
>Closed-Date:    Tue Aug 21 04:48:31 PDT 2001
>Last-Modified:  Tue Aug 21 06:07:52 PDT 2001
>Originator:     christian
>Release:        4.3-RELEASE
>Organization:
>Environment:
FreeBSD hp0.pacbell.net 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Mon Apr 30 12:47:33 PDT 2001     root@hp0.pacbell.net:/usr/src/sys/compile/HP9780C-LITE  i386
>Description:
the wtmp log is not always updated when you log out.
it does get updated if you use login(1) from the console (ttyv*).
it does get updated if you use telnet from anywhere.
it does not get updated if you use login(1) from an xterm.
so, even when no one is logged on, last(1) reports that many
users are "still logged in".

>How-To-Repeat:
run "xterm -e login".
log in.
run last(1) to verify that wtmp thinks you are logged in.
log out.
run last(1) to verify that wtmp does not realize you logged out.
it will say you are "still logged in".

>Fix:
not sure...
login(1) writes the log-in wtmp entry.
and normally init(8) writes the log-out entry.
but if you're running login from an xterm... how is init(8)
going to find out about the logout?

>Release-Note:
>Audit-Trail:

From: Ruslan Ermilov <ru@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/27482: /var/log/wtmp is not updated on logout
Date: Mon, 21 May 2001 13:17:14 +0300

 The following patch fixes at least the case where you:
 
 1.  login to a tty (1st wtmp `login' mark is then made)
 2.  execute /usr/bin/login and login again (2nd wtmp `login' mark)
 3.  leave the second login (wtmp `logout' mark isn't written)
 
 Index: last.c
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/last/last.c,v
 retrieving revision 1.10.6.2
 diff -u -p -r1.10.6.2 last.c
 --- last.c	2001/03/04 08:39:25	1.10.6.2
 +++ last.c	2001/05/21 10:10:35
 @@ -309,13 +309,10 @@ wtmp()
  							    delta / 86400, width, width, ct + 11);
  						}
  					}
 -					LIST_REMOVE(tt, list);
 -					free(tt);
  					if (maxrec != -1 && !--maxrec)
  						return;
 -				} else {
 -					tt->logout = bp->ut_time;
  				}
 +				tt->logout = bp->ut_time;
  			}
  		}
  	}
 
 This was first "broken" in last.c, rev.1.3.
 
 
 Cheers,
 -- 
 Ruslan Ermilov		Oracle Developer/DBA,
 ru@sunbay.com		Sunbay Software AG,
 ru@FreeBSD.org		FreeBSD committer,
 +380.652.512.251	Simferopol, Ukraine
 
 http://www.FreeBSD.org	The Power To Serve
 http://www.oracle.com	Enabling The Information Age
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: mike 
Responsible-Changed-When: Tue Jul 17 20:04:38 PDT 2001 
Responsible-Changed-Why:  
Ruslan Ermilov <ru@FreeBSD.org> committed a change which apparently 
resolves this PR.  I'm passing it on to him to decide if this PR 
can be closed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27482 
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Tue Aug 21 04:48:31 PDT 2001 
State-Changed-Why:  
last(1) patch has been committed. 
The remnants of this PR are duplicate of PR bin/17830. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27482 
>Unformatted:
