mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
* gpgkeys_curl.c (main): If the http-proxy option is given without any
arguments, try to get the proxy from the environment. * ksutil.h, ksutil.c (curl_err_to_gpg_err, curl_writer): Copy from gpgkeys_curl.c. * gpgkeys_oldhkp.c: Copy from gpgkeys_hkp.c.
This commit is contained in:
parent
799f97ceee
commit
5748f595b0
@ -1,3 +1,13 @@
|
|||||||
|
2005-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* gpgkeys_curl.c (main): If the http-proxy option is given without
|
||||||
|
any arguments, try to get the proxy from the environment.
|
||||||
|
|
||||||
|
* ksutil.h, ksutil.c (curl_err_to_gpg_err, curl_writer): Copy from
|
||||||
|
gpgkeys_curl.c.
|
||||||
|
|
||||||
|
* gpgkeys_oldhkp.c: Copy from gpgkeys_hkp.c.
|
||||||
|
|
||||||
2005-03-22 David Shaw <dshaw@jabberwocky.com>
|
2005-03-22 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* gpgkeys_ldap.c, ksutil.h, ksutil.c (print_nocr): Moved from
|
* gpgkeys_ldap.c, ksutil.h, ksutil.c (print_nocr): Moved from
|
||||||
|
@ -38,72 +38,10 @@
|
|||||||
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;
|
||||||
|
|
||||||
static int
|
|
||||||
curl_err_to_gpg_err(CURLcode error)
|
|
||||||
{
|
|
||||||
switch(error)
|
|
||||||
{
|
|
||||||
case CURLE_FTP_COULDNT_RETR_FILE: return KEYSERVER_KEY_NOT_FOUND;
|
|
||||||
default: return KEYSERVER_INTERNAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t
|
|
||||||
writer(const void *ptr,size_t size,size_t nmemb,void *stream)
|
|
||||||
{
|
|
||||||
const char *buf=ptr;
|
|
||||||
size_t i;
|
|
||||||
static int markeridx=0,begun=0,done=0;
|
|
||||||
static const char *marker=BEGIN;
|
|
||||||
|
|
||||||
/* scan the incoming data for our marker */
|
|
||||||
for(i=0;!done && i<(size*nmemb);i++)
|
|
||||||
{
|
|
||||||
if(buf[i]==marker[markeridx])
|
|
||||||
{
|
|
||||||
markeridx++;
|
|
||||||
if(marker[markeridx]=='\0')
|
|
||||||
{
|
|
||||||
if(begun)
|
|
||||||
done=1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* We've found the BEGIN marker, so now we're looking
|
|
||||||
for the END marker. */
|
|
||||||
begun=1;
|
|
||||||
marker=END;
|
|
||||||
markeridx=0;
|
|
||||||
fprintf(output,BEGIN);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
markeridx=0;
|
|
||||||
|
|
||||||
if(begun)
|
|
||||||
{
|
|
||||||
/* Canonicalize CRLF to just LF by stripping CRs. This
|
|
||||||
actually makes sense, since on Unix-like machines LF is
|
|
||||||
correct, and on win32-like machines, our output buffer is
|
|
||||||
opened in textmode and will re-canonicalize line endings
|
|
||||||
back to CRLF. Since we only need to handle armored keys,
|
|
||||||
we don't have to worry about odd cases like CRCRCR and
|
|
||||||
the like. */
|
|
||||||
|
|
||||||
if(buf[i]!='\r')
|
|
||||||
fputc(buf[i],output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return size*nmemb;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_key(char *getkey)
|
get_key(char *getkey)
|
||||||
{
|
{
|
||||||
@ -123,7 +61,7 @@ get_key(char *getkey)
|
|||||||
opt->path?opt->path:"/");
|
opt->path?opt->path:"/");
|
||||||
|
|
||||||
curl_easy_setopt(curl,CURLOPT_URL,request);
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
||||||
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,writer);
|
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
|
||||||
curl_easy_setopt(curl,CURLOPT_FILE,output);
|
curl_easy_setopt(curl,CURLOPT_FILE,output);
|
||||||
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
|
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
|
||||||
|
|
||||||
@ -155,6 +93,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];
|
||||||
|
|
||||||
console=stderr;
|
console=stderr;
|
||||||
|
|
||||||
@ -256,6 +195,15 @@ main(int argc,char *argv[])
|
|||||||
strncpy(proxy,&start[11],MAX_PROXY);
|
strncpy(proxy,&start[11],MAX_PROXY);
|
||||||
proxy[MAX_PROXY]='\0';
|
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);
|
||||||
|
proxy[MAX_PROXY]='\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strncasecmp(start,"follow-redirects",16)==0)
|
else if(strncasecmp(start,"follow-redirects",16)==0)
|
||||||
{
|
{
|
||||||
|
1138
keyserver/gpgkeys_oldhkp.c
Normal file
1138
keyserver/gpgkeys_oldhkp.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef FAKE_CURL
|
||||||
|
#include "curl-shim.h"
|
||||||
|
#else
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
#include "keyserver.h"
|
#include "keyserver.h"
|
||||||
#include "ksutil.h"
|
#include "ksutil.h"
|
||||||
|
|
||||||
@ -312,3 +317,64 @@ print_nocr(FILE *stream,const char *str)
|
|||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
curl_err_to_gpg_err(CURLcode error)
|
||||||
|
{
|
||||||
|
switch(error)
|
||||||
|
{
|
||||||
|
case CURLE_FTP_COULDNT_RETR_FILE: return KEYSERVER_KEY_NOT_FOUND;
|
||||||
|
default: return KEYSERVER_INTERNAL_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
curl_writer(const void *ptr,size_t size,size_t nmemb,void *stream)
|
||||||
|
{
|
||||||
|
const char *buf=ptr;
|
||||||
|
size_t i;
|
||||||
|
static int markeridx=0,begun=0,done=0;
|
||||||
|
static const char *marker=BEGIN;
|
||||||
|
|
||||||
|
/* scan the incoming data for our marker */
|
||||||
|
for(i=0;!done && i<(size*nmemb);i++)
|
||||||
|
{
|
||||||
|
if(buf[i]==marker[markeridx])
|
||||||
|
{
|
||||||
|
markeridx++;
|
||||||
|
if(marker[markeridx]=='\0')
|
||||||
|
{
|
||||||
|
if(begun)
|
||||||
|
done=1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We've found the BEGIN marker, so now we're looking
|
||||||
|
for the END marker. */
|
||||||
|
begun=1;
|
||||||
|
marker=END;
|
||||||
|
markeridx=0;
|
||||||
|
fprintf(stream,BEGIN);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
markeridx=0;
|
||||||
|
|
||||||
|
if(begun)
|
||||||
|
{
|
||||||
|
/* Canonicalize CRLF to just LF by stripping CRs. This
|
||||||
|
actually makes sense, since on Unix-like machines LF is
|
||||||
|
correct, and on win32-like machines, our output buffer is
|
||||||
|
opened in textmode and will re-canonicalize line endings
|
||||||
|
back to CRLF. Since we only need to handle armored keys,
|
||||||
|
we don't have to worry about odd cases like CRCRCR and
|
||||||
|
the like. */
|
||||||
|
|
||||||
|
if(buf[i]!='\r')
|
||||||
|
fputc(buf[i],stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return size*nmemb;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,12 @@
|
|||||||
#ifndef _KSUTIL_H_
|
#ifndef _KSUTIL_H_
|
||||||
#define _KSUTIL_H_
|
#define _KSUTIL_H_
|
||||||
|
|
||||||
|
#ifdef FAKE_CURL
|
||||||
|
#include "curl-shim.h"
|
||||||
|
#else
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GET 0
|
#define GET 0
|
||||||
#define SEND 1
|
#define SEND 1
|
||||||
#define SEARCH 2
|
#define SEARCH 2
|
||||||
@ -47,6 +53,12 @@
|
|||||||
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
|
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
|
||||||
#define END "-----END PGP PUBLIC KEY BLOCK-----"
|
#define END "-----END PGP PUBLIC KEY BLOCK-----"
|
||||||
|
|
||||||
|
#ifdef __riscos__
|
||||||
|
#define HTTP_PROXY_ENV "GnuPG$HttpProxy"
|
||||||
|
#else
|
||||||
|
#define HTTP_PROXY_ENV "http_proxy"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct keylist
|
struct keylist
|
||||||
{
|
{
|
||||||
char str[MAX_LINE];
|
char str[MAX_LINE];
|
||||||
@ -88,5 +100,7 @@ void free_ks_options(struct ks_options *opt);
|
|||||||
int parse_ks_options(char *line,struct ks_options *opt);
|
int parse_ks_options(char *line,struct ks_options *opt);
|
||||||
const char *ks_action_to_string(enum ks_action action);
|
const char *ks_action_to_string(enum ks_action action);
|
||||||
void print_nocr(FILE *stream,const char *str);
|
void print_nocr(FILE *stream,const char *str);
|
||||||
|
int curl_err_to_gpg_err(CURLcode error);
|
||||||
|
size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *stream);
|
||||||
|
|
||||||
#endif /* !_KSUTIL_H_ */
|
#endif /* !_KSUTIL_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user