Subject: bin/2127: buglet in domestic/usr.bin/telnet vs. CNAMES and ip #'s
To: None <gnats-bugs@NetBSD.ORG>
From: Michael Graff <explorer@flame.org>
List: netbsd-bugs
Date: 02/25/1996 18:09:54
>Number: 2127
>Category: bin
>Synopsis: buglet in domestic/usr.bin/telnet vs. CNAMES and ip #'s
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Feb 25 19:35:00 1996
>Last-Modified:
>Originator: Michael Graff
>Organization:
flame.org: yes, we do know everything
>Release: 25-Feb-1996 <NetBSD-current source date>
>Environment:
System: NetBSD packrat.flame.org 1.1A NetBSD 1.1A (PACKRAT) #1: Fri Feb 23 00:31:21 CST 1996 explorer@packrat.flame.org:/usr/src/sys/arch/i386/compile/PACKRAT i386
>Description:
Now that telnet supports the -a (authenticaton) flag and uses kerberos4,
there is a bug in the way telnet deals with hostnames and kerberos notices.
>How-To-Repeat:
This arrises in two ways:
telnet 129.186.82.10
telnet ftp
Both of these machines are darkwatch.flame.org, but the first tries
to get a rcmd.129 ticket and the second tries rcmd.ftp, which both
fail.
>Fix:
What needs to be done is as follows:
for ip # based telnets:
get the host name via gethostbyaddr() and use the
name returned. If the call fails, keep
the numeric version and let kerberos fail.
for telnets to CNAMEs:
After the gethostbyname() has returned the correct
ip #, use it as above to get the true
name of the machine.
Here it is, as a patch to domestic/usr.bin/telnet/commands.c:
Index: commands.c
===================================================================
RCS file: /local/source/netbsd/src/domestic/usr.bin/telnet/commands.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 commands.c
*** 1.1.1.1 1996/02/25 16:39:52
--- commands.c 1996/02/26 00:03:29
***************
*** 2319,2325 ****
if (temp != INADDR_NONE) {
sin.sin_addr.s_addr = temp;
sin.sin_family = AF_INET;
! (void) strcpy(_hostname, hostp);
hostname = _hostname;
} else {
host = gethostbyname(hostp);
--- 2319,2329 ----
if (temp != INADDR_NONE) {
sin.sin_addr.s_addr = temp;
sin.sin_family = AF_INET;
! host = gethostbyaddr((char *)&temp, sizeof(temp), AF_INET);
! if (host)
! strcpy(_hostname, host->h_name);
! else
! strcpy(_hostname, hostp);
hostname = _hostname;
} else {
host = gethostbyname(hostp);
***************
*** 2331,2339 ****
#else /* defined(h_addr) */
memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
#endif /* defined(h_addr) */
! strncpy(_hostname, host->h_name, sizeof(_hostname));
! _hostname[sizeof(_hostname)-1] = '\0';
! hostname = _hostname;
} else {
herror(hostp);
setuid(getuid());
--- 2335,2347 ----
#else /* defined(h_addr) */
memmove((caddr_t)&sin.sin_addr, host->h_addr, host->h_length);
#endif /* defined(h_addr) */
! host = gethostbyaddr((char *)&sin.sin_addr,
! sizeof(sin.sin_addr), AF_INET);
! if (host)
! strcpy(_hostname, host->h_name);
! else
! strcpy(_hostname, hostp);
! hostname = _hostname;
} else {
herror(hostp);
setuid(getuid());
>Audit-Trail:
>Unformatted: