Bug 23128

Summary: libfetch doesn't behave as documented about FTP_PROXY
Product: Base System Reporter: SANETO Takanori <sanewo>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   

Description SANETO Takanori 2000-11-27 13:10:01 UTC
On FTP_PROXY environment variable, fetch(3) says "if no scheme is specified, FTP is assumed."
But lib/libfetch/ftp.c sets default scheme as HTTP.

   872  _ftp_get_proxy(void)
	:
   879          if (!*purl->scheme)
   880              strcpy(purl->scheme, SCHEME_HTTP);

Fix: 

Change the source as documented, or change the document as source behaves.
How-To-Repeat: 
Put just a hostname to FTP_PROXY and invoke fetch. You will see fetch trying to
connect proxy via http port (80).
Comment 1 dwmalone freebsd_committer freebsd_triage 2000-11-27 13:23:17 UTC
Responsible Changed
From-To: freebsd-bugs->des

Des owns libfecth.
Comment 2 des 2000-11-27 13:26:04 UTC
sanewo@ba2.so-net.ne.jp writes:
> On FTP_PROXY environment variable, fetch(3) says "if no scheme is
> specified, FTP is assumed." But lib/libfetch/ftp.c sets default
> scheme as HTTP.

I'm aware of this problem, and will fix it very soon.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 3 des 2000-11-27 13:29:48 UTC
I should elaborate a little more - I got a report of the opposite bug
(defaulting to FTP where it previously defaulted to HTTP) shortly
before 4.2-RELEASE, and in the rush to get it fixed in time for the
release, I fixed it the wrong way. The following patch should correct
the problem:

Index: ftp.c
===================================================================
RCS file: /home/ncvs/src/lib/libfetch/ftp.c,v
retrieving revision 1.16.2.14
diff -u -r1.16.2.14 ftp.c
--- ftp.c	2000/11/27 10:15:09	1.16.2.14
+++ ftp.c	2000/11/27 13:27:02
@@ -877,7 +877,10 @@
     if (((p = getenv("FTP_PROXY")) || (p = getenv("HTTP_PROXY"))) &&
 	*p && (purl = fetchParseURL(p)) != NULL) {
 	if (!*purl->scheme)
-	    strcpy(purl->scheme, SCHEME_HTTP);
+	    if (getenv("FTP_PROXY"))
+		strcpy(purl->scheme, SCHEME_FTP);
+	    else
+		strcpy(purl->scheme, SCHEME_HTTP);
 	if (!purl->port)
 	    purl->port = _fetch_default_proxy_port(purl->scheme);
 	if (strcasecmp(purl->scheme, SCHEME_FTP) == 0 ||


DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 4 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2000-11-28 09:21:06 UTC
State Changed
From-To: open->feedback

Fixed in -CURRENT, awaiting MFC.
Comment 5 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2000-12-01 11:11:54 UTC
State Changed
From-To: feedback->closed

MFCed.