diff options
author | David Shaw <[email protected]> | 2004-12-22 05:23:22 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2004-12-22 05:23:22 +0000 |
commit | f150d44a313dfa8c244687feb15fcfbcd6f3b3d2 (patch) | |
tree | 75845a67d77158185544da96acb209e8b57570c1 | |
parent | * autogen.sh: automake needs --add-missing for conditional CPPFLAGS build (diff) | |
download | gnupg-f150d44a313dfa8c244687feb15fcfbcd6f3b3d2.tar.gz gnupg-f150d44a313dfa8c244687feb15fcfbcd6f3b3d2.zip |
* gpgkeys_ftp.c (main, get_key): Use auth data as passed by gpg. Use
CURLOPT_FILE instead of CURLOPT_WRITEDATA (same option, but backwards
compatible).
Diffstat (limited to '')
-rw-r--r-- | keyserver/ChangeLog | 6 | ||||
-rw-r--r-- | keyserver/gpgkeys_ftp.c | 19 |
2 files changed, 19 insertions, 6 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index 967eb299a..f4ae97201 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,9 @@ +2004-12-22 David Shaw <[email protected]> + + * gpgkeys_ftp.c (main, get_key): Use auth data as passed by gpg. + Use CURLOPT_FILE instead of CURLOPT_WRITEDATA (same option, but + backwards compatible). + 2004-12-21 David Shaw <[email protected]> * gpgkeys_ftp.c: New. diff --git a/keyserver/gpgkeys_ftp.c b/keyserver/gpgkeys_ftp.c index 239a6719c..74977e351 100644 --- a/keyserver/gpgkeys_ftp.c +++ b/keyserver/gpgkeys_ftp.c @@ -37,15 +37,16 @@ extern int optind; #define GET 0 #define MAX_LINE 80 #define MAX_PATH 1023 +#define MAX_AUTH 127 #define MAX_HOST 79 #define MAX_PORT 9 -#define MAX_URL (3+3+MAX_HOST+1+1+MAX_PORT+1+1+MAX_PATH+1+50) +#define MAX_URL (3+3+MAX_AUTH+1+MAX_HOST+1+1+MAX_PORT+1+1+MAX_PATH+1+50) #define STRINGIFY(x) #x #define MKSTRING(x) STRINGIFY(x) static int verbose=0; -static char host[MAX_HOST+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'}; +static char auth[MAX_AUTH+1],host[MAX_HOST+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'}; static FILE *input=NULL,*output=NULL,*console=NULL; static CURL *curl; static char request[MAX_URL]={'\0'}; @@ -61,12 +62,12 @@ get_key(char *getkey) fprintf(output,"KEY 0x%s BEGIN\n",getkey); - sprintf(request,"ftp://%s%s%s%s%s",host,port[0]?":":"", - port[0]?port:"",path[0]?"":"/",path); + sprintf(request,"ftp://%s%s%s%s%s%s%s",auth[0]?auth:"",auth[0]?"@":"", + host,port[0]?":":"",port[0]?port:"",path[0]?"":"/",path); curl_easy_setopt(curl,CURLOPT_URL,request); curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,fwrite); - curl_easy_setopt(curl,CURLOPT_WRITEDATA,output); + curl_easy_setopt(curl,CURLOPT_FILE,output); curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer); if(verbose>2) @@ -132,7 +133,7 @@ main(int argc,char *argv[]) return KEYSERVER_OK; case 'o': - output=fopen(optarg,"w"); + output=fopen(optarg,"wb"); if(output==NULL) { fprintf(console,"gpgkeys: Cannot open output file `%s': %s\n", @@ -185,6 +186,12 @@ main(int argc,char *argv[]) continue; } + if(sscanf(line,"AUTH %" MKSTRING(MAX_AUTH) "s\n",auth)==1) + { + host[MAX_AUTH]='\0'; + continue; + } + if(sscanf(line,"HOST %" MKSTRING(MAX_HOST) "s\n",host)==1) { host[MAX_HOST]='\0'; |