Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Apr 1999 14:23:49 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        Rahul Dhesi <dhesi@rahul.net>
Cc:        freebsd-current@FreeBSD.ORG
Subject:   Re: showing full host names in output from who/finger/last 
Message-ID:  <199904111323.OAA57685@keep.lan.Awfulhak.org>
In-Reply-To: Your message of "Sat, 10 Apr 1999 17:18:08 PDT." <199904110018.AA21927@bolero-x.rahul.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
> For some years I have been using patched utilities under SunOS to show
> full host names in the output from the 'who', 'finger', and 'last'
> commands.  (Traditional UNIXes truncate host names to about 16
> characters.)
> 
> I have been thinking of patching FreeBSD programs to do the same, but
> since I have been updating my source tree often, it will be a bit
> painful to maintain my changes through the updates.  So I will do it
> only if the FreeBSD developers would be willing to incorporate my
> changes into the official FreeBSD source tree.  Below is what I would 
> do -- tell me if it could be make a part of FreeBSD.
> 
> - Update all programs that write to utmp and wtmp to check the host name
>   length, and if it's too long, insert the IP address instead

I've been doing this in current in the last few days.  There's now a 
new function in libutil called realhostname().  You pass it a maximum 
fields size (UT_HOSTSIZE?).  If it can fit the gethostbyaddr() result 
into the field, AND that name resolves back to the same IP number, 
the full host name is used, otherwise the IP number is used.

The trimdomain() function has also been fixed and documented.

I believe all the stuff in libexec now works and I've just committed 
some ssh patches that'll do the same for sshd.

> - Update all of the above programs, if they accept a host name on the
>   command line, to also accept an additional argument that specifies
>   the IP address.
> - Update all programs that invoke the above programs and supply a
>   host name to also supply the IP address.

I think the host name that's passed should be considered correct.  
However, if it doesn't fit in the ut_host field, a gethostbyname() is 
required.  Passing an IP number would therefore probably be a quite 
good addition if it avoids that call.

> - Update all programs that look up wtmp and utmp such that, if they find
>   an IP address, they do a double-reverse DNS resolution (IP address ->
>   fqdn -> IP address) and, if successful and consistent, display the
>   host name instead of the IP address.  The user may if he wishes supply
>   a command-line argument to suppress the reverse resolution and cause
>   the IP address to be displayed directly.

I'd agree with Matt here - don't make the default suddenly require 
lookups, but I'd say that if a lookup is being done, it should be a 
correct double lookup (realhostname() from libutil).

> For example, rlogind might invoke /usr/bin/login as:
> 
>    /usr/bin/login -h 98.portland-23-24rs.or.dial-access.att.net -i 12.73.137.98
> 
> /usr/bin/login notices that the host name is too long, inserts
> 12.73.137.98 into utmp and wtmp.  If no -i argument is available,
> /usr/bin/login would do a forward DNS resolution of the host name to get
> the IP address.

Yep.  This sounds pretty rational.

> Below are samples from the 'last' and 'finger' commands with only the
> really long host names included and some information x'd out to protect
> user privacy.  (Obviously comumnar alignment doesn't work as well for
> very long host names, but only a small fraction are that long.  The rest
> will display normally in aligned columns.)
> 
> == output from 'finger ==
> Login        Name               Idle       When         Where
> xxxxxx   xxxxxxxxxxxxxx            7  Apr  9 13:14  kaibab.redbacknetworks.com
> xxx      xxxxxxxxxxxxxxx              Apr 10 16:37  dyn164.rahul.net
> xxxxxxxx xxxxxxxxxxxx              8  Apr 10 16:48  c166.ppp.tsoft.com
> xxxxx    xxxxxxxxxxx                  Apr  9 23:35  \
>                                                  cxxxxxxx-x.xxxxx.occa.home.com
> xxxxx    xxxxxxxxxxxx         *   10  Apr 10 16:44  01-025.006.popsite.net
> 
> == output from 'last' ==
> xxx       s1  98.portland-23-24rs.or.dial-access.att.net Sat Apr 10 16:50 - 16:50  (00:00)
> xxxxxx    rd  oak-hiper1b-145-145.dialup.slip.net Sat Apr 10 16:48 - 16:51  (00:03)
> xxxx      p6  netcom14.netcom.com            Sat Apr 10 15:36 - 15:39  (00:03)
> xxxxx     s2  adsl-xxx-xxx-xxx-10.dsl.snfc21.pacbell.net Sat Apr 10 13:51 - 13:52  (00:00)
> xxxxxxxx  sb  tnt9-xxx-xxx-17-189.dialup.HiWAAY.net Sat Apr 10 12:54 - 14:54  (02:00)
> xxxxxx    s2  oak-hiper1a-15-79.dialup.slip.net Sat Apr 10 12:37 - 12:40  (00:02)
> xxxx      r2  dnai-207-181-255-82.dialup.dnai.com Sat Apr 10 11:41 - 13:58  (02:17)
> xxxxxxx   q8  sdn-ar-001casfraP195.dialsprint.net Sat Apr 10 08:28 - 13:30  (05:01)
> == END ==

This is fine for ``w'' as I believe it already does the lookup.  But 
in the ``who'' and ``last'' cases, they should display the contents 
of ut_host by default unless some consistent option is used - it's a 
pity that this is the opposite of the -n option to route/netstat and 
probably others :-(

I'll review & commit your changes when you've got them done if you 
haven't already got someone.
-- 
Brian <brian@Awfulhak.org>                        <brian@FreeBSD.org>
      <http://www.Awfulhak.org>;                   <brian@OpenBSD.org>
Don't _EVER_ lose your sense of humour !          <brian@uk.FreeBSD.org>




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904111323.OAA57685>