From nobody@FreeBSD.org  Fri Mar 16 13:23:04 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 2C99F16A403
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 16 Mar 2007 13:23:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 1BC1113C45A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 16 Mar 2007 13:23:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l2GDN31S084405
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 16 Mar 2007 13:23:03 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l2GDN3D4084352;
	Fri, 16 Mar 2007 13:23:03 GMT
	(envelope-from nobody)
Message-Id: <200703161323.l2GDN3D4084352@www.freebsd.org>
Date: Fri, 16 Mar 2007 13:23:03 GMT
From: Alexander Pohoyda<alexander.pohoyda@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Missing NO_PROXY support in fetch(3)
X-Send-Pr-Version: www-3.0

>Number:         110388
>Category:       kern
>Synopsis:       [libfetch] [patch] Missing NO_PROXY support in fetch(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 16 13:30:01 GMT 2007
>Closed-Date:    Fri Feb 29 01:56:23 UTC 2008
>Last-Modified:  Fri Feb 29 01:56:23 UTC 2008
>Originator:     Alexander Pohoyda
>Release:        7.0
>Organization:
SAP AG
>Environment:
There is no problem. This is a feature request.
>Description:
fetch(3) tool, which uses the libfetch library, supports HTTP_PROXY and
FTP_PROXY env. variables.  However, if the *_PROXY variable is set, there's
no way to exclude some domain name suffixes from being requested over that
proxy.
This is very annoying.

>How-To-Repeat:
$ setenv HTTP_PROXY "proxy:8080"
$ fetch http://some-remote.machine/some-file
$ fetch http://local-machine/file

The first fetch works, because we must use the proxy to request the external
pages, but the second fetch does not work.

>Fix:
Please apply the attached patch.


Patch attached with submission follows:

--- ftp.c.orig	Fri Mar 16 13:56:09 2007
+++ ftp.c	Fri Mar 16 14:08:36 2007
@@ -924,6 +924,22 @@
 {
 	conn_t *conn;
 	int oflag;
+	char *no_proxy, *no_proxy_item;
+	size_t b, s;
+
+	if ((no_proxy = getenv("NO_PROXY")) != NULL) {
+		b = strlen(url->host);
+		while ((no_proxy_item = strsep(&no_proxy, ",")) != NULL) {
+			s = strlen(no_proxy_item);
+			if (b > s && strcasecmp(url->host + b - s,
+						no_proxy_item) == 0) {
+				/* disable proxy */
+				fetchFreeURL(purl);
+				purl = NULL;
+				break;
+			}
+		}
+	}
 
 	/* check if we should use HTTP instead */
 	if (purl && strcasecmp(purl->scheme, SCHEME_HTTP) == 0) {
--- http.c.orig	Fri Mar 16 13:56:04 2007
+++ http.c	Fri Mar 16 14:06:32 2007
@@ -779,6 +779,22 @@
 	FILE *f;
 	hdr_t h;
 	char hbuf[MAXHOSTNAMELEN + 7], *host;
+	char *no_proxy, *no_proxy_item;
+	size_t b, s;
+
+	if ((no_proxy = getenv("NO_PROXY")) != NULL) {
+		b = strlen(URL->host);
+		while ((no_proxy_item = strsep(&no_proxy, ",")) != NULL) {
+			s = strlen(no_proxy_item);
+			if (b > s && strcasecmp(URL->host + b - s,
+						no_proxy_item) == 0) {
+				/* disable proxy */
+				fetchFreeURL(purl);
+				purl = NULL;
+				break;
+			}
+		}
+	}
 
 	direct = CHECK_FLAG('d');
 	noredirect = CHECK_FLAG('A');

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Fri Mar 16 14:35:16 UTC 2007 
Responsible-Changed-Why:  
Over to libfetch maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=110388 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/110388: commit references a PR
Date: Tue, 18 Dec 2007 11:03:15 +0000 (UTC)

 des         2007-12-18 11:03:08 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libfetch         common.c common.h ftp.c http.c 
   Log:
   Add support for the NO_PROXY / no_proxy environment variable as used by
   lynx, curl etc.  Note that this patch differs significantly from that
   in the PR, as the submitter refined it after submitting the PR.
   
   PR:             110388
   Submitted by:   Alexander Pohoyda <alexander.pohoyda@gmx.net>
   MFC after:      3 weeks
   
   Revision  Changes    Path
   1.52      +50 -0     src/lib/libfetch/common.c
   1.30      +1 -0      src/lib/libfetch/common.h
   1.99      +7 -5      src/lib/libfetch/ftp.c
   1.81      +5 -3      src/lib/libfetch/http.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Fri Feb 29 01:53:13 UTC 2008 
State-Changed-Why:  
MFCed to RELENG_6 as 1.50.2.1 on Jan 24 2008. 

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