2002-06-29 13:31:13 +00:00
|
|
|
/* gpgkeys_hkp.c - talk to an HKP keyserver
|
2005-01-13 23:37:26 +00:00
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
2002-06-29 13:31:13 +00:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-05-31 08:39:18 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
2002-06-29 13:31:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2002-08-27 19:11:36 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
2003-05-31 03:52:02 +00:00
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
#include <getopt.h>
|
|
|
|
#endif
|
2006-04-26 21:48:29 +00:00
|
|
|
#ifdef HAVE_LIBCURL
|
2005-04-17 02:18:32 +00:00
|
|
|
#include <curl/curl.h>
|
2006-04-26 21:48:29 +00:00
|
|
|
#else
|
|
|
|
#include "curl-shim.h"
|
2005-04-17 02:18:32 +00:00
|
|
|
#endif
|
2002-08-27 19:11:36 +00:00
|
|
|
#include "keyserver.h"
|
2004-10-13 18:30:29 +00:00
|
|
|
#include "ksutil.h"
|
2002-08-27 12:44:18 +00:00
|
|
|
|
2003-05-31 03:52:02 +00:00
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
static FILE *input,*output,*console;
|
|
|
|
static CURL *curl;
|
|
|
|
static struct ks_options *opt;
|
|
|
|
static char errorbuffer[CURL_ERROR_SIZE];
|
2003-12-28 16:21:46 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
static size_t
|
|
|
|
curl_mrindex_writer(const void *ptr,size_t size,size_t nmemb,void *stream)
|
2002-08-27 12:44:18 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
static int checked=0,swallow=0;
|
|
|
|
|
|
|
|
if(!checked)
|
|
|
|
{
|
|
|
|
/* If the document begins with a '<', assume it's a HTML
|
|
|
|
response, which we don't support. Discard the whole message
|
|
|
|
body. GPG can handle it, but this is an optimization to deal
|
|
|
|
with it on this side of the pipe. */
|
|
|
|
const char *buf=ptr;
|
|
|
|
if(buf[0]=='<')
|
|
|
|
swallow=1;
|
|
|
|
|
|
|
|
checked=1;
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
|
|
|
|
if(swallow || fwrite(ptr,size,nmemb,stream)==nmemb)
|
|
|
|
return size*nmemb;
|
|
|
|
else
|
|
|
|
return 0;
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2005-06-21 04:24:10 +00:00
|
|
|
/* Append but avoid creating a double slash // in the path. */
|
|
|
|
static char *
|
|
|
|
append_path(char *dest,const char *src)
|
|
|
|
{
|
|
|
|
size_t n=strlen(dest);
|
|
|
|
|
|
|
|
if(src[0]=='/' && n>0 && dest[n-1]=='/')
|
|
|
|
dest[n-1]='\0';
|
|
|
|
|
|
|
|
return strcat(dest,src);
|
|
|
|
}
|
|
|
|
|
2002-09-13 18:45:36 +00:00
|
|
|
int
|
2002-09-24 19:50:09 +00:00
|
|
|
send_key(int *eof)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
CURLcode res;
|
2005-06-04 23:09:27 +00:00
|
|
|
char request[MAX_URL+15];
|
2005-04-17 02:18:32 +00:00
|
|
|
int begin=0,end=0,ret=KEYSERVER_INTERNAL_ERROR;
|
2006-07-14 16:07:01 +00:00
|
|
|
char keyid[17],state[6];
|
2002-08-27 19:11:36 +00:00
|
|
|
char line[MAX_LINE];
|
2006-01-16 17:59:46 +00:00
|
|
|
char *key=NULL,*encoded_key=NULL;
|
|
|
|
size_t keylen=0,keymax=0;
|
2005-05-02 00:46:39 +00:00
|
|
|
|
2002-08-28 04:04:37 +00:00
|
|
|
/* Read and throw away input until we see the BEGIN */
|
2002-06-29 13:31:13 +00:00
|
|
|
|
|
|
|
while(fgets(line,MAX_LINE,input)!=NULL)
|
2006-07-17 04:11:30 +00:00
|
|
|
if(sscanf(line,"KEY%*[ ]%16s%*[ ]%5s\n",keyid,state)==2
|
2006-07-14 16:07:01 +00:00
|
|
|
&& strcmp(state,"BEGIN")==0)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2002-11-04 13:59:08 +00:00
|
|
|
begin=1;
|
2002-06-29 13:31:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-11-04 13:59:08 +00:00
|
|
|
if(!begin)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2002-09-24 19:50:09 +00:00
|
|
|
/* i.e. eof before the KEY BEGIN was found. This isn't an
|
|
|
|
error. */
|
|
|
|
*eof=1;
|
|
|
|
ret=KEYSERVER_OK;
|
2002-06-29 13:31:13 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now slurp up everything until we see the END */
|
|
|
|
|
2002-08-27 19:11:36 +00:00
|
|
|
while(fgets(line,MAX_LINE,input))
|
2006-07-17 04:11:30 +00:00
|
|
|
if(sscanf(line,"KEY%*[ ]%16s%*[ ]%3s\n",keyid,state)==2
|
2006-07-14 16:07:01 +00:00
|
|
|
&& strcmp(state,"END")==0)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2002-11-04 13:59:08 +00:00
|
|
|
end=1;
|
2002-06-29 13:31:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
2005-04-17 02:18:32 +00:00
|
|
|
{
|
|
|
|
if(strlen(line)+keylen>keymax)
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
keymax+=200;
|
|
|
|
tmp=realloc(key,keymax+1);
|
|
|
|
if(!tmp)
|
|
|
|
{
|
|
|
|
free(key);
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
key=tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(&key[keylen],line);
|
|
|
|
keylen+=strlen(line);
|
|
|
|
}
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2002-11-04 13:59:08 +00:00
|
|
|
if(!end)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: no KEY %s END found\n",keyid);
|
2002-09-24 19:50:09 +00:00
|
|
|
*eof=1;
|
|
|
|
ret=KEYSERVER_KEY_INCOMPLETE;
|
2002-06-29 13:31:13 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
encoded_key=curl_escape(key,keylen);
|
|
|
|
if(!encoded_key)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
2002-06-29 13:31:13 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2006-01-16 17:59:46 +00:00
|
|
|
free(key);
|
|
|
|
|
|
|
|
key=malloc(8+strlen(encoded_key)+1);
|
|
|
|
if(!key)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(key,"keytext=");
|
|
|
|
strcat(key,encoded_key);
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
strcpy(request,"http://");
|
|
|
|
strcat(request,opt->host);
|
|
|
|
strcat(request,":");
|
|
|
|
if(opt->port)
|
|
|
|
strcat(request,opt->port);
|
|
|
|
else
|
|
|
|
strcat(request,"11371");
|
2005-06-21 04:24:10 +00:00
|
|
|
strcat(request,opt->path);
|
2005-06-04 23:09:27 +00:00
|
|
|
/* request is MAX_URL+15 bytes long - MAX_URL covers the whole URL,
|
|
|
|
including any supplied path. The 15 covers /pks/add. */
|
2005-06-21 04:24:10 +00:00
|
|
|
append_path(request,"/pks/add");
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->verbose>2)
|
|
|
|
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_POST,1);
|
2006-01-16 17:59:46 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_POSTFIELDS,key);
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_FAILONERROR,1);
|
2002-08-27 19:11:36 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
res=curl_easy_perform(curl);
|
|
|
|
if(res!=0)
|
2002-08-27 19:11:36 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"gpgkeys: HTTP post error %d: %s\n",res,errorbuffer);
|
|
|
|
ret=curl_err_to_gpg_err(res);
|
2006-07-14 16:07:01 +00:00
|
|
|
goto fail;
|
2002-08-27 19:11:36 +00:00
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
else
|
|
|
|
fprintf(output,"\nKEY %s SENT\n",keyid);
|
2002-09-24 19:50:09 +00:00
|
|
|
|
|
|
|
ret=KEYSERVER_OK;
|
2002-08-27 19:11:36 +00:00
|
|
|
|
|
|
|
fail:
|
2005-04-17 02:18:32 +00:00
|
|
|
free(key);
|
|
|
|
curl_free(encoded_key);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2002-11-04 13:59:08 +00:00
|
|
|
if(ret!=0 && begin)
|
|
|
|
fprintf(output,"KEY %s FAILED %d\n",keyid,ret);
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
static int
|
2002-09-13 18:45:36 +00:00
|
|
|
get_key(char *getkey)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
CURLcode res;
|
2005-06-04 23:09:27 +00:00
|
|
|
char request[MAX_URL+60];
|
2005-04-17 02:18:32 +00:00
|
|
|
char *offset;
|
|
|
|
struct curl_writer_ctx ctx;
|
|
|
|
|
|
|
|
memset(&ctx,0,sizeof(ctx));
|
2002-06-29 13:31:13 +00:00
|
|
|
|
|
|
|
/* Build the search string. HKP only uses the short key IDs. */
|
|
|
|
|
|
|
|
if(strncmp(getkey,"0x",2)==0)
|
|
|
|
getkey+=2;
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(output,"KEY 0x%s BEGIN\n",getkey);
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
if(strlen(getkey)==32)
|
|
|
|
{
|
|
|
|
fprintf(console,
|
|
|
|
"gpgkeys: HKP keyservers do not support v3 fingerprints\n");
|
2002-09-24 19:50:09 +00:00
|
|
|
fprintf(output,"KEY 0x%s FAILED %d\n",getkey,KEYSERVER_NOT_SUPPORTED);
|
|
|
|
return KEYSERVER_NOT_SUPPORTED;
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
strcpy(request,"http://");
|
|
|
|
strcat(request,opt->host);
|
|
|
|
strcat(request,":");
|
|
|
|
if(opt->port)
|
|
|
|
strcat(request,opt->port);
|
|
|
|
else
|
|
|
|
strcat(request,"11371");
|
2005-06-21 04:24:10 +00:00
|
|
|
strcat(request,opt->path);
|
2005-06-04 23:09:27 +00:00
|
|
|
/* request is MAX_URL+55 bytes long - MAX_URL covers the whole URL,
|
|
|
|
including any supplied path. The 60 overcovers this /pks/... etc
|
|
|
|
string plus the 8 bytes of key id */
|
2005-06-21 04:24:10 +00:00
|
|
|
append_path(request,"/pks/lookup?op=get&options=mr&search=0x");
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
/* fingerprint or long key id. Take the last 8 characters and treat
|
|
|
|
it like a short key id */
|
|
|
|
if(strlen(getkey)>8)
|
|
|
|
offset=&getkey[strlen(getkey)-8];
|
|
|
|
else
|
|
|
|
offset=getkey;
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
strcat(request,offset);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->verbose>2)
|
2004-10-11 20:33:22 +00:00
|
|
|
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
|
|
|
|
ctx.stream=output;
|
|
|
|
curl_easy_setopt(curl,CURLOPT_FILE,&ctx);
|
|
|
|
|
|
|
|
res=curl_easy_perform(curl);
|
2005-12-19 19:39:32 +00:00
|
|
|
if(res!=CURLE_OK)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"gpgkeys: HTTP fetch error %d: %s\n",res,errorbuffer);
|
|
|
|
fprintf(output,"\nKEY 0x%s FAILED %d\n",getkey,curl_err_to_gpg_err(res));
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
2002-08-27 19:11:36 +00:00
|
|
|
else
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-12-19 19:39:32 +00:00
|
|
|
curl_writer_finalize(&ctx);
|
|
|
|
if(!ctx.flags.done)
|
2002-09-16 14:35:19 +00:00
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
|
2005-12-19 19:39:32 +00:00
|
|
|
fprintf(output,"\nKEY 0x%s FAILED %d\n",
|
2002-09-24 19:50:09 +00:00
|
|
|
getkey,KEYSERVER_KEY_NOT_FOUND);
|
2002-09-16 14:35:19 +00:00
|
|
|
}
|
2005-12-19 19:39:32 +00:00
|
|
|
else
|
|
|
|
fprintf(output,"\nKEY 0x%s END\n",getkey);
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2002-09-24 19:50:09 +00:00
|
|
|
return KEYSERVER_OK;
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2005-12-23 20:51:48 +00:00
|
|
|
static int
|
|
|
|
get_name(const char *getkey)
|
|
|
|
{
|
|
|
|
CURLcode res;
|
|
|
|
char *request=NULL;
|
|
|
|
char *searchkey_encoded;
|
|
|
|
int ret=KEYSERVER_INTERNAL_ERROR;
|
|
|
|
struct curl_writer_ctx ctx;
|
|
|
|
|
|
|
|
memset(&ctx,0,sizeof(ctx));
|
|
|
|
|
|
|
|
searchkey_encoded=curl_escape((char *)getkey,0);
|
|
|
|
if(!searchkey_encoded)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
request=malloc(MAX_URL+60+strlen(searchkey_encoded));
|
|
|
|
if(!request)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(output,"NAME %s BEGIN\n",getkey);
|
|
|
|
|
|
|
|
strcpy(request,"http://");
|
|
|
|
strcat(request,opt->host);
|
|
|
|
strcat(request,":");
|
|
|
|
if(opt->port)
|
|
|
|
strcat(request,opt->port);
|
|
|
|
else
|
|
|
|
strcat(request,"11371");
|
|
|
|
strcat(request,opt->path);
|
|
|
|
append_path(request,"/pks/lookup?op=get&options=mr&search=");
|
|
|
|
strcat(request,searchkey_encoded);
|
|
|
|
|
2006-02-22 23:19:36 +00:00
|
|
|
if(opt->action==KS_GETNAME)
|
|
|
|
strcat(request,"&exact=on");
|
|
|
|
|
2005-12-23 20:51:48 +00:00
|
|
|
if(opt->verbose>2)
|
|
|
|
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
|
|
|
|
ctx.stream=output;
|
|
|
|
curl_easy_setopt(curl,CURLOPT_FILE,&ctx);
|
|
|
|
|
|
|
|
res=curl_easy_perform(curl);
|
|
|
|
if(res!=CURLE_OK)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: HTTP fetch error %d: %s\n",res,errorbuffer);
|
|
|
|
ret=curl_err_to_gpg_err(res);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
curl_writer_finalize(&ctx);
|
|
|
|
if(!ctx.flags.done)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey);
|
|
|
|
ret=KEYSERVER_KEY_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(output,"\nNAME %s END\n",getkey);
|
|
|
|
ret=KEYSERVER_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
|
|
|
curl_free(searchkey_encoded);
|
|
|
|
free(request);
|
|
|
|
|
|
|
|
if(ret!=KEYSERVER_OK)
|
|
|
|
fprintf(output,"\nNAME %s FAILED %d\n",getkey,ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-08-26 04:24:46 +00:00
|
|
|
static int
|
|
|
|
search_key(const char *searchkey)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
CURLcode res;
|
2005-08-18 04:17:20 +00:00
|
|
|
char *request=NULL;
|
2005-12-23 20:51:48 +00:00
|
|
|
char *searchkey_encoded;
|
2005-04-17 02:18:32 +00:00
|
|
|
int ret=KEYSERVER_INTERNAL_ERROR;
|
2005-08-26 04:24:46 +00:00
|
|
|
enum ks_search_type search_type;
|
2004-01-12 04:09:37 +00:00
|
|
|
|
2005-08-26 04:24:46 +00:00
|
|
|
search_type=classify_ks_search(&searchkey);
|
2005-08-18 04:17:20 +00:00
|
|
|
|
2005-08-26 04:24:46 +00:00
|
|
|
if(opt->debug)
|
|
|
|
fprintf(console,"gpgkeys: search type is %d, and key is \"%s\"\n",
|
|
|
|
search_type,searchkey);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-11-03 04:46:20 +00:00
|
|
|
searchkey_encoded=curl_escape((char *)searchkey,0);
|
2005-08-18 04:17:20 +00:00
|
|
|
if(!searchkey_encoded)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
request=malloc(MAX_URL+60+strlen(searchkey_encoded));
|
2002-09-10 08:28:40 +00:00
|
|
|
if(!request)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory\n");
|
2002-09-24 19:50:09 +00:00
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
goto fail;
|
2002-09-10 08:28:40 +00:00
|
|
|
}
|
2002-08-27 19:11:36 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(output,"SEARCH %s BEGIN\n",searchkey);
|
|
|
|
|
|
|
|
strcpy(request,"http://");
|
|
|
|
strcat(request,opt->host);
|
|
|
|
strcat(request,":");
|
|
|
|
if(opt->port)
|
|
|
|
strcat(request,opt->port);
|
|
|
|
else
|
|
|
|
strcat(request,"11371");
|
2005-06-21 04:24:10 +00:00
|
|
|
strcat(request,opt->path);
|
|
|
|
append_path(request,"/pks/lookup?op=index&options=mr&search=");
|
2005-04-17 02:18:32 +00:00
|
|
|
strcat(request,searchkey_encoded);
|
2002-08-27 19:11:36 +00:00
|
|
|
|
2005-08-26 04:24:46 +00:00
|
|
|
if(search_type!=KS_SEARCH_SUBSTR)
|
2005-08-18 04:17:20 +00:00
|
|
|
strcat(request,"&exact=on");
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->verbose>2)
|
2004-10-11 20:33:22 +00:00
|
|
|
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_URL,request);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_mrindex_writer);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_FILE,output);
|
|
|
|
|
|
|
|
res=curl_easy_perform(curl);
|
|
|
|
if(res!=0)
|
2002-08-27 19:11:36 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"gpgkeys: HTTP search error %d: %s\n",res,errorbuffer);
|
|
|
|
ret=curl_err_to_gpg_err(res);
|
2002-08-27 19:11:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(output,"\nSEARCH %s END\n",searchkey);
|
2002-09-24 19:50:09 +00:00
|
|
|
ret=KEYSERVER_OK;
|
2002-08-27 19:11:36 +00:00
|
|
|
}
|
|
|
|
|
2002-09-24 19:50:09 +00:00
|
|
|
fail:
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_free(searchkey_encoded);
|
2002-08-28 04:04:37 +00:00
|
|
|
free(request);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2002-09-24 19:50:09 +00:00
|
|
|
if(ret!=KEYSERVER_OK)
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(output,"\nSEARCH %s FAILED %d\n",searchkey,ret);
|
2002-09-24 19:50:09 +00:00
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-10-09 02:03:22 +00:00
|
|
|
void
|
2005-04-17 02:18:32 +00:00
|
|
|
fail_all(struct keylist *keylist,int err)
|
2002-10-09 02:03:22 +00:00
|
|
|
{
|
|
|
|
if(!keylist)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->action==KS_SEARCH)
|
2002-10-09 02:03:22 +00:00
|
|
|
{
|
|
|
|
fprintf(output,"SEARCH ");
|
|
|
|
while(keylist)
|
|
|
|
{
|
|
|
|
fprintf(output,"%s ",keylist->str);
|
|
|
|
keylist=keylist->next;
|
|
|
|
}
|
|
|
|
fprintf(output,"FAILED %d\n",err);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
while(keylist)
|
|
|
|
{
|
|
|
|
fprintf(output,"KEY %s FAILED %d\n",keylist->str,err);
|
|
|
|
keylist=keylist->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-15 12:19:06 +00:00
|
|
|
static void
|
|
|
|
show_help (FILE *fp)
|
|
|
|
{
|
|
|
|
fprintf (fp,"-h\thelp\n");
|
|
|
|
fprintf (fp,"-V\tversion\n");
|
|
|
|
fprintf (fp,"-o\toutput to this file\n");
|
|
|
|
}
|
|
|
|
|
2002-09-13 18:45:36 +00:00
|
|
|
int
|
|
|
|
main(int argc,char *argv[])
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
int arg,ret=KEYSERVER_INTERNAL_ERROR;
|
2002-06-29 13:31:13 +00:00
|
|
|
char line[MAX_LINE];
|
2002-08-28 04:04:37 +00:00
|
|
|
int failed=0;
|
2002-06-29 13:31:13 +00:00
|
|
|
struct keylist *keylist=NULL,*keyptr=NULL;
|
2005-06-23 23:42:35 +00:00
|
|
|
char *proxy=NULL;
|
2002-06-29 13:31:13 +00:00
|
|
|
|
|
|
|
console=stderr;
|
|
|
|
|
2004-10-15 12:19:06 +00:00
|
|
|
/* Kludge to implement standard GNU options. */
|
|
|
|
if (argc > 1 && !strcmp (argv[1], "--version"))
|
|
|
|
{
|
2005-02-05 15:04:59 +00:00
|
|
|
fputs ("gpgkeys_hkp (GnuPG) " VERSION"\n", stdout);
|
2004-10-15 12:19:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else if (argc > 1 && !strcmp (argv[1], "--help"))
|
|
|
|
{
|
|
|
|
show_help (stdout);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-10-24 22:33:22 +00:00
|
|
|
while((arg=getopt(argc,argv,"hVo:"))!=-1)
|
2002-06-29 13:31:13 +00:00
|
|
|
switch(arg)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 'h':
|
2004-10-15 12:19:06 +00:00
|
|
|
show_help (console);
|
2002-06-29 13:31:13 +00:00
|
|
|
return KEYSERVER_OK;
|
|
|
|
|
2002-10-24 22:33:22 +00:00
|
|
|
case 'V':
|
2002-11-18 00:43:33 +00:00
|
|
|
fprintf(stdout,"%d\n%s\n",KEYSERVER_PROTO_VERSION,VERSION);
|
2002-10-24 22:33:22 +00:00
|
|
|
return KEYSERVER_OK;
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
case 'o':
|
|
|
|
output=fopen(optarg,"w");
|
|
|
|
if(output==NULL)
|
|
|
|
{
|
2004-10-11 20:33:22 +00:00
|
|
|
fprintf(console,"gpgkeys: Cannot open output file `%s': %s\n",
|
2002-06-29 13:31:13 +00:00
|
|
|
optarg,strerror(errno));
|
|
|
|
return KEYSERVER_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(argc>optind)
|
|
|
|
{
|
|
|
|
input=fopen(argv[optind],"r");
|
|
|
|
if(input==NULL)
|
|
|
|
{
|
2004-10-11 20:33:22 +00:00
|
|
|
fprintf(console,"gpgkeys: Cannot open input file `%s': %s\n",
|
2002-06-29 13:31:13 +00:00
|
|
|
argv[optind],strerror(errno));
|
|
|
|
return KEYSERVER_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(input==NULL)
|
|
|
|
input=stdin;
|
|
|
|
|
|
|
|
if(output==NULL)
|
|
|
|
output=stdout;
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
opt=init_ks_options();
|
|
|
|
if(!opt)
|
|
|
|
return KEYSERVER_NO_MEMORY;
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
/* Get the command and info block */
|
|
|
|
|
|
|
|
while(fgets(line,MAX_LINE,input)!=NULL)
|
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
int err;
|
2005-01-13 23:22:10 +00:00
|
|
|
char option[MAX_OPTION+1];
|
2002-06-29 13:31:13 +00:00
|
|
|
|
|
|
|
if(line[0]=='\n')
|
|
|
|
break;
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
err=parse_ks_options(line,opt);
|
|
|
|
if(err>0)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
ret=err;
|
|
|
|
goto fail;
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
else if(err==0)
|
|
|
|
continue;
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-01-13 23:22:10 +00:00
|
|
|
if(sscanf(line,"OPTION %" MKSTRING(MAX_OPTION) "s\n",option)==1)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
|
|
|
int no=0;
|
2005-01-13 23:22:10 +00:00
|
|
|
char *start=&option[0];
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-01-13 23:22:10 +00:00
|
|
|
option[MAX_OPTION]='\0';
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-01-13 23:22:10 +00:00
|
|
|
if(strncasecmp(option,"no-",3)==0)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
|
|
|
no=1;
|
2005-01-13 23:22:10 +00:00
|
|
|
start=&option[3];
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(strncasecmp(start,"http-proxy",10)==0)
|
2002-07-01 17:46:56 +00:00
|
|
|
{
|
2002-08-27 19:11:36 +00:00
|
|
|
if(no)
|
2003-12-28 16:21:46 +00:00
|
|
|
{
|
2005-06-23 23:42:35 +00:00
|
|
|
free(proxy);
|
|
|
|
proxy=strdup("");
|
2003-12-28 16:21:46 +00:00
|
|
|
}
|
2005-06-23 23:42:35 +00:00
|
|
|
else if(start[10]=='=')
|
2003-12-28 16:21:46 +00:00
|
|
|
{
|
2005-06-23 23:42:35 +00:00
|
|
|
if(strlen(&start[11])<MAX_PROXY)
|
2003-12-28 16:21:46 +00:00
|
|
|
{
|
2005-06-23 23:42:35 +00:00
|
|
|
free(proxy);
|
|
|
|
proxy=strdup(&start[11]);
|
2003-12-28 16:21:46 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-27 19:11:36 +00:00
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
#if 0
|
2003-03-11 17:42:07 +00:00
|
|
|
else if(strcasecmp(start,"try-dns-srv")==0)
|
|
|
|
{
|
|
|
|
if(no)
|
|
|
|
http_flags&=~HTTP_FLAG_TRY_SRV;
|
|
|
|
else
|
|
|
|
http_flags|=HTTP_FLAG_TRY_SRV;
|
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
#endif
|
2002-06-29 13:31:13 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(!opt->host)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: no keyserver host provided\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(opt->timeout && register_timeout()==-1)
|
2004-10-13 18:30:29 +00:00
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: unable to register timeout handler\n");
|
|
|
|
return KEYSERVER_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
|
|
|
curl=curl_easy_init();
|
|
|
|
if(!curl)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: unable to initialize curl\n");
|
|
|
|
ret=KEYSERVER_INTERNAL_ERROR;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
|
|
|
|
|
2005-06-23 23:42:35 +00:00
|
|
|
if(opt->auth)
|
|
|
|
curl_easy_setopt(curl,CURLOPT_USERPWD,opt->auth);
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->debug)
|
|
|
|
{
|
2005-08-04 03:59:16 +00:00
|
|
|
fprintf(console,"gpgkeys: curl version = %s\n",curl_version());
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_STDERR,console);
|
|
|
|
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
|
|
|
|
}
|
|
|
|
|
2005-06-23 23:42:35 +00:00
|
|
|
if(proxy)
|
2005-04-17 02:18:32 +00:00
|
|
|
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);
|
|
|
|
|
|
|
|
#if 0
|
2003-03-11 17:42:07 +00:00
|
|
|
/* By suggested convention, if the user gives a :port, then disable
|
|
|
|
SRV. */
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->port)
|
2003-03-11 17:42:07 +00:00
|
|
|
http_flags&=~HTTP_FLAG_TRY_SRV;
|
2005-04-17 02:18:32 +00:00
|
|
|
#endif
|
2003-03-11 17:42:07 +00:00
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
/* If it's a GET or a SEARCH, the next thing to come in is the
|
|
|
|
keyids. If it's a SEND, then there are no keyids. */
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->action==KS_SEND)
|
2002-06-29 13:31:13 +00:00
|
|
|
while(fgets(line,MAX_LINE,input)!=NULL && line[0]!='\n');
|
2005-12-23 20:51:48 +00:00
|
|
|
else if(opt->action==KS_GET
|
|
|
|
|| opt->action==KS_GETNAME || opt->action==KS_SEARCH)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
struct keylist *work;
|
|
|
|
|
|
|
|
if(fgets(line,MAX_LINE,input)==NULL)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
2004-01-12 04:09:37 +00:00
|
|
|
if(line[0]=='\n' || line[0]=='\0')
|
2002-06-29 13:31:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
work=malloc(sizeof(struct keylist));
|
|
|
|
if(work==NULL)
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: out of memory while "
|
|
|
|
"building key list\n");
|
2002-10-09 02:03:22 +00:00
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
2002-06-29 13:31:13 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(work->str,line);
|
|
|
|
|
|
|
|
/* Trim the trailing \n */
|
|
|
|
work->str[strlen(line)-1]='\0';
|
|
|
|
|
|
|
|
work->next=NULL;
|
|
|
|
|
|
|
|
/* Always attach at the end to keep the list in proper
|
|
|
|
order for searching */
|
|
|
|
if(keylist==NULL)
|
|
|
|
keylist=work;
|
|
|
|
else
|
|
|
|
keyptr->next=work;
|
|
|
|
|
|
|
|
keyptr=work;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fprintf(console,"gpgkeys: no keyserver command specified\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send the response */
|
|
|
|
|
2002-10-14 20:01:05 +00:00
|
|
|
fprintf(output,"VERSION %d\n",KEYSERVER_PROTO_VERSION);
|
2002-06-29 13:31:13 +00:00
|
|
|
fprintf(output,"PROGRAM %s\n\n",VERSION);
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->verbose>1)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"Host:\t\t%s\n",opt->host);
|
|
|
|
if(opt->port)
|
|
|
|
fprintf(console,"Port:\t\t%s\n",opt->port);
|
2005-06-21 04:24:10 +00:00
|
|
|
if(strcmp(opt->path,"/")!=0)
|
2005-06-04 23:09:27 +00:00
|
|
|
fprintf(console,"Path:\t\t%s\n",opt->path);
|
2005-04-17 02:18:32 +00:00
|
|
|
fprintf(console,"Command:\t%s\n",ks_action_to_string(opt->action));
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(opt->action==KS_GET)
|
2002-06-29 13:31:13 +00:00
|
|
|
{
|
|
|
|
keyptr=keylist;
|
|
|
|
|
|
|
|
while(keyptr!=NULL)
|
|
|
|
{
|
2005-04-17 02:18:32 +00:00
|
|
|
set_timeout(opt->timeout);
|
2004-10-13 18:30:29 +00:00
|
|
|
|
2002-09-24 19:50:09 +00:00
|
|
|
if(get_key(keyptr->str)!=KEYSERVER_OK)
|
2002-06-29 13:31:13 +00:00
|
|
|
failed++;
|
|
|
|
|
2005-12-23 20:51:48 +00:00
|
|
|
keyptr=keyptr->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->action==KS_GETNAME)
|
|
|
|
{
|
|
|
|
keyptr=keylist;
|
|
|
|
|
|
|
|
while(keyptr!=NULL)
|
|
|
|
{
|
|
|
|
set_timeout(opt->timeout);
|
|
|
|
|
|
|
|
if(get_name(keyptr->str)!=KEYSERVER_OK)
|
|
|
|
failed++;
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
keyptr=keyptr->next;
|
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
}
|
|
|
|
else if(opt->action==KS_SEND)
|
|
|
|
{
|
|
|
|
int eof=0;
|
2004-10-13 18:30:29 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
set_timeout(opt->timeout);
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(send_key(&eof)!=KEYSERVER_OK)
|
|
|
|
failed++;
|
|
|
|
}
|
|
|
|
while(!eof);
|
|
|
|
}
|
|
|
|
else if(opt->action==KS_SEARCH)
|
|
|
|
{
|
|
|
|
char *searchkey=NULL;
|
|
|
|
int len=0;
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
set_timeout(opt->timeout);
|
2004-10-13 18:30:29 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
/* To search, we stick a space in between each key to search
|
|
|
|
for. */
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
keyptr=keylist;
|
|
|
|
while(keyptr!=NULL)
|
|
|
|
{
|
|
|
|
len+=strlen(keyptr->str)+1;
|
|
|
|
keyptr=keyptr->next;
|
|
|
|
}
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
searchkey=malloc(len+1);
|
|
|
|
if(searchkey==NULL)
|
|
|
|
{
|
|
|
|
ret=KEYSERVER_NO_MEMORY;
|
|
|
|
fail_all(keylist,KEYSERVER_NO_MEMORY);
|
|
|
|
goto fail;
|
|
|
|
}
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
searchkey[0]='\0';
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
keyptr=keylist;
|
|
|
|
while(keyptr!=NULL)
|
|
|
|
{
|
|
|
|
strcat(searchkey,keyptr->str);
|
|
|
|
strcat(searchkey," ");
|
|
|
|
keyptr=keyptr->next;
|
|
|
|
}
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
/* Nail that last space */
|
|
|
|
if(*searchkey)
|
|
|
|
searchkey[strlen(searchkey)-1]='\0';
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
if(search_key(searchkey)!=KEYSERVER_OK)
|
|
|
|
failed++;
|
2002-06-29 13:31:13 +00:00
|
|
|
|
2005-04-17 02:18:32 +00:00
|
|
|
free(searchkey);
|
2002-06-29 13:31:13 +00:00
|
|
|
}
|
2005-04-17 02:18:32 +00:00
|
|
|
else
|
|
|
|
abort();
|
2002-06-29 13:31:13 +00:00
|
|
|
|
|
|
|
if(!failed)
|
|
|
|
ret=KEYSERVER_OK;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
while(keylist!=NULL)
|
|
|
|
{
|
|
|
|
struct keylist *current=keylist;
|
|
|
|
keylist=keylist->next;
|
|
|
|
free(current);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(input!=stdin)
|
|
|
|
fclose(input);
|
|
|
|
|
|
|
|
if(output!=stdout)
|
|
|
|
fclose(output);
|
|
|
|
|
2005-06-23 23:42:35 +00:00
|
|
|
free_ks_options(opt);
|
|
|
|
|
|
|
|
if(curl)
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
free(proxy);
|
|
|
|
|
2002-06-29 13:31:13 +00:00
|
|
|
return ret;
|
|
|
|
}
|