From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 22 15:51:32 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B459C16A4B3 for ; Mon, 22 Sep 2003 15:51:32 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id B717F4405A for ; Mon, 22 Sep 2003 15:50:22 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h8MMoMFY004726 for ; Mon, 22 Sep 2003 15:50:22 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h8MMoMYO004725; Mon, 22 Sep 2003 15:50:22 -0700 (PDT) (envelope-from gnats) Date: Mon, 22 Sep 2003 15:50:22 -0700 (PDT) Message-Id: <200309222250.h8MMoMYO004725@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Dima Dorfman Subject: Re: bin/57089: "w" does not honor the -n option X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dima Dorfman List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Sep 2003 22:51:32 -0000 The following reply was made to PR bin/57089; it has been noted by GNATS. From: Dima Dorfman To: Kirk Strauser Cc: FreeBSD-gnats-submit@FreeBSD.org, brian@FreeBSD.org Subject: Re: bin/57089: "w" does not honor the -n option Date: Mon, 22 Sep 2003 22:43:00 +0000 Kirk Strauser wrote: > At 2003-09-22T21:54:10Z, Dima Dorfman 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@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.