Bug 27482

Summary: /var/log/wtmp is not updated on logout
Product: Base System Reporter: christian
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-RELEASE   
Hardware: Any   
OS: Any   

Description christian freebsd_committer freebsd_triage 2001-05-21 02:30:01 UTC
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".

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?
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".
Comment 1 ru freebsd_committer freebsd_triage 2001-05-21 11:17:14 UTC
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
Comment 2 Mike Barcroft freebsd_committer freebsd_triage 2001-07-18 04:04:38 UTC
Responsible Changed
From-To: freebsd-bugs->ru

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.
Comment 3 ru freebsd_committer freebsd_triage 2001-08-21 12:48:31 UTC
State Changed
From-To: open->closed

last(1) patch has been committed. 
The remnants of this PR are duplicate of PR bin/17830.