bin/57089: "w" does not honor the -n option

Dima Dorfman dima at trit.org
Mon Sep 22 15:51:32 PDT 2003


The following reply was made to PR bin/57089; it has been noted by GNATS.

From: Dima Dorfman <dima at trit.org>
To: Kirk Strauser <kirk at strauser.com>
Cc: FreeBSD-gnats-submit at FreeBSD.org, brian at FreeBSD.org
Subject: Re: bin/57089: "w" does not honor the -n option
Date: Mon, 22 Sep 2003 22:43:00 +0000

 Kirk Strauser <kirk at strauser.com> wrote:
 > At 2003-09-22T21:54:10Z, Dima Dorfman <dima at trit.org> writes:
 > 
 > > I think the "-n" option is intended to prevent name resolution to avoid a
 > > display delay--not necessarily to display numeric addresses (name
 > > resolution can be slow, possibly requiring dialing out the Internet, and
 > > so on, so it's useful to be able to tell w(1) not to do it).  If utmp
 > > already has a name, it can be displayed without incurring any lookup
 > > delay, so w(1) does so.
 > 
 > 
 > However, that's different from the behavior in 4.x systems (at least, as of
 > the 4.7 server that I have access to):
 > 
 >     kirk at glaaki:/usr/src/usr.bin/w$ w -n
 >      5:06PM  up 14 days,  8:36, 3 users, load averages: 0.09, 0.06, 0.01
 >     USER             TTY      FROM              LOGIN@  IDLE WHAT
 >     corwin           p0       12.218.138.143    1:09PM  1:10 psql template1
 >     corwin           p1       12.218.138.143   Sat09PM 21:47 -bash (bash)
 >     kirk             p2       208.162.254.126   4:59PM     - w -n
 > 
 > I'd definitely think that's the more appropriate behavior, since it would be
 > analogous to the "-n" (mnemmonic: "numeric") options of other utilities
 > such as netstat.
 
 It seems that you're right about the intention (I always thought -n
 was to avoid doing lookups, and I've always used it for that purpose).
 
 The behavior was changed in this commit of w.c:
 
 ----------------------------
 revision 1.48
 date: 2001/07/26 19:20:13;  author: brian;  state: Exp;  lines: +40 -41
 When -n is specified, don't attempt to turn hostnames found in utmp
 into addresses as we have no idea what address family they belong to.
 
 When -n is not specified, resolve IPv6 as well as IPv4 addresses found
 in the host field of utmp.  Use realhostname_sa() to resolve addresses
 (the old code was wrong).
 ...
 
 and it looks like that rationale still applies.  I've cc'd brian (who
 made that change) to see whether he has any input on this.  The issue
 is: So, you want to see numeric addresses--but for which family?  If a
 host resolves to a v4 and v6 address, which one should be displayed?
 Perhaps the programs that write to utmp/wtmp should just avoid writing
 hostnames? (although this is just a thought--I haven't tried to think
 through the implications of doing something like that)
 
 Dima.


More information about the freebsd-bugs mailing list