1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-17 15:44:34 +02:00

* gpgkeys_hkp.c (send_key, get_key, main): Work with new HTTP code that

passes the proxy in from the outside.  If the command file sends a proxy,
use it.  If it sends "http-proxy" with no arguments, use $http_proxy from
the environment.
This commit is contained in:
David Shaw 2003-12-28 16:21:46 +00:00
parent 48238805b9
commit f13f772a29
2 changed files with 37 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2003-12-28 David Shaw <dshaw@jabberwocky.com>
* gpgkeys_hkp.c (send_key, get_key, main): Work with new HTTP code
that passes the proxy in from the outside. If the command file
sends a proxy, use it. If it sends "http-proxy" with no
arguments, use $http_proxy from the environment.
2003-12-28 Stefan Bellon <sbellon@sbellon.de> 2003-12-28 Stefan Bellon <sbellon@sbellon.de>
* gpgkeys_hkp.c, gpgkeys_ldap.c [__riscos__]: Removal of * gpgkeys_hkp.c, gpgkeys_ldap.c [__riscos__]: Removal of

View File

@ -1,5 +1,5 @@
/* gpgkeys_hkp.c - talk to an HKP keyserver /* gpgkeys_hkp.c - talk to an HKP keyserver
* Copyright (C) 2001, 2002 Free Software Foundation, Inc. * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -43,7 +43,7 @@ extern int optind;
int verbose=0,include_revoked=0,include_disabled=0; int verbose=0,include_revoked=0,include_disabled=0;
unsigned int http_flags=0; unsigned int http_flags=0;
char host[80]={'\0'},port[10]={'\0'}; char host[80]={'\0'},proxy[80]={'\0'},port[10]={'\0'};
FILE *input=NULL,*output=NULL,*console=NULL; FILE *input=NULL,*output=NULL,*console=NULL;
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----" #define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
@ -55,6 +55,12 @@ struct keylist
struct keylist *next; struct keylist *next;
}; };
#ifdef __riscos__
#define HTTP_PROXY_ENV "GnuPG$HttpProxy"
#else
#define HTTP_PROXY_ENV "http_proxy"
#endif
int int
urlencode_filter( void *opaque, int control, urlencode_filter( void *opaque, int control,
IOBUF a, byte *buf, size_t *ret_len) IOBUF a, byte *buf, size_t *ret_len)
@ -152,7 +158,7 @@ send_key(int *eof)
if(verbose>2) if(verbose>2)
fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request); fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request);
rc=http_open(&hd,HTTP_REQ_POST,request,http_flags); rc=http_open(&hd,HTTP_REQ_POST,request,http_flags,proxy[0]?proxy:NULL);
if(rc) if(rc)
{ {
fprintf(console,"gpgkeys: unable to connect to `%s'\n",host); fprintf(console,"gpgkeys: unable to connect to `%s'\n",host);
@ -256,7 +262,7 @@ get_key(char *getkey)
if(verbose>2) if(verbose>2)
fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request); fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request);
rc=http_open_document(&hd,request,http_flags); rc=http_open_document(&hd,request,http_flags,proxy[0]?proxy:NULL);
if(rc!=0) if(rc!=0)
{ {
fprintf(console,"gpgkeys: HKP fetch error: %s\n", fprintf(console,"gpgkeys: HKP fetch error: %s\n",
@ -666,7 +672,7 @@ search_key(char *searchkey)
if(verbose>2) if(verbose>2)
fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request); fprintf(console,"gpgkeys: HTTP URL is \"%s\"\n",request);
rc=http_open_document(&hd,request,http_flags); rc=http_open_document(&hd,request,http_flags,proxy[0]?proxy:NULL);
if(rc) if(rc)
{ {
fprintf(console,"gpgkeys: can't search keyserver `%s': %s\n", fprintf(console,"gpgkeys: can't search keyserver `%s': %s\n",
@ -795,7 +801,7 @@ main(int argc,char *argv[])
{ {
int version; int version;
char commandstr[7]; char commandstr[7];
char optionstr[30]; char optionstr[110];
char hash; char hash;
if(line[0]=='\n') if(line[0]=='\n')
@ -841,12 +847,12 @@ main(int argc,char *argv[])
continue; continue;
} }
if(sscanf(line,"OPTION %29s\n",optionstr)==1) if(sscanf(line,"OPTION %109s\n",optionstr)==1)
{ {
int no=0; int no=0;
char *start=&optionstr[0]; char *start=&optionstr[0];
optionstr[29]='\0'; optionstr[109]='\0';
if(strncasecmp(optionstr,"no-",3)==0) if(strncasecmp(optionstr,"no-",3)==0)
{ {
@ -875,13 +881,24 @@ main(int argc,char *argv[])
else else
include_disabled=1; include_disabled=1;
} }
else if(strcasecmp(start,"honor-http-proxy")==0) else if(strncasecmp(start,"http-proxy",10)==0)
{ {
if(no) if(no)
http_flags&=~HTTP_FLAG_TRY_PROXY; proxy[0]='\0';
else else if(start[10]=='=')
http_flags|=HTTP_FLAG_TRY_PROXY; {
strncpy(proxy,&start[11],79);
proxy[79]='\0';
}
else if(start[10]=='\0')
{
char *http_proxy=getenv(HTTP_PROXY_ENV);
if(http_proxy)
{
strncpy(proxy,http_proxy,79);
proxy[79]='\0';
}
}
} }
else if(strcasecmp(start,"broken-http-proxy")==0) else if(strcasecmp(start,"broken-http-proxy")==0)
{ {