From dchapes@ddm.on.ca  Tue Apr 21 04:20:42 1998
Received: from ymris.ddm.on.ca (p12a.neon.sentex.ca [207.245.212.205])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA19853
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Apr 1998 04:20:34 GMT
          (envelope-from dchapes@ddm.on.ca)
Received: from squigy.ddm.on.ca (squigy.ddm.on.ca [209.47.139.138])
	by ymris.ddm.on.ca (8.8.8/8.8.8) with ESMTP id AAA04136
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 21 Apr 1998 00:20:29 -0400 (EDT)
	(envelope-from dchapes@ymris.ddm.on.ca)
Received: (from dchapes@localhost)
	by squigy.ddm.on.ca (8.8.8/8.8.7) id AAA08216;
	Tue, 21 Apr 1998 00:20:27 -0400 (EDT)
Message-Id: <199804210420.AAA08216@squigy.ddm.on.ca>
Date: Tue, 21 Apr 1998 00:20:27 -0400 (EDT)
From: dchapes@ddm.on.ca
Reply-To: dchapes@ddm.on.ca
To: FreeBSD-gnats-submit@freebsd.org
Subject: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
X-Send-Pr-Version: 3.2

>Number:         6371
>Category:       bin
>Synopsis:       [PATCH?] fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 20 21:30:01 PDT 1998
>Closed-Date:    Thu Aug 31 07:52:44 PDT 2000
>Last-Modified:  Thu Aug 31 07:53:07 PDT 2000
>Originator:     Dave Chapeskie
>Release:        FreeBSD 2.2.5-STABLE i386
>Organization:
DDM Consulting
>Environment:
FreeBSD-2.2.6

>Description:

I have a local Squid cache which I want fetch(1) to use for HTTP
requests but not for FTP requests (the cache has ftp access disabled).
If I just set the HTTP_PROXY variable fetch(1) uses the proxy for
both.  I couldn't find an easy way to tell fetch(1) not to use the proxy
without undefining HTTP_PROXY.

>How-To-Repeat:

% setenv HTTP_PROXY somewhere
% unsetenv FTP_PROXY
% fetch ftp://somehost/some/path

fetch(1) will use the HTTP_PROXY for the ftp request.


>Fix:

The following three line change causes fetch(1) to not use any proxy if
the FTP_PROXY env variable exists but is null.

It might be better to use a special value like "NONE" or change the
semantics of having HTTP_PROXY defined without FTP_PROXY defined but
this is a simpler change that doesn't impact people who don't set
FTP_PROXY yet want fetch(1) to use the HTTP_PROXY.

With this patch:
% setenv HTTP_PROXY somewhere
% setenv FTP_PROXY
% fetch ftp://somehost/some/path

fetch(1) will NOT use any proxy for the ftp request.


Index: ftp.c
===================================================================
RCS file: /cvs/FreeBSD/src/usr.bin/fetch/ftp.c,v
retrieving revision 1.3.2.5
diff -u -r1.3.2.5 ftp.c
--- ftp.c	1997/10/08 18:44:07	1.3.2.5
+++ ftp.c	1997/12/11 20:51:49
@@ -250,6 +250,9 @@
 	struct ftp_state *ftps;
 
 	hostname = getenv("FTP_PROXY");
+	if (hostname[0]=='\0')
+		return ftp_parse(fs,uri);
+
 	port = strchr(hostname, ':');
 	if (port == 0) {
 		portno = 21;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: phk 
State-Changed-When: Tue Apr 21 23:24:33 PDT 1998 
State-Changed-Why:  
Better patch is needed: 
FTP_PROXY=somehost:someport should work 
manual page should be updated 

From: Martin Cracauer <cracauer@cons.org>
To: dchapes@ddm.on.ca, FreeBSD-gnats-submit@FreeBSD.ORG
Cc:  Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
Date: Wed, 22 Apr 1998 12:32:45 +0200

 In <199804210420.AAA08216@squigy.ddm.on.ca>, dchapes@ddm.on.ca wrote: 
 > I have a local Squid cache which I want fetch(1) to use for HTTP
 > requests but not for FTP requests (the cache has ftp access disabled).
 > If I just set the HTTP_PROXY variable fetch(1) uses the proxy for
 > both.  I couldn't find an easy way to tell fetch(1) not to use the proxy
 > without undefining HTTP_PROXY.
 > 
 > >How-To-Repeat:
 > 
 > % setenv HTTP_PROXY somewhere
 > % unsetenv FTP_PROXY
 > % fetch ftp://somehost/some/path
 > 
 > fetch(1) will use the HTTP_PROXY for the ftp request.
 
 Your solution didn't take into account that there are two things to
 control: 
 - The kind of url a proxy is being used for
 - The kind of protocol to speak to the proxy
 
 Theres are the cases to consider:
 
 1) I have two proxies. One that speaks http to the client and serves
    http urls. And one that use ftp to talk to the client and should be
    used for ftp urls. This is what fetch expects when both variables
    are set.
 
 2) I have a proxy that uses the http protocol to talk to the client
    and serves http requests only. The client should not use any proxy
    when fetching ftp urls. That is your situation and not covered by
    the current fetch. 
 
 3) I have a proxy that uses the http protocol and serves http and ftp
    requests. That means, you can get ftp urls by using http to talk to
    your proxy. This is what fetch does when HTTP_PROXY is set, but
    FTP_PROXY isn't. 
 
 You fix breaks case 3, which is a pretty common one, IMHO. I at
 least use such a proxy.
 
 Case 2 is usually a bad situation since some client software use http
 only to talk to proxies.
 
 What we need here is a standard for $..._PROXY environment variables
 that allows us to control the protocol and the kind of url seperatly,
 preferrably without breaking older clients.
 
 Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer
 BSD User Group Hamburg, Germany     http://www.bsdhh.org/

