Subject: Re: UT_HOSTSIZE vs. MAXHOSTNAMELEN
To: None <current-users@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: current-users
Date: 10/02/1999 15:22:25
[ On Friday, October 1, 1999 at 15:48:05 (-0500), Brian Stark wrote: ]
> Subject: UT_HOSTSIZE vs. MAXHOSTNAMELEN
>
> I'm thinking that the value of 16 may have something to do with the
> amount of space required to store an IPv4 address as a C-style string.
> For example the IP address string:
>
> 123.123.123.123
>
> requires 15 characters, plus one extra character for the null terminator
> so 16 characters seems to make sense...
Indeed this is the case. A long long time ago there were versions of
Unix that would put an ASCII IP# literal in ut_host if the hostname
retrieved was more than 16 characters. Indeed there's code in rlogind.c
to do exactly this, however not all (none of the other?) parts of *BSD
do things the same way (eg. xterm and telnetd just pass the hostname to
login, which simply trims it to fit, though telentd *could* do the right
thing if it was properly ported -- the code's there, just not used).
I'd always planned to hack everything to do this stuff more
consistently, but I've never got around to it. These days I think it
would be better to re-write all this stuff to be more xOpen/SUS
compliant, but perhaps with a unique new non-binary file format.
(BTW, as others have already pointed out the NUL isn't necessary in
struct utmp, but perhaps whomever set UT_HOSTSIZE way back when was
planning to make it necessary at some point.)
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>