Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Sep 2004 03:20:14 +0200
From:      "\"Florent Thoumie\" <Florent Thoumie" <flz@xbsd.org>
To:        "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org>
Cc:        kuriyama@FreeBSD.org
Subject:   ports/71214: security/gnupg - add patch to support http-proxy authentication
Message-ID:  <1094001614.0@innercity.xbsd.org>
Resent-Message-ID: <200409010130.i811UQ93047824@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         71214
>Category:       ports
>Synopsis:       security/gnupg - add patch to support http-proxy authentication
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 01 01:30:25 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Florent Thoumie
>Release:        FreeBSD 5.2-CURRENT i386
>Organization:
Xbsd.org 
>Environment:


System: FreeBSD 5.2-CURRENT #0: Tue Jul 27 03:52:18 CEST 2004
    root@innercity.xbsd.org:/usr/obj/usr/src/sys/INNERCITY



>Description:


This is a simple patch to add http-proxy authentication support


>How-To-Repeat:


Put these patches in files/


>Fix:


--- patch-util::http.c begins here ---
--- util/http.c	2004-08-23 17:28:14.000000000 +0200
+++ util/http.c.new	2004-09-01 02:23:02.000000000 +0200
@@ -42,6 +42,7 @@
 #include "util.h"
 #include "iobuf.h"
 #include "i18n.h"
+#include "g10/main.h"
 
 #include "http.h"
 
@@ -303,6 +304,17 @@
 	    p++;
 	    if( (p2 = strchr(p, '/')) )
 		*p2++ = 0;
+
+	    p3 = p;
+	    if( (p=strchr( p3, '@' )) ) {
+		*p++ = 0;
+		uri->user = p3;
+		if ( !(uri->pass = strchr( p3, ':' )) )
+		  return G10ERR_INVALID_URI;
+		*uri->pass++ = 0;
+	    }
+	    else p = p3;
+
 	    strlwr( p );
 	    uri->host = p;
 	    if( (p3=strchr( p, ':' )) ) {
@@ -472,9 +484,11 @@
 {
     const byte *server;
     byte *request, *p;
+    byte *cred;
     ushort port;
     int rc;
     const char *http_proxy = NULL;
+    char *cookie = NULL;
 
     server = *hd->uri->host? hd->uri->host : "localhost";
     port   = hd->uri->port?  hd->uri->port : 80;
@@ -492,6 +506,12 @@
 	}
 	hd->sock = connect_server( *uri->host? uri->host : "localhost",
 				    uri->port? uri->port : 80 );
+	if ( uri->user && uri->pass )
+	{
+	  cred = m_alloc( strlen(uri->user) + strlen(uri->pass) + 2 );
+	  sprintf( cred, "%s:%s", uri->user, uri->pass );
+	  cookie = make_radix64_string( cred, strlen(cred) );
+	}
 	release_parsed_uri( uri );
     }
     else
@@ -501,9 +521,15 @@
 	return G10ERR_NETWORK;
 
     p = build_rel_path( hd->uri );
-    request = m_alloc( strlen(server)*2 + strlen(p) + 50 );
+    request = m_alloc( strlen(server)*2 + strlen(p) + 80 + strlen(cookie ? cookie : "") );
     if( http_proxy ) {
-	sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\n",
+	if ( cookie )
+	  sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\nProxy-Authorization: Basic %s\r\n\r",
+			  hd->req_type == HTTP_REQ_GET ? "GET" :
+			  hd->req_type == HTTP_REQ_HEAD? "HEAD":
+			  hd->req_type == HTTP_REQ_POST? "POST": "OOPS",
+			  server, port,  *p == '/'? "":"/", p, cookie );
+	else sprintf( request, "%s http://%s:%hu%s%s HTTP/1.0\r\n\r",
 			  hd->req_type == HTTP_REQ_GET ? "GET" :
 			  hd->req_type == HTTP_REQ_HEAD? "HEAD":
 			  hd->req_type == HTTP_REQ_POST? "POST": "OOPS",
--- patch-util::http.c ends here ---
--- patch-include::http.h begins here ---
--- include/http.h	2002-06-29 15:26:17.000000000 +0200
+++ include/http.h.new	2004-09-01 02:10:14.000000000 +0200
@@ -34,6 +34,8 @@
 struct parsed_uri {
     /* all these pointers point into buffer; most stuff is not escaped */
     char *scheme;	/* pointer to the scheme string (lowercase) */
+    char *user;		/* username for basic proxy authentication */
+    char *pass;		/* password for basic proxy authentication */
     char *host; 	/* host (converted to lowercase) */
     ushort port;	/* port (always set if the host is set) */
     char *path; 	/* the path */
--- patch-include::http.h ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1094001614.0>