From nobody@FreeBSD.org  Mon Mar 11 02:10:17 2002
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 0BDB337B41F
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 11 Mar 2002 02:10:17 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g2BAAHb35625;
	Mon, 11 Mar 2002 02:10:17 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200203111010.g2BAAHb35625@freefall.freebsd.org>
Date: Mon, 11 Mar 2002 02:10:17 -0800 (PST)
From: Michael Wardle <michael@endbracket.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: w does not correctly interpret X sessions
X-Send-Pr-Version: www-1.0

>Number:         35769
>Category:       bin
>Synopsis:       w(1) does not correctly interpret X sessions
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 11 02:20:00 PST 2002
>Closed-Date:    
>Last-Modified:  Wed May 21 21:28:39 UTC 2008
>Originator:     Michael Wardle
>Release:        4.5
>Organization:
>Environment:
FreeBSD water 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Mon Feb 11 20:27:00 EST 2002
   root@water:/usr/obj/usr/src/sys/WATER  i386
>Description:
If I do "w" on my system, I get this output:
-----
w: /dev/:0: No such file or directory
w: /dev/air.:0: No such file or directory
 9:04PM  up 20:32, 0 users, load averages: 0.04, 0.06, 0.02
USER             TTY      FROM              LOGIN@  IDLE WHAT
-----

I guess it tries to interpret the terminal (usually something like ttyv1) as an entry in /dev, however a user can also be logged in on an X session such as :0 or remotehost:0.  These "terminals" should not
be interpreted as entries in /dev.

Running "who" on my system shows what is really happening:
-----
michael          :0      Mar 11 20:57
alison           air.:0  Mar 11 20:52
-----

I have configured this host as a remote X server, so most logins are
actually performed remotely using XDMCP, but I expect this will also
work if only a local X session is active.

>How-To-Repeat:
establish an X session on the host, then issue "w".
>Fix:
      
>Release-Note:
>Audit-Trail:

From: "Crist J. Clark" <cjc@FreeBSD.ORG>
To: Michael Wardle <michael@endbracket.net>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/35769: w does not correctly interpret X sessions
Date: Mon, 11 Mar 2002 03:31:59 -0800

 On Mon, Mar 11, 2002 at 02:10:17AM -0800, Michael Wardle wrote:
 [snip]
 
 > >Description:
 > If I do "w" on my system, I get this output:
 > -----
 > w: /dev/:0: No such file or directory
 > w: /dev/air.:0: No such file or directory
 >  9:04PM  up 20:32, 0 users, load averages: 0.04, 0.06, 0.02
 > USER             TTY      FROM              LOGIN@  IDLE WHAT
 > -----
 > 
 > I guess it tries to interpret the terminal (usually something like ttyv1) as an entry in /dev, however a user can also be logged in on an X session such as :0 or remotehost:0.  These "terminals" should not
 > be interpreted as entries in /dev.
 
 You should bet getting the pty(4) associated with the session.
 
 > Running "who" on my system shows what is really happening:
 > -----
 > michael          :0      Mar 11 20:57
 > alison           air.:0  Mar 11 20:52
 > -----
 > 
 > I have configured this host as a remote X server, so most logins are
 > actually performed remotely using XDMCP, but I expect this will also
 > work if only a local X session is active.
 
 Hmmm...
 
   $ echo $DISPLAY
   blossom.cjclark.org:10.0
   $ tty
   /dev/ttyp3
   $ w
    3:31AM  up 33 days,  3:08, 7 users, load averages: 1.02, 1.03, 1.00
   USER             TTY      FROM              LOGIN@  IDLE WHAT
   cjc              p0       vegeta           Wed08AM     1 emacs /var/tmp/tmp_cjc/mutt-blossom-57999-1626
   cjc              p1       blossom.cjclark. Wed08AM    35 tcsh
   cjc              p2       blossom.cjclark. Wed08AM    49 tcsh
 
 > >How-To-Repeat:
 > establish an X session on the host, then issue "w".
 
 What does 'tty' return for one of these sessions?
 -- 
 Crist J. Clark                     |     cjclark@alum.mit.edu
                                    |     cjclark@jhu.edu
 http://people.freebsd.org/~cjc/    |     cjc@freebsd.org

