Subject: bin/7965: Can't use IPv4 on ftp(1) (via ftp/http proxy) and telnet(1)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <itohy@netbsd.org>
List: netbsd-bugs
Date: 07/11/1999 19:35:48
>Number: 7965
>Category: bin
>Synopsis: Can't use IPv4 on ftp(1) (via ftp/http proxy) and telnet(1)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jul 11 19:35:00 1999
>Last-Modified:
>Originator: ITOH Yasufumi
>Organization:
>Release: 1.4D (June 3, 1999)
>Environment:
System: NetBSD pino.my.domain 1.4D NetBSD 1.4D (PINO) #0: Sun Jul 11 15:35:13 JST 1999 itohy@pino.my.domain:/usr/src/sys/arch/i386/compile/PINO i386
>Description:
Can't use IPv4 address by ftp(1) (via proxy), telnet(1)
if the kernel is build without IPv6 support (sorry :).
The source is a little old and ignore this if already fixed.
>How-To-Repeat:
Note that the kernel has no IPv6 support.
% env http_proxy=http://proxy/ ftp -o foo http://www.netbsd.org/
ftp: Can't create socket: Protocol not supported
%
% telnet server
Trying c0a8:102:6963:6e6d:7039:0:7465:0...
telnet: socket: Protocol not supported
%
>Fix:
This would not be a correct fix since I'm ignorant of
IPv6 programming....
diff -uF^[a-zA-Z_][a-z A-Z0-9_]*(.*[^;]$ usr.bin/ftp/fetch.c.orig usr.bin/ftp/fetch.c
--- usr.bin/ftp/fetch.c.orig Mon Jul 12 08:44:08 1999
+++ usr.bin/ftp/fetch.c Mon Jul 12 10:31:02 1999
@@ -430,6 +430,7 @@ fetch_url(url, proxyenv, proxyauth, wwwa
in_port_t portnum;
char *port;
int error;
+ const char *cause;
closefunc = NULL;
fin = fout = NULL;
@@ -670,12 +671,12 @@ fetch_url(url, proxyenv, proxyauth, wwwa
if (res->ai_canonname)
host = res->ai_canonname;
- while (1) {
+ for ( ; res; res = res->ai_next) {
s = socket(res->ai_family,
res->ai_socktype, res->ai_protocol);
if (s < 0) {
- warn("Can't create socket");
- goto cleanup_fetch_url;
+ cause = "Can't create socket";
+ continue;
}
if (xconnect(s, res->ai_addr, res->ai_addrlen) < 0) {
@@ -694,12 +695,14 @@ fetch_url(url, proxyenv, proxyauth, wwwa
fprintf(ttyout, "Trying %s...\n", hbuf);
continue;
}
- warn("Can't connect to %s", host);
- goto cleanup_fetch_url;
+ cause = "Can't connect to %s";
+ resetsockbufsize();
}
-
- break;
+ goto sock_ok;
}
+ warn(cause, host);
+ goto cleanup_fetch_url;
+sock_ok:
#endif
diff -uF^[a-zA-Z_][a-z A-Z0-9_]*(.*[^;]$ usr.bin/telnet/commands.c.orig usr.bin/telnet/commands.c
--- usr.bin/telnet/commands.c.orig Sat Jul 3 13:04:31 1999
+++ usr.bin/telnet/commands.c Mon Jul 12 10:37:01 1999
@@ -2307,6 +2307,11 @@ tn(argc, argv)
net = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
setuid(getuid());
if (net < 0) {
+ if (res->ai_next) {
+ /* probably no IPv6 support by this kernel */
+ res = res->ai_next;
+ continue;
+ }
perror("telnet: socket");
return 0;
}
>Audit-Trail:
>Unformatted: