mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-11 22:52:47 +01:00
* gpgkeys_mailto.in, gpgkeys_test.in: Use @VERSION@ so version string
stays up to date. * gpgkeys_http.c: Don't need to define HTTP_PROXY_ENV here since it's in ksutil.h. * gpgkeys_curl.c (get_key, main), gpgkeys_hkp.c (main): Pass AUTH values to curl or curl-shim. * curl-shim.c (curl_easy_perform), gpgkeys_curl.c (main), gpgkeys_hkp.c (main): Use curl-style proxy semantics.
This commit is contained in:
parent
d65763eccd
commit
ccab129be5
@ -1,5 +1,17 @@
|
|||||||
2005-06-23 David Shaw <dshaw@jabberwocky.com>
|
2005-06-23 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* gpgkeys_mailto.in, gpgkeys_test.in: Use @VERSION@ so version
|
||||||
|
string stays up to date.
|
||||||
|
|
||||||
|
* gpgkeys_http.c: Don't need to define HTTP_PROXY_ENV here since
|
||||||
|
it's in ksutil.h.
|
||||||
|
|
||||||
|
* gpgkeys_curl.c (get_key, main), gpgkeys_hkp.c (main): Pass AUTH
|
||||||
|
values to curl or curl-shim.
|
||||||
|
|
||||||
|
* curl-shim.c (curl_easy_perform), gpgkeys_curl.c (main),
|
||||||
|
gpgkeys_hkp.c (main): Use curl-style proxy semantics.
|
||||||
|
|
||||||
* curl-shim.h, curl-shim.c (curl_easy_setopt, curl_easy_perform):
|
* curl-shim.h, curl-shim.c (curl_easy_setopt, curl_easy_perform):
|
||||||
Add CURLOPT_USERPWD option for HTTP auth.
|
Add CURLOPT_USERPWD option for HTTP auth.
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "ksutil.h"
|
||||||
#include "curl-shim.h"
|
#include "curl-shim.h"
|
||||||
|
|
||||||
static CURLcode
|
static CURLcode
|
||||||
@ -142,10 +143,24 @@ curl_easy_perform(CURL *curl)
|
|||||||
int rc;
|
int rc;
|
||||||
CURLcode err=CURLE_OK;
|
CURLcode err=CURLE_OK;
|
||||||
const char *errstr=NULL;
|
const char *errstr=NULL;
|
||||||
|
char *proxy=NULL;
|
||||||
|
|
||||||
|
/* Emulate the libcurl proxy behavior. If the calling program set a
|
||||||
|
proxy, use it. If it didn't set a proxy or set it to NULL, check
|
||||||
|
for one in the environment. If the calling program explicitly
|
||||||
|
set a null-string proxy, don't set a proxy at all. */
|
||||||
|
|
||||||
|
if(curl->proxy)
|
||||||
|
{
|
||||||
|
if(*curl->proxy)
|
||||||
|
proxy=curl->proxy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
proxy=getenv(HTTP_PROXY_ENV);
|
||||||
|
|
||||||
if(curl->flags.post)
|
if(curl->flags.post)
|
||||||
{
|
{
|
||||||
rc=http_open(&curl->hd,HTTP_REQ_POST,curl->url,curl->auth,0,curl->proxy);
|
rc=http_open(&curl->hd,HTTP_REQ_POST,curl->url,curl->auth,0,proxy);
|
||||||
if(rc==0)
|
if(rc==0)
|
||||||
{
|
{
|
||||||
char content_len[50];
|
char content_len[50];
|
||||||
@ -166,7 +181,7 @@ curl_easy_perform(CURL *curl)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rc=http_open(&curl->hd,HTTP_REQ_GET,curl->url,curl->auth,0,curl->proxy);
|
rc=http_open(&curl->hd,HTTP_REQ_GET,curl->url,curl->auth,0,proxy);
|
||||||
if(rc==0)
|
if(rc==0)
|
||||||
{
|
{
|
||||||
rc=http_wait_response(&curl->hd,&curl->status);
|
rc=http_wait_response(&curl->hd,&curl->status);
|
||||||
|
@ -58,11 +58,8 @@ get_key(char *getkey)
|
|||||||
|
|
||||||
fprintf(output,"KEY 0x%s BEGIN\n",getkey);
|
fprintf(output,"KEY 0x%s BEGIN\n",getkey);
|
||||||
|
|
||||||
sprintf(request,"%s://%s%s%s%s%s%s",opt->scheme,
|
sprintf(request,"%s://%s%s%s%s",opt->scheme,opt->host,
|
||||||
opt->auth?opt->auth:"",
|
opt->port?":":"",opt->port?opt->port:"",opt->path?opt->path:"/");
|
||||||
opt->auth?"@":"",opt->host,
|
|
||||||
opt->port?":":"",opt->port?opt->port:"",
|
|
||||||
opt->path?opt->path:"/");
|
|
||||||
|
|
||||||
curl_easy_setopt(curl,CURLOPT_URL,request);
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
||||||
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
|
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
|
||||||
@ -98,7 +95,7 @@ main(int argc,char *argv[])
|
|||||||
char line[MAX_LINE];
|
char line[MAX_LINE];
|
||||||
char *thekey=NULL;
|
char *thekey=NULL;
|
||||||
long follow_redirects=5;
|
long follow_redirects=5;
|
||||||
char proxy[MAX_PROXY+1];
|
char *proxy=NULL;
|
||||||
|
|
||||||
console=stderr;
|
console=stderr;
|
||||||
|
|
||||||
@ -193,20 +190,19 @@ main(int argc,char *argv[])
|
|||||||
|
|
||||||
if(strncasecmp(start,"http-proxy",10)==0)
|
if(strncasecmp(start,"http-proxy",10)==0)
|
||||||
{
|
{
|
||||||
|
/* Safe to not check the return code of strdup() here.
|
||||||
|
If it fails, we simply won't use a proxy. */
|
||||||
if(no)
|
if(no)
|
||||||
proxy[0]='\0';
|
{
|
||||||
|
free(proxy);
|
||||||
|
proxy=strdup("");
|
||||||
|
}
|
||||||
else if(start[10]=='=')
|
else if(start[10]=='=')
|
||||||
{
|
{
|
||||||
strncpy(proxy,&start[11],MAX_PROXY);
|
if(strlen(&start[11])<MAX_PROXY)
|
||||||
proxy[MAX_PROXY]='\0';
|
|
||||||
}
|
|
||||||
else if(start[10]=='\0')
|
|
||||||
{
|
|
||||||
char *http_proxy=getenv(HTTP_PROXY_ENV);
|
|
||||||
if(http_proxy)
|
|
||||||
{
|
{
|
||||||
strncpy(proxy,http_proxy,MAX_PROXY);
|
free(proxy);
|
||||||
proxy[MAX_PROXY]='\0';
|
proxy=strdup(&start[11]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,6 +276,9 @@ main(int argc,char *argv[])
|
|||||||
curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
|
curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(opt->auth)
|
||||||
|
curl_easy_setopt(curl,CURLOPT_USERPWD,opt->auth);
|
||||||
|
|
||||||
if(opt->debug)
|
if(opt->debug)
|
||||||
{
|
{
|
||||||
curl_easy_setopt(curl,CURLOPT_STDERR,console);
|
curl_easy_setopt(curl,CURLOPT_STDERR,console);
|
||||||
@ -289,7 +288,7 @@ main(int argc,char *argv[])
|
|||||||
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,opt->flags.check_cert);
|
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,opt->flags.check_cert);
|
||||||
curl_easy_setopt(curl,CURLOPT_CAINFO,opt->ca_cert_file);
|
curl_easy_setopt(curl,CURLOPT_CAINFO,opt->ca_cert_file);
|
||||||
|
|
||||||
if(proxy[0])
|
if(proxy)
|
||||||
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
|
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
|
||||||
|
|
||||||
/* If it's a GET or a SEARCH, the next thing to come in is the
|
/* If it's a GET or a SEARCH, the next thing to come in is the
|
||||||
@ -372,6 +371,8 @@ main(int argc,char *argv[])
|
|||||||
if(curl)
|
if(curl)
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
free(proxy);
|
||||||
|
|
||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind;
|
extern int optind;
|
||||||
|
|
||||||
static char proxy[MAX_PROXY+1];
|
|
||||||
static FILE *input,*output,*console;
|
static FILE *input,*output,*console;
|
||||||
static CURL *curl;
|
static CURL *curl;
|
||||||
static struct ks_options *opt;
|
static struct ks_options *opt;
|
||||||
@ -384,6 +383,7 @@ main(int argc,char *argv[])
|
|||||||
char line[MAX_LINE];
|
char line[MAX_LINE];
|
||||||
int failed=0;
|
int failed=0;
|
||||||
struct keylist *keylist=NULL,*keyptr=NULL;
|
struct keylist *keylist=NULL,*keyptr=NULL;
|
||||||
|
char *proxy=NULL;
|
||||||
|
|
||||||
console=stderr;
|
console=stderr;
|
||||||
|
|
||||||
@ -479,19 +479,16 @@ main(int argc,char *argv[])
|
|||||||
if(strncasecmp(start,"http-proxy",10)==0)
|
if(strncasecmp(start,"http-proxy",10)==0)
|
||||||
{
|
{
|
||||||
if(no)
|
if(no)
|
||||||
proxy[0]='\0';
|
{
|
||||||
|
free(proxy);
|
||||||
|
proxy=strdup("");
|
||||||
|
}
|
||||||
else if(start[10]=='=')
|
else if(start[10]=='=')
|
||||||
{
|
{
|
||||||
strncpy(proxy,&start[11],MAX_PROXY);
|
if(strlen(&start[11])<MAX_PROXY)
|
||||||
proxy[MAX_PROXY]='\0';
|
|
||||||
}
|
|
||||||
else if(start[10]=='\0')
|
|
||||||
{
|
|
||||||
char *http_proxy=getenv(HTTP_PROXY_ENV);
|
|
||||||
if(http_proxy)
|
|
||||||
{
|
{
|
||||||
strncpy(proxy,http_proxy,MAX_PROXY);
|
free(proxy);
|
||||||
proxy[MAX_PROXY]='\0';
|
proxy=strdup(&start[11]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,13 +528,16 @@ main(int argc,char *argv[])
|
|||||||
|
|
||||||
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
|
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
|
||||||
|
|
||||||
|
if(opt->auth)
|
||||||
|
curl_easy_setopt(curl,CURLOPT_USERPWD,opt->auth);
|
||||||
|
|
||||||
if(opt->debug)
|
if(opt->debug)
|
||||||
{
|
{
|
||||||
curl_easy_setopt(curl,CURLOPT_STDERR,console);
|
curl_easy_setopt(curl,CURLOPT_STDERR,console);
|
||||||
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
|
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(proxy[0])
|
if(proxy)
|
||||||
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
|
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -704,5 +704,12 @@ main(int argc,char *argv[])
|
|||||||
if(output!=stdout)
|
if(output!=stdout)
|
||||||
fclose(output);
|
fclose(output);
|
||||||
|
|
||||||
|
free_ks_options(opt);
|
||||||
|
|
||||||
|
if(curl)
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
free(proxy);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,6 @@ static char port[MAX_PORT+1];
|
|||||||
static char path[URLMAX_PATH+1];
|
static char path[URLMAX_PATH+1];
|
||||||
static FILE *input,*output,*console;
|
static FILE *input,*output,*console;
|
||||||
|
|
||||||
#ifdef __riscos__
|
|
||||||
#define HTTP_PROXY_ENV "GnuPG$HttpProxy"
|
|
||||||
#else
|
|
||||||
#define HTTP_PROXY_ENV "http_proxy"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_key(char *getkey)
|
get_key(char *getkey)
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ $sendmail="@SENDMAIL@ -t";
|
|||||||
|
|
||||||
sub VERSION_MESSAGE ()
|
sub VERSION_MESSAGE ()
|
||||||
{
|
{
|
||||||
print STDOUT "gpgkeys_mailto (GnuPG) 1.3.91-cvs\n";
|
print STDOUT "gpgkeys_mailto (GnuPG) @VERSION@\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HELP_MESSAGE ()
|
sub HELP_MESSAGE ()
|
||||||
|
@ -26,7 +26,7 @@ $|=1;
|
|||||||
|
|
||||||
sub VERSION_MESSAGE ()
|
sub VERSION_MESSAGE ()
|
||||||
{
|
{
|
||||||
print STDOUT "gpgkeys_test (GnuPG) 1.3.91-cvs\n";
|
print STDOUT "gpgkeys_test (GnuPG) @VERSION@\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub HELP_MESSAGE ()
|
sub HELP_MESSAGE ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user