From: Michael Wardle <michael@endbracket.net>
To: "Crist J. Clark" <cjc@FreeBSD.ORG>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/35769: w does not correctly interpret X sessions
Date: Mon, 11 Mar 2002 05:09:30 -0800 (PST)

 [...]
 
 > What does 'tty' return for one of these sessions?
 
 This is precisely the problem -- it is not a terminal, indeed there is
 no way to issue "tty".  I can only issue "tty" if I start a terminal
 emulator, but the problem is when w tries to look directly at the X
 session itself, not any terminal I have spawned from within the X
 session.
 
 In the same way, I can't "write" a user on one of these X sessions
 unless they have opened a terminal emulator (such as xterm or konsole).
 
 
 __________________________________________________
 Do You Yahoo!?
 Try FREE Yahoo! Mail - the world's greatest free email!
 http://mail.yahoo.com/

From: "Crist J. Clark" <crist.clark@attbi.com>
To: Michael Wardle <michael@endbracket.net>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/35769: w does not correctly interpret X sessions
Date: Mon, 11 Mar 2002 11:34:22 -0800

 On Mon, Mar 11, 2002 at 05:09:30AM -0800, Michael Wardle wrote:
 > 
 > [...]
 > 
 > > What does 'tty' return for one of these sessions?
 > 
 > This is precisely the problem -- it is not a terminal, indeed there is
 > no way to issue "tty".  I can only issue "tty" if I start a terminal
 > emulator, but the problem is when w tries to look directly at the X
 > session itself, not any terminal I have spawned from within the X
 > session.
 
 Ah. Now I realize what you are talking about. You're using
 xdm(8). xdm(8) is well known for putting broken entries into
 utmp(5). There isn't much w(1) can do about it. xdm(8) is feeding it
 invalid data.
 -- 
 Crist J. Clark                     |     cjclark@alum.mit.edu
                                    |     cjclark@jhu.edu
 http://people.freebsd.org/~cjc/    |     cjc@freebsd.org

From: Michael Wardle <michael@endbracket.net>
To: cjclark@alum.mit.edu, Michael Wardle <michael@endbracket.net>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: bin/35769: w does not correctly interpret X sessions
Date: Mon, 11 Mar 2002 14:01:33 -0800 (PST)

 --- "Crist J. Clark" <crist.clark@attbi.com> wrote:
 > On Mon, Mar 11, 2002 at 05:09:30AM -0800, Michael Wardle wrote:
 > > 
 > > [...]
 > > 
 > > > What does 'tty' return for one of these sessions?
 > > 
 > > This is precisely the problem -- it is not a terminal...
 
 [...]
 
 > Ah. Now I realize what you are talking about. You're using
 > xdm(8). xdm(8) is well known for putting broken entries into
 > utmp(5). There isn't much w(1) can do about it. xdm(8) is feeding it
 > invalid data.
 > -- 
 
 So we could file bugs against xdm, kdm, and gdm, and hope that they
 change their manipulation of utmp, but as I stated in my original bug,
 "who" gives some useful information about users logged in on X
 sessions, presumably derived from utmp, so I'm guessing what we get
 from utmp isn't about to change.
 
 At the very least, as there seems to be agreement that this is a common
 problem, could "w" be modified to first test whether a corresponding
 entry exists in /dev for that "terminal", and if it does not, "w"
 ignores that one?
 
 I would actually wonder whether "w" should indeed print useful
 information about each session (including non-terminal logins), to
 give it parity with "who", but at least ignoring non-terminals would
 workaround the error messages.
 
 
 
 =====
 MICHAEL WARDLE
 
 MAIL   michael@endbracket.net
 MOBILE +61-415-439-838
 WWW    http://www.endbracket.net/michael/
 
 
 __________________________________________________
 Do You Yahoo!?
 Try FREE Yahoo! Mail - the world's greatest free email!
 http://mail.yahoo.com/
>Unformatted:
