Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Nov 2009 01:28:02 +0900
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        Juli Mallett <jmallett@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r199655 - head/usr.bin/w
Message-ID:  <ygebpiqd0x9.wl%ume@mahoroba.org>
In-Reply-To: <eaa228be0911241718i10795347hdd0f5735adee51e4@mail.gmail.com>
References:  <200911221651.nAMGpiIO023873@svn.freebsd.org> <eaa228be0911241718i10795347hdd0f5735adee51e4@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

>>>>> On Tue, 24 Nov 2009 17:18:49 -0800
>>>>> Juli Mallett <jmallett@FreeBSD.org> said:

jmallett> I'm not sure this is right.  While the manpage implies that doing no
jmallett> resolution means that it will show numeric addresses, since that is
jmallett> not correct, there are two ways to go.  As you have done, you can
jmallett> choose to try to resolve hostnames to IP addresses.  You could also do
jmallett> as the code before did and do no resolution.  I frequently use 'w -n'
jmallett> on systems with slow nameservers to see who is logged in without
jmallett> triggering a bunch of DNS traffic that I then have to wait for.
jmallett> Trying to resolve the name to a numeric address presents that problem.
jmallett>  Since it is not possible to always show a numeric address (if, for
jmallett> example, the hostname is no longer valid) I'm not sure that this is
jmallett> the right direction to try to go with 'w -n'.

The feature was present in the past, and was dropped by 1.48.  The
reason is that we have no idea what address family they belong to.
So, I reintroduce it for just one A/AAAA RR case.

http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/w/w.c#rev1.48

However, a hostname in utmp is truncated in many cases.  It is useless
to query for a truncated hostname.  How about this patch?

Index: usr.bin/w/w.c
diff -u -p usr.bin/w/w.c.orig usr.bin/w/w.c
--- usr.bin/w/w.c.orig	2009-11-21 20:27:35.000000000 +0900
+++ usr.bin/w/w.c	2009-11-25 12:40:19.142972545 +0900
@@ -383,7 +383,7 @@ main(int argc, char *argv[])
 			if (isaddr && realhostname_sa(fn, sizeof(fn), sa,
 			    sa->sa_len) == HOSTNAME_FOUND)
 				p = fn;
-		} else if (!isaddr) {
+		} else if (!isaddr && strlen(p) < UT_HOSTSIZE) {
 			/*
 			 * If a host has only one A/AAAA RR, change a
 			 * name into an IP address


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygebpiqd0x9.wl%ume>