Subject: bin/1946: rlogind truncates long remote hostnames
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@spiff.bga.com>
List: netbsd-bugs
Date: 01/15/1996 14:59:21
>Number:         1946
>Category:       bin
>Synopsis:       rlogind truncates long remote hostnames
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 15 16:20:05 1996
>Last-Modified:
>Originator:     Dave Huang
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 20 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of Jan 15, 1996
>Environment:
	
System: NetBSD spiff.bga.com 1.1A NetBSD 1.1A (SPIFF) #5: Sun Jan 14 19:31:53 CST 1996 khym@spiff.bga.com:/usr/src/sys/arch/i386/compile/SPIFF i386


>Description:
When someone rlogins from another machine, the remote machine name
that gets put into utmp and wtmp gets truncated if it's longer than 16
characters. On the other hand, telnetd will log the IP address instead
of the hostname if it's too long to fit in utmp.
	
>How-To-Repeat:
rlogin from a machine that has a >16 character hostname and do a "who"
or "last".

>Fix:
Here's a patch that makes rlogind log the IP address if the hostname
is too long:

--- /usr/src/libexec/rlogind/rlogind.c  Fri Oct 13 20:05:42 1995
+++ rlogind.c   Mon Jan 15 13:18:24 1996
@@ -72,6 +72,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <utmp.h>
 #include "pathnames.h"
 
 #ifndef TIOCPKT_WINDOW
@@ -178,7 +179,7 @@
        fromp->sin_port = ntohs((u_short)fromp->sin_port);
        hp = gethostbyaddr((char *)&fromp->sin_addr, sizeof(struct in_addr),
            fromp->sin_family);
-       if (hp)
+       if (hp && (strlen(hp->h_name) <= UT_HOSTSIZE))
                (void)strcpy(hostname, hp->h_name);
        else
                (void)strcpy(hostname, inet_ntoa(fromp->sin_addr));
>Audit-Trail:
>Unformatted: