Bug 32828

Summary: [jail] w(1) incorrectly handles stale utmp slots with jail
Product: Base System Reporter: rlucia <rlucia>
Component: binAssignee: freebsd-jail (Nobody) <jail>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description rlucia 2001-12-14 11:50:07 UTC
While using jail, w command on host machine erroneously handles 'current
process' for a stale utmp slot.

It will show as 'current process' that one who is actually run in the jail
and whose controlling terminal line is the same as it was used in the host machine.

How-To-Repeat: 1. log into the jail and allocate different ttys (screen could help)
2. log into the host machine and have the process killed or disconnected
   (create a stale utmp record)

Manage steps 1 and 2 so that you have at least a session on host machine
and a session in the prison that share same tty name (/dev/ttyp1 on host,
and ${JAIL}/dev/ttyp1 in the prison).

3. now issue the w command on the host system and you'll see the 'current
   process' for the stale utmp record being a process running in the jail
   but that has same tty (though on two different environments).
Comment 1 rlucia 2001-12-15 02:10:32 UTC
I was wrong about assumptions and I didn't doublecheck before
posting the PR. shame on me :)

anwyay here's the corrected thing:

How-to-Repeat
  1. log into the host machine and have your shell killed or disconnected
     (create a stale utmp record)
  2. log into the jail and manage to get allocated to you the tty just
     freed but who appears in the stale utmp record
  3. now issue the w command on the host system and you'll see the
     'current process' for the stale utmp record being a process running
     in the jail.

-- 
Rocco Lucia - rlucia@iscanet.com      Iscanet Internet Services
http://elisa.utopianet.net/~rlucia    System and Network Admin
C6E6 AC9A 1361 FB38 B47A  2792 9FC4 C52F 7A68 4468

Free unices for a free world. Support *BSD.
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2001-12-30 13:05:01 UTC
Responsible Changed
From-To: freebsd-bugs->phk

This is more a problem with w(1) than with jails, but perhaps you 
could take a look anyway? 
:-)
Comment 3 Poul-Henning Kamp freebsd_committer freebsd_triage 2003-07-29 11:32:30 UTC
Responsible Changed
From-To: phk->bugs

This is indeed a problem with the way utmp and w(1) works, but 
admittedly, jails probably add to the confusion. 

I have no simple fix to offer.
Comment 4 Tilman Keskinoz freebsd_committer freebsd_triage 2003-08-04 19:19:46 UTC
Responsible Changed
From-To: bugs->freebsd-bugs

fix responsible
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2008-01-25 22:05:56 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-jail

Reassign to appropriate mailing list.
Comment 6 Ed Schouten freebsd_committer freebsd_triage 2012-11-17 13:12:43 UTC
State Changed
From-To: open->closed

Closing, as this is no longer an issue on FreeBSD -CURRENT.