From: Dave Chapeskie <dchapes@ddm.on.ca>
To: Poul-Henning Kamp <phk@FreeBSD.ORG>,
        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/6371
Date: Wed, 22 Apr 1998 23:20:18 -0400

 On Tue, 21 Apr 1998 at 23:25:27 -0700, Poul-Henning Kamp wrote:
 > Better patch is needed:
 >         FTP_PROXY=somehost:someport should work
 
 The patch doesn't change the behaviour of non-null FTP_PROXY settings at
 all.
 
 >         manual page should be updated
 
 True.  The patch at the end of this message adds this paragraph:
 
     If FTP_PROXY is undefined the value of HTTP_PROXY is used for FTP
     transfers.  If this is undesirable you can set FTP_PROXY to NULL and
     fetch will connect directly without using a proxy.
 
 By the way, I should mention that I submitted the patch because I've
 come across a few other people in the same situation as me.  You'll
 note that my original submission suggested that there is likely a better
 solution.  If you don't like this quick fix just leave the PR open and
 perhaps someone else will take the time to do it 'right'.
 
 On Wed, Apr 22, 1998 at 10:18:48AM -0400, Garrett Wollman wrote:
 > > Synopsis: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY
 > > undefined
 >
 > It was done this way intentionally.  (The original `fetch' did it,
 > too, before I rewrote it to be more general.)  My solution:
 > 
 > fetch() {
 > 	(unset HTTP_PROXY; /usr/bin/fetch ${1+"$@"})
 > }
 
 But then you you can't use fetch to get files via HTTP (at least not
 through the proxy).  My 'solution' doesn't break anything for existing
 users it just adds a way for people to tell fetch they don't want FTP to
 be proxied.  Currently there is no way to do that.  At least no way that
 I know of, if anyone else knows better...
 
 Cheers,
 -- 
 Dave Chapeskie <dchapes@ddm.on.ca>, DDM Consulting
 
 ===================================================================
 RCS file: /cvs/FreeBSD/src/usr.bin/fetch/fetch.1,v
 retrieving revision 1.9.2.6
 diff -u -u -r1.9.2.6 fetch.1
 --- fetch.1	1997/09/15 08:07:03	1.9.2.6
 +++ fetch.1	1998/04/23 03:09:45
 @@ -163,6 +163,21 @@
  .Tn HTTP
  .Dq Li GET
  request.  HTTP proxy authentication is not yet implemented.
 +.Pp
 +If
 +.Ev FTP_PROXY
 +is undefined the value of
 +.Ev HTTP_PROXY
 +is used for 
 +.Tn FTP
 +transfers.
 +If this is undesirable you can set
 +.Ev FTP_PROXY
 +to
 +.Tn NULL
 +and
 +.Nm fetch
 +will connect directly without using a proxy.
  .Sh HTTP AUTHENTICATION
  The
  .Tn HTTP

From: Dave Chapeskie <dchapes@ddm.on.ca>
To: Martin Cracauer <cracauer@cons.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
Date: Wed, 22 Apr 1998 23:36:37 -0400

 On Wed, Apr 22, 1998 at 12:32:45PM +0200, Martin Cracauer wrote:
 > Theres are the cases to consider:
 [...]
 > 3) I have a proxy that uses the http protocol and serves http and ftp
 >    requests. That means, you can get ftp urls by using http to talk to
 >    your proxy. This is what fetch does when HTTP_PROXY is set, but
 >    FTP_PROXY isn't. 
 > 
 > You fix breaks case 3, which is a pretty common one, IMHO. I at
 > least use such a proxy.
 
 It doesn't break it.  Just don't set FTP_PROXY.  All I did was change
 the meaning of FTP_PROXY="" from undefined to "Don't use any proxy".
 
 > What we need here is a standard for $..._PROXY environment variables
 > that allows us to control the protocol and the kind of url seperatly,
 > preferrably without breaking older clients.
 
 Yes!  But until that comes along...
 
 Wow, all this discussion about a three line work around.  I suppose
 that's a good thing so that mis-features don't get into the tree.  If
 indeed this is a mis-feature then by all means let it die.  However, I
 have yet to be convinced.
 
 -- 
 Dave Chapeskie <dchapes@ddm.on.ca>, DDM Consulting

From: Martin Cracauer <cracauer@cons.org>
To: Dave Chapeskie <dchapes@ddm.on.ca>, Martin Cracauer <cracauer@cons.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
Date: Thu, 23 Apr 1998 10:04:40 +0200

 In <19980422233637.18932@ddm.on.ca>, Dave Chapeskie wrote: 
 > On Wed, Apr 22, 1998 at 12:32:45PM +0200, Martin Cracauer wrote:
 > > Theres are the cases to consider:
 > [...]
 > > 3) I have a proxy that uses the http protocol and serves http and ftp
 > >    requests. That means, you can get ftp urls by using http to talk to
 > >    your proxy. This is what fetch does when HTTP_PROXY is set, but
 > >    FTP_PROXY isn't. 
 > > 
 > > You fix breaks case 3, which is a pretty common one, IMHO. I at
 > > least use such a proxy.
 > 
 > It doesn't break it.  Just don't set FTP_PROXY.  All I did was change
 > the meaning of FTP_PROXY="" from undefined to "Don't use any proxy".
 
 What I meant is that if you define HTTP_PROXY, but not FTP_PROXY,
 there are two noncompatible things to do:
 1) Don't use a proxy for ftp urls, get then directly.
 2) get ftp urls from the HTTP_PROXY, talking http to the proxy
 
 The latter is what fetch does for now and my understanding is that you
 want it to do 1). In that case, people can't fetch ftp urls from a
 proxy they have talk http to.
 
 To further illustrate my point, if you set FTP_PROXY, it obviously
 mean you should get ftp urls from this proxy, but will you talk ftp or
 http to the proxy?
 
 Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer
   cracauer@wavehh.hanse.de (batched, preferred for large mails)
   Tel.: (daytime) +4940 41478712 Fax.: (daytime) +4940 41478715
   Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536
   Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany

From: Bill Fenner <fenner@parc.xerox.com>
To: Martin Cracauer <cracauer@cons.org>
Cc: freebsd-gnats-submit@hub.freebsd.org
Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined 
Date: Thu, 23 Apr 1998 08:42:13 PDT

 Martin Cracauer <cracauer@cons.org> wrote:
 > 1) Don't use a proxy for ftp urls, get then directly.
 > 2) get ftp urls from the HTTP_PROXY, talking http to the proxy
 
 What everyone seems to be missing is that Dave's patch allows you to
 choose which one of these you want - setenv FTP_PROXY "" gives you (1),
 unsetenv FTP_PROXY gives you (2).
 
   Bill

From: Martin Cracauer <cracauer@cons.org>
To: Bill Fenner <fenner@parc.xerox.com>, Martin Cracauer <cracauer@cons.org>
Cc: freebsd-gnats-submit@hub.freebsd.org
Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
Date: Thu, 23 Apr 1998 19:36:51 +0200

 In <98Apr23.084215pdt.177515@crevenia.parc.xerox.com>, Bill Fenner wrote: 
 > Martin Cracauer <cracauer@cons.org> wrote:
 > > 1) Don't use a proxy for ftp urls, get then directly.
 > > 2) get ftp urls from the HTTP_PROXY, talking http to the proxy
 > 
 > What everyone seems to be missing is that Dave's patch allows you to
 > choose which one of these you want - setenv FTP_PROXY "" gives you (1),
 > unsetenv FTP_PROXY gives you (2).
 
 Then, how can I tell fetch to get ftp urls from a proxy that talks ftp
 (not http) to the client? That's what fetch currently does when
 FTP_PROXY is defined.
 
 Martin
 -- 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer
   cracauer@wavehh.hanse.de (batched, preferred for large mails)
   Tel.: (daytime) +4940 41478712 Fax.: (daytime) +4940 41478715
   Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536
   Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany

From: Bill Fenner <fenner@parc.xerox.com>
To: cracauer@cons.org, freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/6371: fetch(1) uses HTTP_PROXY for ftp requests when FTP_PROXY undefined
Date: Thu, 23 Apr 1998 11:57:48 PDT

 Setting FTP_PROXY to host:port gives you fetch's traditional behavior
 of contacting an FTP proxy to fetch the file.  Setting FTP_PROXY to ""
 goes directly no matter what.  Unsetting FTP_PROXY uses HTTP_PROXY if
 it's set or goes directly if not.
 
 I share Dave's amazement that there's so much brouhaha over this
 straightforward change.
 
   Bill
State-Changed-From-To: feedback->suspended 
State-Changed-By: phk 
State-Changed-When: Tue May 19 23:12:20 PDT 1998 
State-Changed-Why:  
Some committer please make up your mind as deal with this one way or 
another. 
State-Changed-From-To: suspended->open 
State-Changed-By: des 
State-Changed-When: Thu Jun 29 03:18:24 PDT 2000 
State-Changed-Why:  
Still an issue. 


Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Thu Jun 29 03:18:24 PDT 2000 
Responsible-Changed-Why:  
fetch(1) is mine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=6371 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Thu Aug 31 07:52:44 PDT 2000 
State-Changed-Why:  
Fixed in 4.x and 5.x. 2.2.x is no longer supported. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=6371 
>Unformatted:
