Page MenuHome GnuPG

No OneTemporary

This document is not UTF8. It was detected as Shift JIS and converted to UTF8 for display.
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 31037c01d..30e8ae6d6 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1,2121 +1,2121 @@
/* keyserver.c - generic keyserver code
* Copyright (C) 2001, 2002, 2003, 2004, 2005,
* 2006 Free Software Foundation, Inc.
*
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#endif
#include "filter.h"
#include "keydb.h"
#include "status.h"
#include "exec.h"
#include "main.h"
#include "i18n.h"
#include "iobuf.h"
#include "memory.h"
#include "ttyio.h"
#include "options.h"
#include "packet.h"
#include "trustdb.h"
#include "keyserver-internal.h"
#include "util.h"
#define GPGKEYS_PREFIX "gpgkeys_"
#if defined(HAVE_LIBCURL) || defined(FAKE_CURL)
#define GPGKEYS_CURL "gpgkeys_curl"
#endif
#ifdef GPGKEYS_CURL
#define GPGKEYS_PREFIX_LEN (strlen(GPGKEYS_PREFIX)+strlen(GPGKEYS_CURL))
#else
#define GPGKEYS_PREFIX_LEN (strlen(GPGKEYS_PREFIX))
#endif
struct keyrec
{
KEYDB_SEARCH_DESC desc;
u32 createtime,expiretime;
int size,flags;
byte type;
IOBUF uidbuf;
unsigned int lines;
};
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
static struct parse_options keyserver_opts[]=
{
/* some of these options are not real - just for the help
message */
{"max-cert-size",0,NULL,NULL},
{"include-revoked",0,NULL,N_("include revoked keys in search results")},
{"include-subkeys",0,NULL,N_("include subkeys when searching by key ID")},
{"use-temp-files",0,NULL,
N_("use temporary files to pass data to keyserver helpers")},
{"keep-temp-files",KEYSERVER_KEEP_TEMP_FILES,NULL,
N_("do not delete temporary files after using them")},
{"refresh-add-fake-v3-keyids",KEYSERVER_ADD_FAKE_V3,NULL,
NULL},
{"auto-key-retrieve",KEYSERVER_AUTO_KEY_RETRIEVE,NULL,
N_("automatically retrieve keys when verifying signatures")},
{"honor-keyserver-url",KEYSERVER_HONOR_KEYSERVER_URL,NULL,
N_("honor the preferred keyserver URL set on the key")},
{"honor-pka-record",KEYSERVER_HONOR_PKA_RECORD,NULL,
N_("honor the PKA record set on a key when retrieving keys")},
{NULL,0,NULL,NULL}
};
static int keyserver_work(enum ks_action action,STRLIST list,
KEYDB_SEARCH_DESC *desc,int count,
unsigned char **fpr,size_t *fpr_len,
struct keyserver_spec *keyserver);
/* Reasonable guess */
#define DEFAULT_MAX_CERT_SIZE 16384
static size_t max_cert_size=DEFAULT_MAX_CERT_SIZE;
static void
add_canonical_option(char *option,STRLIST *list)
{
char *arg=argsplit(option);
if(arg)
{
char *joined;
joined=xmalloc(strlen(option)+1+strlen(arg)+1);
/* Make a canonical name=value form with no spaces */
strcpy(joined,option);
strcat(joined,"=");
strcat(joined,arg);
append_to_strlist(list,joined);
xfree(joined);
}
else
append_to_strlist(list,option);
}
int
parse_keyserver_options(char *options)
{
int ret=1;
char *tok;
char *max_cert=NULL;
keyserver_opts[0].value=&max_cert;
while((tok=optsep(&options)))
{
if(tok[0]=='\0')
continue;
/* For backwards compatibility. 1.2.x used honor-http-proxy and
there are a good number of documents published that recommend
it. */
if(ascii_strcasecmp(tok,"honor-http-proxy")==0)
tok="http-proxy";
else if(ascii_strcasecmp(tok,"no-honor-http-proxy")==0)
tok="no-http-proxy";
/* We accept quite a few possible options here - some options to
handle specially, the keyserver_options list, and import and
export options that pertain to keyserver operations. Note
that you must use strncasecmp here as there might be an
=argument attached which will foil the use of strcasecmp. */
#ifdef EXEC_TEMPFILE_ONLY
if(ascii_strncasecmp(tok,"use-temp-files",14)==0 ||
ascii_strncasecmp(tok,"no-use-temp-files",17)==0)
log_info(_("WARNING: keyserver option `%s' is not used"
" on this platform\n"),tok);
#else
if(ascii_strncasecmp(tok,"use-temp-files",14)==0)
opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
else if(ascii_strncasecmp(tok,"no-use-temp-files",17)==0)
opt.keyserver_options.options&=~KEYSERVER_USE_TEMP_FILES;
#endif
else if(!parse_options(tok,&opt.keyserver_options.options,
keyserver_opts,0)
&& !parse_import_options(tok,
&opt.keyserver_options.import_options,0)
&& !parse_export_options(tok,
&opt.keyserver_options.export_options,0))
{
/* All of the standard options have failed, so the option is
destined for a keyserver plugin. */
add_canonical_option(tok,&opt.keyserver_options.other);
}
}
if(max_cert)
{
max_cert_size=strtoul(max_cert,(char **)NULL,10);
if(max_cert_size==0)
max_cert_size=DEFAULT_MAX_CERT_SIZE;
}
return ret;
}
void
free_keyserver_spec(struct keyserver_spec *keyserver)
{
xfree(keyserver->uri);
xfree(keyserver->scheme);
xfree(keyserver->auth);
xfree(keyserver->host);
xfree(keyserver->port);
xfree(keyserver->path);
xfree(keyserver->opaque);
free_strlist(keyserver->options);
xfree(keyserver);
}
/* Return 0 for match */
static int
cmp_keyserver_spec(struct keyserver_spec *one,struct keyserver_spec *two)
{
if(ascii_strcasecmp(one->scheme,two->scheme)==0)
{
if(one->host && two->host && ascii_strcasecmp(one->host,two->host)==0)
{
if((one->port && two->port
&& ascii_strcasecmp(one->port,two->port)==0)
|| (!one->port && !two->port))
return 0;
}
else if(one->opaque && two->opaque
&& ascii_strcasecmp(one->opaque,two->opaque)==0)
return 0;
}
return 1;
}
/* Try and match one of our keyservers. If we can, return that. If
we can't, return our input. */
struct keyserver_spec *
keyserver_match(struct keyserver_spec *spec)
{
struct keyserver_spec *ks;
for(ks=opt.keyserver;ks;ks=ks->next)
if(cmp_keyserver_spec(spec,ks)==0)
return ks;
return spec;
}
/* TODO: once we cut over to an all-curl world, we don't need this
parser any longer so it can be removed, or at least moved to
keyserver/ksutil.c for limited use in gpgkeys_ldap or the like. */
struct keyserver_spec *
parse_keyserver_uri(const char *string,int require_scheme,
const char *configname,unsigned int configlineno)
{
int assume_hkp=0;
struct keyserver_spec *keyserver;
const char *idx;
int count;
char *uri,*options;
assert(string!=NULL);
keyserver=xmalloc_clear(sizeof(struct keyserver_spec));
uri=xstrdup(string);
options=strchr(uri,' ');
if(options)
{
char *tok;
*options='\0';
options++;
while((tok=optsep(&options)))
add_canonical_option(tok,&keyserver->options);
}
/* Get the scheme */
for(idx=uri,count=0;*idx && *idx!=':';idx++)
{
count++;
/* Do we see the start of an RFC-2732 ipv6 address here? If so,
there clearly isn't a scheme so get out early. */
if(*idx=='[')
{
/* Was the '[' the first thing in the string? If not, we
have a mangled scheme with a [ in it so fail. */
if(count==1)
break;
else
goto fail;
}
}
if(count==0)
goto fail;
if(*idx=='\0' || *idx=='[')
{
if(require_scheme)
return NULL;
/* Assume HKP if there is no scheme */
assume_hkp=1;
keyserver->scheme=xstrdup("hkp");
keyserver->uri=xmalloc(strlen(keyserver->scheme)+3+strlen(uri)+1);
strcpy(keyserver->uri,keyserver->scheme);
strcat(keyserver->uri,"://");
strcat(keyserver->uri,uri);
}
else
{
int i;
keyserver->uri=xstrdup(uri);
keyserver->scheme=xmalloc(count+1);
/* Force to lowercase */
for(i=0;i<count;i++)
keyserver->scheme[i]=ascii_tolower(uri[i]);
keyserver->scheme[i]='\0';
/* Skip past the scheme and colon */
uri+=count+1;
}
if(ascii_strcasecmp(keyserver->scheme,"x-broken-hkp")==0)
{
deprecated_warning(configname,configlineno,"x-broken-hkp",
"--keyserver-options ","broken-http-proxy");
xfree(keyserver->scheme);
keyserver->scheme=xstrdup("hkp");
append_to_strlist(&opt.keyserver_options.other,"broken-http-proxy");
}
else if(ascii_strcasecmp(keyserver->scheme,"x-hkp")==0)
{
/* Canonicalize this to "hkp" so it works with both the internal
and external keyserver interface. */
xfree(keyserver->scheme);
keyserver->scheme=xstrdup("hkp");
}
if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
{
/* Two slashes means network path. */
/* Skip over the "//", if any */
if(!assume_hkp)
uri+=2;
/* Do we have userinfo auth data present? */
for(idx=uri,count=0;*idx && *idx!='@' && *idx!='/';idx++)
count++;
/* We found a @ before the slash, so that means everything
before the @ is auth data. */
if(*idx=='@')
{
if(count==0)
goto fail;
keyserver->auth=xmalloc(count+1);
strncpy(keyserver->auth,uri,count);
keyserver->auth[count]='\0';
uri+=count+1;
}
/* Is it an RFC-2732 ipv6 [literal address] ? */
if(*uri=='[')
{
for(idx=uri+1,count=1;*idx
&& ((isascii (*idx) && isxdigit(*idx))
|| *idx==':' || *idx=='.');idx++)
count++;
/* Is the ipv6 literal address terminated? */
if(*idx==']')
count++;
else
goto fail;
}
else
for(idx=uri,count=0;*idx && *idx!=':' && *idx!='/';idx++)
count++;
if(count==0)
goto fail;
keyserver->host=xmalloc(count+1);
strncpy(keyserver->host,uri,count);
keyserver->host[count]='\0';
/* Skip past the host */
uri+=count;
if(*uri==':')
{
/* It would seem to be reasonable to limit the range of the
ports to values between 1-65535, but RFC 1738 and 1808
imply there is no limit. Of course, the real world has
limits. */
for(idx=uri+1,count=0;*idx && *idx!='/';idx++)
{
count++;
/* Ports are digits only */
if(!digitp(idx))
goto fail;
}
keyserver->port=xmalloc(count+1);
strncpy(keyserver->port,uri+1,count);
keyserver->port[count]='\0';
/* Skip past the colon and port number */
uri+=1+count;
}
/* Everything else is the path */
if(*uri)
keyserver->path=xstrdup(uri);
else
keyserver->path=xstrdup("/");
if(keyserver->path[1]!='\0')
keyserver->flags.direct_uri=1;
}
else if(uri[0]!='/')
{
/* No slash means opaque. Just record the opaque blob and get
out. */
keyserver->opaque=xstrdup(uri);
}
else
{
/* One slash means absolute path. We don't need to support that
yet. */
goto fail;
}
return keyserver;
fail:
free_keyserver_spec(keyserver);
return NULL;
}
struct keyserver_spec *
parse_preferred_keyserver(PKT_signature *sig)
{
struct keyserver_spec *spec=NULL;
const byte *p;
size_t plen;
p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_PREF_KS,&plen);
if(p && plen)
{
byte *dupe=xmalloc(plen+1);
memcpy(dupe,p,plen);
dupe[plen]='\0';
spec=parse_keyserver_uri(dupe,1,NULL,0);
xfree(dupe);
}
return spec;
}
static void
print_keyrec(int number,struct keyrec *keyrec)
{
int i;
iobuf_writebyte(keyrec->uidbuf,0);
iobuf_flush_temp(keyrec->uidbuf);
printf("(%d)\t%s ",number,iobuf_get_temp_buffer(keyrec->uidbuf));
if(keyrec->size>0)
printf("%d bit ",keyrec->size);
if(keyrec->type)
{
const char *str=pubkey_algo_to_string(keyrec->type);
if(str)
printf("%s ",str);
else
printf("unknown ");
}
switch(keyrec->desc.mode)
{
/* If the keyserver helper gave us a short keyid, we have no
choice but to use it. Do check --keyid-format to add a 0x if
needed. */
case KEYDB_SEARCH_MODE_SHORT_KID:
printf("key %s%08lX",
(opt.keyid_format==KF_0xSHORT
|| opt.keyid_format==KF_0xLONG)?"0x":"",
(ulong)keyrec->desc.u.kid[1]);
break;
/* However, if it gave us a long keyid, we can honor
--keyid-format */
case KEYDB_SEARCH_MODE_LONG_KID:
printf("key %s",keystr(keyrec->desc.u.kid));
break;
case KEYDB_SEARCH_MODE_FPR16:
printf("key ");
for(i=0;i<16;i++)
printf("%02X",keyrec->desc.u.fpr[i]);
break;
case KEYDB_SEARCH_MODE_FPR20:
printf("key ");
for(i=0;i<20;i++)
printf("%02X",keyrec->desc.u.fpr[i]);
break;
default:
BUG();
break;
}
if(keyrec->createtime>0)
{
printf(", ");
printf(_("created: %s"),strtimestamp(keyrec->createtime));
}
if(keyrec->expiretime>0)
{
printf(", ");
printf(_("expires: %s"),strtimestamp(keyrec->expiretime));
}
if(keyrec->flags&1)
printf(" (%s)",_("revoked"));
if(keyrec->flags&2)
printf(" (%s)",_("disabled"));
if(keyrec->flags&4)
printf(" (%s)",_("expired"));
printf("\n");
}
/* Returns a keyrec (which must be freed) once a key is complete, and
NULL otherwise. Call with a NULL keystring once key parsing is
complete to return any unfinished keys. */
static struct keyrec *
parse_keyrec(char *keystring)
{
static struct keyrec *work=NULL;
struct keyrec *ret=NULL;
char *record;
int i;
if(keystring==NULL)
{
if(work==NULL)
return NULL;
else if(work->desc.mode==KEYDB_SEARCH_MODE_NONE)
{
xfree(work);
return NULL;
}
else
{
ret=work;
work=NULL;
return ret;
}
}
if(work==NULL)
{
work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
/* Remove trailing whitespace */
for(i=strlen(keystring);i>0;i--)
if(ascii_isspace(keystring[i-1]))
keystring[i-1]='\0';
else
break;
if((record=strsep(&keystring,":"))==NULL)
return ret;
if(ascii_strcasecmp("pub",record)==0)
{
char *tok;
if(work->desc.mode)
{
ret=work;
work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
if((tok=strsep(&keystring,":"))==NULL)
return ret;
classify_user_id(tok,&work->desc);
if(work->desc.mode!=KEYDB_SEARCH_MODE_SHORT_KID
&& work->desc.mode!=KEYDB_SEARCH_MODE_LONG_KID
&& work->desc.mode!=KEYDB_SEARCH_MODE_FPR16
&& work->desc.mode!=KEYDB_SEARCH_MODE_FPR20)
{
work->desc.mode=KEYDB_SEARCH_MODE_NONE;
return ret;
}
/* Note all items after this are optional. This allows us to
have a pub line as simple as pub:keyid and nothing else. */
work->lines++;
if((tok=strsep(&keystring,":"))==NULL)
return ret;
work->type=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
work->size=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(atoi(tok)<=0)
work->createtime=0;
else
work->createtime=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(atoi(tok)<=0)
work->expiretime=0;
else
{
work->expiretime=atoi(tok);
/* Force the 'e' flag on if this key is expired. */
if(work->expiretime<=make_timestamp())
work->flags|=4;
}
if((tok=strsep(&keystring,":"))==NULL)
return ret;
while(*tok)
switch(*tok++)
{
case 'r':
case 'R':
work->flags|=1;
break;
case 'd':
case 'D':
work->flags|=2;
break;
case 'e':
case 'E':
work->flags|=4;
break;
}
}
else if(ascii_strcasecmp("uid",record)==0 && work->desc.mode)
{
char *userid,*tok,*decoded;
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(strlen(tok)==0)
return ret;
userid=tok;
/* By definition, de-%-encoding is always smaller than the
original string so we can decode in place. */
i=0;
while(*tok)
if(tok[0]=='%' && tok[1] && tok[2])
{
if((userid[i]=hextobyte(&tok[1]))==-1)
userid[i]='?';
i++;
tok+=3;
}
else
userid[i++]=*tok++;
/* We don't care about the other info provided in the uid: line
since no keyserver supports marking userids with timestamps
or revoked/expired/disabled yet. */
/* No need to check for control characters, as utf8_to_native
does this for us. */
decoded=utf8_to_native(userid,i,0);
if(strlen(decoded)>opt.screen_columns-10)
decoded[opt.screen_columns-10]='\0';
iobuf_writestr(work->uidbuf,decoded);
xfree(decoded);
iobuf_writestr(work->uidbuf,"\n\t");
work->lines++;
}
/* Ignore any records other than "pri" and "uid" for easy future
growth. */
return ret;
}
/* TODO: do this as a list sent to keyserver_work rather than calling
it once for each key to get the correct counts after the import
(cosmetics, really) and to better take advantage of the keyservers
that can do multiple fetches in one go (LDAP). */
static int
show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
{
char *answer;
if(count && opt.command_fd==-1)
{
static int from=1;
tty_printf("Keys %d-%d of %d for \"%s\". ",from,numdesc,count,search);
from=numdesc+1;
}
answer=cpr_get_no_help("keysearch.prompt",
_("Enter number(s), N)ext, or Q)uit > "));
/* control-d */
if(answer[0]=='\x04')
{
printf("Q\n");
answer[0]='q';
}
if(answer[0]=='q' || answer[0]=='Q')
{
xfree(answer);
return 1;
}
else if(atoi(answer)>=1 && atoi(answer)<=numdesc)
{
char *split=answer,*num;
while((num=strsep(&split," ,"))!=NULL)
if(atoi(num)>=1 && atoi(num)<=numdesc)
keyserver_work(KS_GET,NULL,&desc[atoi(num)-1],1,
NULL,NULL,opt.keyserver);
xfree(answer);
return 1;
}
return 0;
}
/* Count and searchstr are just for cosmetics. If the count is too
small, it will grow safely. If negative it disables the "Key x-y
of z" messages. searchstr should be UTF-8 (rather than native). */
static void
keyserver_search_prompt(IOBUF buffer,const char *searchstr)
{
int i=0,validcount=0,started=0,header=0,count=1;
unsigned int maxlen,buflen,numlines=0;
KEYDB_SEARCH_DESC *desc;
byte *line=NULL;
char *localstr=NULL;
if(searchstr)
localstr=utf8_to_native(searchstr,strlen(searchstr),0);
desc=xmalloc(count*sizeof(KEYDB_SEARCH_DESC));
for(;;)
{
struct keyrec *keyrec;
int rl;
maxlen=1024;
rl=iobuf_read_line(buffer,&line,&buflen,&maxlen);
if(opt.with_colons)
{
if(!header && ascii_strncasecmp("SEARCH ",line,7)==0
&& ascii_strncasecmp(" BEGIN",&line[strlen(line)-7],6)==0)
{
header=1;
continue;
}
else if(ascii_strncasecmp("SEARCH ",line,7)==0
&& ascii_strncasecmp(" END",&line[strlen(line)-5],4)==0)
continue;
printf("%s",line);
}
/* Look for an info: line. The only current info: values
defined are the version and key count. */
if(!started && rl>0 && ascii_strncasecmp("info:",line,5)==0)
{
char *tok,*str=&line[5];
if((tok=strsep(&str,":"))!=NULL)
{
int version;
if(sscanf(tok,"%d",&version)!=1)
version=1;
if(version!=1)
{
log_error(_("invalid keyserver protocol "
"(us %d!=handler %d)\n"),1,version);
break;
}
}
if((tok=strsep(&str,":"))!=NULL && sscanf(tok,"%d",&count)==1)
{
if(count==0)
goto notfound;
else if(count<0)
count=10;
else
validcount=1;
desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
}
started=1;
continue;
}
if(rl==0)
{
keyrec=parse_keyrec(NULL);
if(keyrec==NULL)
{
if(i==0)
{
count=0;
break;
}
if(i!=count)
validcount=0;
for(;;)
{
if(show_prompt(desc,i,validcount?count:0,localstr))
break;
validcount=0;
}
break;
}
}
else
keyrec=parse_keyrec(line);
if(i==count)
{
/* keyserver helper sent more keys than they claimed in the
info: line. */
count+=10;
desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
validcount=0;
}
if(keyrec)
{
desc[i]=keyrec->desc;
if(!opt.with_colons)
{
/* screen_lines - 1 for the prompt. */
if(numlines+keyrec->lines>opt.screen_lines-1)
{
if(show_prompt(desc,i,validcount?count:0,localstr))
break;
else
numlines=0;
}
print_keyrec(i+1,keyrec);
}
numlines+=keyrec->lines;
iobuf_close(keyrec->uidbuf);
xfree(keyrec);
started=1;
i++;
}
}
notfound:
/* Leave this commented out or now, and perhaps for a very long
time. All HKPish servers return HTML error messages for
no-key-found. */
/*
if(!started)
log_info(_("keyserver does not support searching\n"));
else
*/
if(count==0)
{
if(localstr)
log_info(_("key \"%s\" not found on keyserver\n"),localstr);
else
log_info(_("key not found on keyserver\n"));
}
xfree(localstr);
xfree(desc);
xfree(line);
}
/* We sometimes want to use a different gpgkeys_xxx for a given
protocol (for example, ldaps is handled by gpgkeys_ldap). Map
these here. */
static const char *
keyserver_typemap(const char *type)
{
if(strcmp(type,"ldaps")==0)
return "ldap";
else
return type;
}
#ifdef GPGKEYS_CURL
/* The PGP LDAP and the curl fetch-a-LDAP-object methodologies are
sufficiently different that we can't use curl to do LDAP. */
static int
curl_cant_handle(const char *scheme,unsigned int direct_uri)
{
if(!direct_uri && (strcmp(scheme,"ldap")==0 || strcmp(scheme,"ldaps")==0))
return 1;
return 0;
}
#endif
#define KEYSERVER_ARGS_KEEP " -o \"%O\" \"%I\""
#define KEYSERVER_ARGS_NOKEEP " -o \"%o\" \"%i\""
static int
keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
int count,int *prog,unsigned char **fpr,size_t *fpr_len,
struct keyserver_spec *keyserver)
{
int ret=0,i,gotversion=0,outofband=0;
STRLIST temp;
unsigned int maxlen,buflen;
char *command,*end,*searchstr=NULL;
byte *line=NULL;
struct exec_info *spawn;
const char *scheme;
const char *libexecdir = get_libexecdir ();
assert(keyserver);
#ifdef EXEC_TEMPFILE_ONLY
opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
#endif
/* Build the filename for the helper to execute */
scheme=keyserver_typemap(keyserver->scheme);
#ifdef DISABLE_KEYSERVER_PATH
/* Destroy any path we might have. This is a little tricky,
portability-wise. It's not correct to delete the PATH
environment variable, as that may fall back to a system built-in
PATH. Similarly, it is not correct to set PATH to the null
string (PATH="") since this actually deletes the PATH environment
variable under MinGW. The safest thing to do here is to force
PATH to be GNUPG_LIBEXECDIR. All this is not that meaningful on
Unix-like systems (since we're going to give a full path to
gpgkeys_foo), but on W32 it prevents loading any DLLs from
directories in %PATH%.
After some more thinking about this we came to the conclusion
that it is better to load the helpers from the directory where
the program of this process lives. Fortunately Windows provides
a way to retrieve this and our get_libexecdir function has been
modified to return just this. Setting the exec-path is not
anymore required.
set_exec_path(libexecdir);
*/
#else
if(opt.exec_path_set)
{
/* If exec-path was set, and DISABLE_KEYSERVER_PATH is
undefined, then don't specify a full path to gpgkeys_foo, so
that the PATH can work. */
command=xmalloc(GPGKEYS_PREFIX_LEN+strlen(scheme)+3+strlen(EXEEXT)+1);
command[0]='\0';
}
else
#endif
{
/* Specify a full path to gpgkeys_foo. */
command=xmalloc(strlen(libexecdir)+strlen(DIRSEP_S)+
GPGKEYS_PREFIX_LEN+strlen(scheme)+3+strlen(EXEEXT)+1);
strcpy(command,libexecdir);
strcat(command,DIRSEP_S);
}
end=command+strlen(command);
strcat(command,GPGKEYS_PREFIX);
strcat(command,scheme);
if(keyserver->flags.direct_uri)
strcat(command,"uri");
strcat(command,EXEEXT);
#ifdef GPGKEYS_CURL
if(!curl_cant_handle(scheme,keyserver->flags.direct_uri)
&& path_access(command,X_OK)!=0)
strcpy(end,GPGKEYS_CURL);
#endif
if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
{
if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
{
command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_KEEP)+1);
strcat(command,KEYSERVER_ARGS_KEEP);
}
else
{
command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_NOKEEP)+1);
strcat(command,KEYSERVER_ARGS_NOKEEP);
}
ret=exec_write(&spawn,NULL,command,NULL,0,0);
}
else
ret=exec_write(&spawn,command,NULL,NULL,0,0);
xfree(command);
if(ret)
return ret;
fprintf(spawn->tochild,
"# This is a GnuPG %s keyserver communications file\n",VERSION);
fprintf(spawn->tochild,"VERSION %d\n",KEYSERVER_PROTO_VERSION);
fprintf(spawn->tochild,"PROGRAM %s\n",VERSION);
fprintf(spawn->tochild,"SCHEME %s\n",keyserver->scheme);
if(keyserver->opaque)
fprintf(spawn->tochild,"OPAQUE %s\n",keyserver->opaque);
else
{
if(keyserver->auth)
fprintf(spawn->tochild,"AUTH %s\n",keyserver->auth);
if(keyserver->host)
fprintf(spawn->tochild,"HOST %s\n",keyserver->host);
if(keyserver->port)
fprintf(spawn->tochild,"PORT %s\n",keyserver->port);
if(keyserver->path)
fprintf(spawn->tochild,"PATH %s\n",keyserver->path);
}
/* Write global options */
for(temp=opt.keyserver_options.other;temp;temp=temp->next)
fprintf(spawn->tochild,"OPTION %s\n",temp->d);
/* Write per-keyserver options */
for(temp=keyserver->options;temp;temp=temp->next)
fprintf(spawn->tochild,"OPTION %s\n",temp->d);
switch(action)
{
case KS_GET:
{
fprintf(spawn->tochild,"COMMAND GET\n\n");
/* Which keys do we want? */
for(i=0;i<count;i++)
{
int quiet=0;
if(desc[i].mode==KEYDB_SEARCH_MODE_FPR20)
{
int f;
fprintf(spawn->tochild,"0x");
for(f=0;f<MAX_FINGERPRINT_LEN;f++)
fprintf(spawn->tochild,"%02X",desc[i].u.fpr[f]);
fprintf(spawn->tochild,"\n");
}
else if(desc[i].mode==KEYDB_SEARCH_MODE_FPR16)
{
int f;
fprintf(spawn->tochild,"0x");
for(f=0;f<16;f++)
fprintf(spawn->tochild,"%02X",desc[i].u.fpr[f]);
fprintf(spawn->tochild,"\n");
}
else if(desc[i].mode==KEYDB_SEARCH_MODE_LONG_KID)
fprintf(spawn->tochild,"0x%08lX%08lX\n",
(ulong)desc[i].u.kid[0],
(ulong)desc[i].u.kid[1]);
else if(desc[i].mode==KEYDB_SEARCH_MODE_SHORT_KID)
fprintf(spawn->tochild,"0x%08lX\n",
(ulong)desc[i].u.kid[1]);
else if(desc[i].mode==KEYDB_SEARCH_MODE_EXACT)
{
fprintf(spawn->tochild,"0x0000000000000000\n");
quiet=1;
}
else if(desc[i].mode==KEYDB_SEARCH_MODE_NONE)
continue;
else
BUG();
if(!quiet)
{
if(keyserver->host)
log_info(_("requesting key %s from %s server %s\n"),
keystr_from_desc(&desc[i]),
keyserver->scheme,keyserver->host);
else
log_info(_("requesting key %s from %s\n"),
keystr_from_desc(&desc[i]),keyserver->uri);
}
}
fprintf(spawn->tochild,"\n");
break;
}
case KS_GETNAME:
{
STRLIST key;
fprintf(spawn->tochild,"COMMAND GETNAME\n\n");
/* Which names do we want? */
for(key=list;key!=NULL;key=key->next)
fprintf(spawn->tochild,"%s\n",key->d);
fprintf(spawn->tochild,"\n");
if(keyserver->host)
log_info(_("searching for names from %s server %s\n"),
keyserver->scheme,keyserver->host);
else
log_info(_("searching for names from %s\n"),keyserver->uri);
break;
}
case KS_SEND:
{
STRLIST key;
/* Note the extra \n here to send an empty keylist block */
fprintf(spawn->tochild,"COMMAND SEND\n\n\n");
for(key=list;key!=NULL;key=key->next)
{
armor_filter_context_t afx;
IOBUF buffer=iobuf_temp();
KBNODE block;
temp=NULL;
add_to_strlist(&temp,key->d);
memset(&afx,0,sizeof(afx));
afx.what=1;
/* Tell the armor filter to use Unix-style \n line
endings, since we're going to fprintf this to a file
that (on Win32) is open in text mode. The win32 stdio
will transform the \n to \r\n and we'll end up with the
proper line endings on win32. This is a no-op on
Unix. */
afx.eol[0]='\n';
iobuf_push_filter(buffer,armor_filter,&afx);
/* TODO: Remove Comment: lines from keys exported this
way? */
if(export_pubkeys_stream(buffer,temp,&block,
opt.keyserver_options.export_options)==-1)
iobuf_close(buffer);
else
{
KBNODE node;
iobuf_flush_temp(buffer);
merge_keys_and_selfsig(block);
fprintf(spawn->tochild,"INFO %08lX%08lX BEGIN\n",
(ulong)block->pkt->pkt.public_key->keyid[0],
(ulong)block->pkt->pkt.public_key->keyid[1]);
for(node=block;node;node=node->next)
{
switch(node->pkt->pkttype)
{
default:
continue;
case PKT_PUBLIC_KEY:
case PKT_PUBLIC_SUBKEY:
{
PKT_public_key *pk=node->pkt->pkt.public_key;
keyid_from_pk(pk,NULL);
fprintf(spawn->tochild,"%sb:%08lX%08lX:%u:%u:%u:%u:",
node->pkt->pkttype==PKT_PUBLIC_KEY?"pu":"su",
(ulong)pk->keyid[0],(ulong)pk->keyid[1],
pk->pubkey_algo,
nbits_from_pk(pk),
pk->timestamp,
pk->expiredate);
if(pk->is_revoked)
fprintf(spawn->tochild,"r");
if(pk->has_expired)
fprintf(spawn->tochild,"e");
fprintf(spawn->tochild,"\n");
}
break;
case PKT_USER_ID:
{
PKT_user_id *uid=node->pkt->pkt.user_id;
int r;
if(uid->attrib_data)
continue;
fprintf(spawn->tochild,"uid:");
/* Quote ':', '%', and any 8-bit
characters */
for(r=0;r<uid->len;r++)
{
if(uid->name[r]==':' || uid->name[r]=='%'
|| uid->name[r]&0x80)
fprintf(spawn->tochild,"%%%02X",
(byte)uid->name[r]);
else
fprintf(spawn->tochild,"%c",uid->name[r]);
}
fprintf(spawn->tochild,":%u:%u:",
uid->created,uid->expiredate);
if(uid->is_revoked)
fprintf(spawn->tochild,"r");
if(uid->is_expired)
fprintf(spawn->tochild,"e");
fprintf(spawn->tochild,"\n");
}
break;
/* This bit is really for the benefit of
people who store their keys in LDAP
servers. It makes it easy to do queries
for things like "all keys signed by
Isabella". */
case PKT_SIGNATURE:
{
PKT_signature *sig=node->pkt->pkt.signature;
if(!IS_UID_SIG(sig))
continue;
fprintf(spawn->tochild,"sig:%08lX%08lX:%X:%u:%u\n",
(ulong)sig->keyid[0],(ulong)sig->keyid[1],
sig->sig_class,sig->timestamp,
sig->expiredate);
}
break;
}
}
fprintf(spawn->tochild,"INFO %08lX%08lX END\n",
(ulong)block->pkt->pkt.public_key->keyid[0],
(ulong)block->pkt->pkt.public_key->keyid[1]);
fprintf(spawn->tochild,"KEY %s BEGIN\n",key->d);
fwrite(iobuf_get_temp_buffer(buffer),
iobuf_get_temp_length(buffer),1,spawn->tochild);
fprintf(spawn->tochild,"KEY %s END\n",key->d);
iobuf_close(buffer);
if(keyserver->host)
log_info(_("sending key %s to %s server %s\n"),
keystr(block->pkt->pkt.public_key->keyid),
keyserver->scheme,keyserver->host);
else
log_info(_("sending key %s to %s\n"),
keystr(block->pkt->pkt.public_key->keyid),
keyserver->uri);
release_kbnode(block);
}
free_strlist(temp);
}
break;
}
case KS_SEARCH:
{
STRLIST key;
fprintf(spawn->tochild,"COMMAND SEARCH\n\n");
/* Which keys do we want? Remember that the gpgkeys_ program
is going to lump these together into a search string. */
for(key=list;key!=NULL;key=key->next)
{
fprintf(spawn->tochild,"%s\n",key->d);
if(key!=list)
{
searchstr=xrealloc(searchstr,
strlen(searchstr)+strlen(key->d)+2);
strcat(searchstr," ");
}
else
{
searchstr=xmalloc(strlen(key->d)+1);
searchstr[0]='\0';
}
strcat(searchstr,key->d);
}
fprintf(spawn->tochild,"\n");
if(keyserver->host)
log_info(_("searching for \"%s\" from %s server %s\n"),
searchstr,keyserver->scheme,keyserver->host);
else
log_info(_("searching for \"%s\" from %s\n"),
searchstr,keyserver->uri);
break;
}
default:
log_fatal(_("no keyserver action!\n"));
break;
}
/* Done sending, so start reading. */
ret=exec_read(spawn);
if(ret)
goto fail;
/* Now handle the response */
for(;;)
{
int plen;
char *ptr;
maxlen=1024;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
{
ret=G10ERR_READ_FILE;
goto fail; /* i.e. EOF */
}
ptr=line;
/* remove trailing whitespace */
plen=strlen(ptr);
while(plen>0 && ascii_isspace(ptr[plen-1]))
plen--;
plen[ptr]='\0';
if(*ptr=='\0')
break;
if(ascii_strncasecmp(ptr,"VERSION ",8)==0)
{
gotversion=1;
if(atoi(&ptr[8])!=KEYSERVER_PROTO_VERSION)
{
log_error(_("invalid keyserver protocol (us %d!=handler %d)\n"),
KEYSERVER_PROTO_VERSION,atoi(&ptr[8]));
goto fail;
}
}
else if(ascii_strncasecmp(ptr,"PROGRAM ",8)==0)
{
if(ascii_strncasecmp(&ptr[8],VERSION,strlen(VERSION))!=0)
log_info(_("WARNING: keyserver handler from a different"
" version of GnuPG (%s)\n"),&ptr[8]);
}
else if(ascii_strncasecmp(ptr,"OPTION OUTOFBAND",16)==0)
outofband=1; /* Currently the only OPTION */
}
if(!gotversion)
{
log_error(_("keyserver did not send VERSION\n"));
goto fail;
}
if(!outofband)
switch(action)
{
case KS_GET:
case KS_GETNAME:
{
void *stats_handle;
stats_handle=import_new_stats_handle();
/* Slurp up all the key data. In the future, it might be
nice to look for KEY foo OUTOFBAND and FAILED indicators.
It's harmless to ignore them, but ignoring them does make
gpg complain about "no valid OpenPGP data found". One
way to do this could be to continue parsing this
line-by-line and make a temp iobuf for each key. */
import_keys_stream(spawn->fromchild,stats_handle,fpr,fpr_len,
opt.keyserver_options.import_options);
import_print_stats(stats_handle);
import_release_stats_handle(stats_handle);
break;
}
/* Nothing to do here */
case KS_SEND:
break;
case KS_SEARCH:
keyserver_search_prompt(spawn->fromchild,searchstr);
break;
default:
log_fatal(_("no keyserver action!\n"));
break;
}
fail:
xfree(line);
xfree(searchstr);
*prog=exec_finish(spawn);
return ret;
}
static int
keyserver_work(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
int count,unsigned char **fpr,size_t *fpr_len,
struct keyserver_spec *keyserver)
{
int rc=0,ret=0;
if(!keyserver)
{
log_error(_("no keyserver known (use option --keyserver)\n"));
return G10ERR_BAD_URI;
}
#ifdef DISABLE_KEYSERVER_HELPERS
log_error(_("external keyserver calls are not supported in this build\n"));
return G10ERR_KEYSERVER;
#else
/* Spawn a handler */
rc=keyserver_spawn(action,list,desc,count,&ret,fpr,fpr_len,keyserver);
if(ret)
{
switch(ret)
{
case KEYSERVER_SCHEME_NOT_FOUND:
log_error(_("no handler for keyserver scheme `%s'\n"),
keyserver->scheme);
break;
case KEYSERVER_NOT_SUPPORTED:
log_error(_("action `%s' not supported with keyserver "
"scheme `%s'\n"),
action==KS_GET?"get":action==KS_SEND?"send":
action==KS_SEARCH?"search":"unknown",
keyserver->scheme);
break;
case KEYSERVER_VERSION_ERROR:
log_error(_(GPGKEYS_PREFIX "%s does not support"
" handler version %d\n"),
keyserver_typemap(keyserver->scheme),
KEYSERVER_PROTO_VERSION);
break;
case KEYSERVER_TIMEOUT:
log_error(_("keyserver timed out\n"));
break;
case KEYSERVER_INTERNAL_ERROR:
default:
log_error(_("keyserver internal error\n"));
break;
}
return G10ERR_KEYSERVER;
}
if(rc)
{
log_error(_("keyserver communications error: %s\n"),g10_errstr(rc));
return rc;
}
return 0;
#endif /* ! DISABLE_KEYSERVER_HELPERS*/
}
int
keyserver_export(STRLIST users)
{
STRLIST sl=NULL;
KEYDB_SEARCH_DESC desc;
int rc=0;
/* Weed out descriptors that we don't support sending */
for(;users;users=users->next)
{
classify_user_id (users->d, &desc);
if(desc.mode!=KEYDB_SEARCH_MODE_SHORT_KID &&
desc.mode!=KEYDB_SEARCH_MODE_LONG_KID &&
desc.mode!=KEYDB_SEARCH_MODE_FPR16 &&
desc.mode!=KEYDB_SEARCH_MODE_FPR20)
{
log_error(_("\"%s\" not a key ID: skipping\n"),users->d);
continue;
}
else
append_to_strlist(&sl,users->d);
}
if(sl)
{
rc=keyserver_work(KS_SEND,sl,NULL,0,NULL,NULL,opt.keyserver);
free_strlist(sl);
}
return rc;
}
int
keyserver_import(STRLIST users)
{
KEYDB_SEARCH_DESC *desc;
int num=100,count=0;
int rc=0;
/* Build a list of key ids */
desc=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
for(;users;users=users->next)
{
classify_user_id (users->d, &desc[count]);
if(desc[count].mode!=KEYDB_SEARCH_MODE_SHORT_KID &&
desc[count].mode!=KEYDB_SEARCH_MODE_LONG_KID &&
desc[count].mode!=KEYDB_SEARCH_MODE_FPR16 &&
desc[count].mode!=KEYDB_SEARCH_MODE_FPR20)
{
log_error(_("\"%s\" not a key ID: skipping\n"),users->d);
continue;
}
count++;
if(count==num)
{
num+=100;
desc=xrealloc(desc,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
if(count>0)
rc=keyserver_work(KS_GET,NULL,desc,count,NULL,NULL,opt.keyserver);
xfree(desc);
return rc;
}
int
keyserver_import_fprint(const byte *fprint,size_t fprint_len,
struct keyserver_spec *keyserver)
{
KEYDB_SEARCH_DESC desc;
memset(&desc,0,sizeof(desc));
if(fprint_len==16)
desc.mode=KEYDB_SEARCH_MODE_FPR16;
else if(fprint_len==20)
desc.mode=KEYDB_SEARCH_MODE_FPR20;
else
return -1;
memcpy(desc.u.fpr,fprint,fprint_len);
/* TODO: Warn here if the fingerprint we got doesn't match the one
we asked for? */
return keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,keyserver);
}
int
keyserver_import_keyid(u32 *keyid,struct keyserver_spec *keyserver)
{
KEYDB_SEARCH_DESC desc;
memset(&desc,0,sizeof(desc));
desc.mode=KEYDB_SEARCH_MODE_LONG_KID;
desc.u.kid[0]=keyid[0];
desc.u.kid[1]=keyid[1];
return keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,keyserver);
}
/* code mostly stolen from do_export_stream */
static int
keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
{
int rc=0,ndesc,num=100;
KBNODE keyblock=NULL,node;
KEYDB_HANDLE kdbhd;
KEYDB_SEARCH_DESC *desc;
STRLIST sl;
*count=0;
*klist=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
kdbhd=keydb_new(0);
if(!users)
{
ndesc = 1;
desc = xmalloc_clear ( ndesc * sizeof *desc);
desc[0].mode = KEYDB_SEARCH_MODE_FIRST;
}
else
{
for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++)
;
desc = xmalloc ( ndesc * sizeof *desc);
for (ndesc=0, sl=users; sl; sl = sl->next)
{
if(classify_user_id (sl->d, desc+ndesc))
ndesc++;
else
log_error (_("key \"%s\" not found: %s\n"),
sl->d, g10_errstr (G10ERR_INV_USER_ID));
}
}
while (!(rc = keydb_search (kdbhd, desc, ndesc)))
{
if (!users)
desc[0].mode = KEYDB_SEARCH_MODE_NEXT;
/* read the keyblock */
rc = keydb_get_keyblock (kdbhd, &keyblock );
if( rc )
{
log_error (_("error reading keyblock: %s\n"), g10_errstr(rc) );
goto leave;
}
if((node=find_kbnode(keyblock,PKT_PUBLIC_KEY)))
{
/* This is to work around a bug in some keyservers (pksd and
OKS) that calculate v4 RSA keyids as if they were v3 RSA.
The answer is to refresh both the correct v4 keyid
(e.g. 99242560) and the fake v3 keyid (e.g. 68FDDBC7).
This only happens for key refresh using the HKP scheme
and if the refresh-add-fake-v3-keyids keyserver option is
set. */
if(fakev3 && is_RSA(node->pkt->pkt.public_key->pubkey_algo) &&
node->pkt->pkt.public_key->version>=4)
{
(*klist)[*count].mode=KEYDB_SEARCH_MODE_LONG_KID;
mpi_get_keyid(node->pkt->pkt.public_key->pkey[0],
(*klist)[*count].u.kid);
(*count)++;
if(*count==num)
{
num+=100;
*klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
/* v4 keys get full fingerprints. v3 keys get long keyids.
This is because it's easy to calculate any sort of keyid
from a v4 fingerprint, but not a v3 fingerprint. */
if(node->pkt->pkt.public_key->version<4)
{
(*klist)[*count].mode=KEYDB_SEARCH_MODE_LONG_KID;
keyid_from_pk(node->pkt->pkt.public_key,
(*klist)[*count].u.kid);
}
else
{
size_t dummy;
(*klist)[*count].mode=KEYDB_SEARCH_MODE_FPR20;
fingerprint_from_pk(node->pkt->pkt.public_key,
(*klist)[*count].u.fpr,&dummy);
}
/* This is a little hackish, using the skipfncvalue as a
void* pointer to the keyserver spec, but we don't need
the skipfnc here, and it saves having an additional field
for this (which would be wasted space most of the
time). */
(*klist)[*count].skipfncvalue=NULL;
/* Are we honoring preferred keyservers? */
if(opt.keyserver_options.options&KEYSERVER_HONOR_KEYSERVER_URL)
{
PKT_user_id *uid=NULL;
PKT_signature *sig=NULL;
merge_keys_and_selfsig(keyblock);
for(node=node->next;node;node=node->next)
{
if(node->pkt->pkttype==PKT_USER_ID
&& node->pkt->pkt.user_id->is_primary)
uid=node->pkt->pkt.user_id;
else if(node->pkt->pkttype==PKT_SIGNATURE
&& node->pkt->pkt.signature->
flags.chosen_selfsig && uid)
{
sig=node->pkt->pkt.signature;
break;
}
}
/* Try and parse the keyserver URL. If it doesn't work,
then we end up writing NULL which indicates we are
the same as any other key. */
if(sig)
(*klist)[*count].skipfncvalue=parse_preferred_keyserver(sig);
}
(*count)++;
if(*count==num)
{
num+=100;
*klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
}
if(rc==-1)
rc=0;
leave:
if(rc)
xfree(*klist);
xfree(desc);
keydb_release(kdbhd);
release_kbnode(keyblock);
return rc;
}
/* Note this is different than the original HKP refresh. It allows
usernames to refresh only part of the keyring. */
int
keyserver_refresh(STRLIST users)
{
int rc,count,numdesc,fakev3=0;
KEYDB_SEARCH_DESC *desc;
unsigned int options=opt.keyserver_options.import_options;
/* We switch merge-only on during a refresh, as 'refresh' should
never import new keys, even if their keyids match. */
opt.keyserver_options.import_options|=IMPORT_MERGE_ONLY;
/* Similarly, we switch on fast-import, since refresh may make
multiple import sets (due to preferred keyserver URLs). We don't
want each set to rebuild the trustdb. Instead we do it once at
the end here. */
opt.keyserver_options.import_options|=IMPORT_FAST;
/* If refresh_add_fake_v3_keyids is on and it's a HKP or MAILTO
scheme, then enable fake v3 keyid generation. */
if((opt.keyserver_options.options&KEYSERVER_ADD_FAKE_V3) && opt.keyserver
&& (ascii_strcasecmp(opt.keyserver->scheme,"hkp")==0 ||
ascii_strcasecmp(opt.keyserver->scheme,"mailto")==0))
fakev3=1;
rc=keyidlist(users,&desc,&numdesc,fakev3);
if(rc)
return rc;
count=numdesc;
if(count>0)
{
int i;
/* Try to handle preferred keyserver keys first */
for(i=0;i<numdesc;i++)
{
if(desc[i].skipfncvalue)
{
struct keyserver_spec *keyserver=desc[i].skipfncvalue;
/* We use the keyserver structure we parsed out before.
Note that a preferred keyserver without a scheme://
will be interpreted as hkp:// */
rc=keyserver_work(KS_GET,NULL,&desc[i],1,NULL,NULL,keyserver);
if(rc)
log_info(_("WARNING: unable to refresh key %s"
" via %s: %s\n"),keystr_from_desc(&desc[i]),
keyserver->uri,g10_errstr(rc));
else
{
/* We got it, so mark it as NONE so we don't try and
get it again from the regular keyserver. */
desc[i].mode=KEYDB_SEARCH_MODE_NONE;
count--;
}
free_keyserver_spec(keyserver);
}
}
}
if(count>0)
{
if(opt.keyserver)
{
if(count==1)
log_info(_("refreshing 1 key from %s\n"),opt.keyserver->uri);
else
log_info(_("refreshing %d keys from %s\n"),
count,opt.keyserver->uri);
}
rc=keyserver_work(KS_GET,NULL,desc,numdesc,NULL,NULL,opt.keyserver);
}
xfree(desc);
opt.keyserver_options.import_options=options;
/* If the original options didn't have fast import, and the trustdb
is dirty, rebuild. */
if(!(opt.keyserver_options.import_options&IMPORT_FAST))
trustdb_check_or_update();
return rc;
}
int
keyserver_search(STRLIST tokens)
{
if(tokens)
return keyserver_work(KS_SEARCH,tokens,NULL,0,NULL,NULL,opt.keyserver);
else
return 0;
}
int
keyserver_fetch(STRLIST urilist)
{
KEYDB_SEARCH_DESC desc;
STRLIST sl;
unsigned int options=opt.keyserver_options.import_options;
/* Switch on fast-import, since fetch can handle more than one
import and we don't want each set to rebuild the trustdb.
Instead we do it once at the end. */
opt.keyserver_options.import_options|=IMPORT_FAST;
/* A dummy desc since we're not actually fetching a particular key
ID */
memset(&desc,0,sizeof(desc));
desc.mode=KEYDB_SEARCH_MODE_EXACT;
for(sl=urilist;sl;sl=sl->next)
{
struct keyserver_spec *spec;
spec=parse_keyserver_uri(sl->d,1,NULL,0);
if(spec)
{
int rc;
/*
Set the direct_uri flag so we know later to call a direct
handler instead of the keyserver style. This lets us use
gpgkeys_curl or gpgkeys_ldapuri instead of gpgkeys_ldap to
fetch things like
ldap://keyserver.pgp.com/o=PGP%20keys?pgpkey?sub?pgpkeyid=99242560
*/
spec->flags.direct_uri=1;
rc=keyserver_work(KS_GET,NULL,&desc,1,NULL,NULL,spec);
if(rc)
log_info (_("WARNING: unable to fetch URI %s: %s\n"),
sl->d,g10_errstr(rc));
free_keyserver_spec(spec);
}
else
log_info (_("WARNING: unable to parse URI %s\n"),sl->d);
}
opt.keyserver_options.import_options=options;
/* If the original options didn't have fast import, and the trustdb
is dirty, rebuild. */
if(!(opt.keyserver_options.import_options&IMPORT_FAST))
trustdb_check_or_update();
return 0;
}
/* Import key in a CERT or pointed to by a CERT */
int
keyserver_import_cert(const char *name,unsigned char **fpr,size_t *fpr_len)
{
char *domain,*look,*url;
IOBUF key;
int type,rc=-1;
look=xstrdup(name);
domain=strrchr(look,'@');
if(domain)
*domain='.';
- type=get_cert(look,max_cert_size,&key,&url);
+ type=get_cert(look,max_cert_size,&key,NULL,NULL,&url);
if(type==1)
{
int armor_status=opt.no_armor;
/* CERTs are always in binary format */
opt.no_armor=1;
rc=import_keys_stream(key,NULL,fpr,fpr_len,
opt.keyserver_options.import_options);
opt.no_armor=armor_status;
iobuf_close(key);
}
else if(type==2)
{
struct keyserver_spec *spec;
spec=parse_keyserver_uri(url,1,NULL,0);
if(spec)
{
STRLIST list=NULL;
add_to_strlist(&list,url);
rc=keyserver_fetch(list);
free_strlist(list);
free_keyserver_spec(spec);
}
xfree(url);
}
xfree(look);
return rc;
}
/* Import key pointed to by a PKA record. Return the requested
fingerprint in fpr. */
int
keyserver_import_pka(const char *name,unsigned char **fpr,size_t *fpr_len)
{
char *uri;
int rc=-1;
*fpr=xmalloc(20);
*fpr_len=20;
uri = get_pka_info (name, *fpr);
if (uri)
{
struct keyserver_spec *spec;
spec = parse_keyserver_uri (uri, 1, NULL, 0);
if (spec)
{
rc=keyserver_import_fprint (*fpr, 20, spec);
free_keyserver_spec (spec);
}
xfree (uri);
}
if(rc!=0)
xfree(*fpr);
return rc;
}
/* Import all keys that match name */
int
keyserver_import_name(const char *name,unsigned char **fpr,size_t *fpr_len,
struct keyserver_spec *keyserver)
{
STRLIST list=NULL;
int rc;
append_to_strlist(&list,name);
rc=keyserver_work(KS_GETNAME,list,NULL,0,fpr,fpr_len,keyserver);
free_strlist(list);
return rc;
}
/* Use the PGP Universal trick of asking ldap://keys.(maildomain) for
the key. */
int
keyserver_import_ldap(const char *name,unsigned char **fpr,size_t *fpr_len)
{
char *domain;
struct keyserver_spec *keyserver;
STRLIST list=NULL;
int rc;
append_to_strlist(&list,name);
/* Parse out the domain */
domain=strrchr(name,'@');
if(!domain)
return G10ERR_GENERAL;
domain++;
keyserver=xmalloc_clear(sizeof(struct keyserver_spec));
keyserver->scheme=xstrdup("ldap");
keyserver->host=xmalloc(5+strlen(domain)+1);
strcpy(keyserver->host,"keys.");
strcat(keyserver->host,domain);
keyserver->uri=xmalloc(strlen(keyserver->scheme)+
3+strlen(keyserver->host)+1);
strcpy(keyserver->uri,keyserver->scheme);
strcat(keyserver->uri,"://");
strcat(keyserver->uri,keyserver->host);
rc=keyserver_work(KS_GETNAME,list,NULL,0,fpr,fpr_len,keyserver);
free_strlist(list);
free_keyserver_spec(keyserver);
return rc;
}
diff --git a/include/ChangeLog b/include/ChangeLog
index 733ca20db..de666b972 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,563 +1,567 @@
+2006-03-16 David Shaw <dshaw@jabberwocky.com>
+
+ * util.h: Handle the fixed IPGP type with fingerprint.
+
2006-02-14 Werner Koch <wk@gnupg.org>
* errors.h (G10ERR_NO_DATA): New.
2005-12-23 David Shaw <dshaw@jabberwocky.com>
* util.h: Prototype get_cert().
2005-07-27 Werner Koch <wk@g10code.com>
* memory.h (m_free, m_alloc, m_realloc, m_strdup): Removed and
replaced all over by xfoo functions. This is to ease porting to
gnupg 1.9.
(xmalloc_secure) [M_DEBUG]: Correctly map to m_debug_alloc_secure.
2005-06-23 David Shaw <dshaw@jabberwocky.com>
* http.h: Fix prototypes for http_open_document and http_open
again, to handle the new different auth for regular files and
proxies.
2005-06-21 David Shaw <dshaw@jabberwocky.com>
* http.h: Fix prototypes for http_open_document and http_open to
pass in auth and proxyauth.
2005-05-19 Werner Koch <wk@g10code.com>
* util.h: Add definitions for membuf functions.
2005-05-05 David Shaw <dshaw@jabberwocky.com>
* util.h: Remove add_days_to_timestamp as unused.
2005-04-22 David Shaw <dshaw@jabberwocky.com>
* distfiles: Add assuan.h.
2005-04-04 Werner Koch <wk@g10code.com>
* memory.h (xcalloc, xcalloc_secure): Replaced macros by functions.
2005-03-31 Werner Koch <wk@g10code.com>
* assuan.h: New. Taken from libassuan 0.6.9.
2005-03-18 David Shaw <dshaw@jabberwocky.com>
* ttyio.h: Prototype tty_enable_completion(), and
tty_disable_completion().
2005-02-09 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add a flag for a symmetric DEK.
2004-12-16 David Shaw <dshaw@jabberwocky.com>
* memory.h: Return a flag to indicate whether we got the lock.
2004-11-29 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add PUBKEY_USAGE_UNKNOWN.
2004-11-03 Timo Schulz <twoaday@g10code.com>
* errors.h: Add w32_strerror prototype.
* dynload.h: Use w32_strerror.
2004-10-27 Werner Koch <wk@g10code.com>
* dynload.h: Always use it for _WIN32.
2004-10-21 Werner Koch <wk@g10code.com>
* util.h [!HAVE_VASPRINTF]: Removed prototype.
2004-10-15 Werner Koch <wk@g10code.com>
* util.h [!HAVE_VASPRINTF]: Add asprintf prototype.
2004-10-13 David Shaw <dshaw@jabberwocky.com>
* keyserver.h: Add KEYSERVER_TIMEOUT.
2004-09-30 David Shaw <dshaw@jabberwocky.com>
* util.h: Prototype destroy_dotlock(). From Werner on stable
branch.
2004-09-10 David Shaw <dshaw@jabberwocky.com>
* http.h: Add auth field for a parsed_uri to allow for basic auth.
2004-09-09 Werner Koch <wk@g10code.com>
* errors.h (G10ERR_NO_CARD, G10ERR_CANCELED): New error codes.
2004-04-27 Werner Koch <wk@gnupg.org>
* mpi.h: Renamed prototype parameter name to avoid gcc warnings.
2004-03-04 David Shaw <dshaw@jabberwocky.com>
* iobuf.h: Remove iobuf_set_block_mode() and
iobuf_in_block_mode().
2004-02-21 David Shaw <dshaw@jabberwocky.com>
* util.h: Prototype for hextobyte().
2004-01-16 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Remove the old CIPHER_ALGO_RINJDAEL values.
is_ELGAMAL() now only matches type 16 and not type 20.
2004-01-15 David Shaw <dshaw@jabberwocky.com>
* util.h: Add prototype for print_string2().
2003-12-28 David Shaw <dshaw@jabberwocky.com>
* http.h: Pass the http proxy from outside rather than pulling it
from the evironment.
2003-12-28 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Removal of unnecessary RISC OS stuff.
2003-12-17 David Shaw <dshaw@jabberwocky.com>
* mpi.h (gcry_mpi, mpi_get_opaque, mpi_set_opaque): Make nbits and
the length of an opaque MPI unsigned.
* cipher.h (pubkey_verify): Remove old unused code.
2003-12-03 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Make cipher list match 2440bis-09.
2003-11-20 David Shaw <dshaw@jabberwocky.com>
* util.h: Add prototype for match_multistr().
2003-10-31 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add COMPRESS_ALGO_BZIP2.
2003-10-04 Timo Schulz <twoaday@freakmail.de>
* dynload [WIN32] (dlclose): Do not use CloseHandle but FreeLibrary.
2003-09-29 Werner Koch <wk@gnupg.org>
* cipher.h (PUBKEY_USAGE_AUTH): New.
2003-09-28 Timo Schulz <twoaday@freakmail.de>
* util.h [WIN32]: Prototype for asprintf.
* dynload.h [WIN32]: Define RTLD_LAZY.
2003-09-28 Werner Koch <wk@gnupg.org>
* util.h: Add the atoi_* and xtoi_* suite of macros from 1.9.
* dynload.h: New. Taken from 1.9.
2003-09-27 Werner Koch <wk@gnupg.org>
* memory.h (xmalloc): Define xmalloc macros in terms of m_alloc.
2003-09-04 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Drop TIGER/192 support.
2003-08-28 David Shaw <dshaw@jabberwocky.com>
* util.h: s/__MINGW32__/_WIN32/ to help building on native Windows
compilers. Requested by Brian Gladman. From Werner on stable
branch.
2003-07-10 David Shaw <dshaw@jabberwocky.com>
* types.h: Prefer using uint64_t when creating a 64-bit unsigned
type. This avoids a warning on compilers that support but complain
about unsigned long long.
* util.h (ascii_isspace): New variation on isspace() that is
immune from locale changes.
* util.h: Make sure that only ascii is passed to isfoo
functions. (From Werner on stable branch).
2003-05-24 David Shaw <dshaw@jabberwocky.com>
* cipher.h, i18n.h, iobuf.h, memory.h, mpi.h, types.h, util.h:
Edit all preprocessor instructions to remove whitespace before the
'#'. This is not required by C89, but there are some compilers
out there that don't like it.
2003-05-14 David Shaw <dshaw@jabberwocky.com>
* types.h: Add initializer macros for 64-bit unsigned type.
2003-05-02 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add constants for compression algorithms.
2003-03-11 David Shaw <dshaw@jabberwocky.com>
* http.h: Add HTTP_FLAG_TRY_SRV.
2003-02-11 David Shaw <dshaw@jabberwocky.com>
* types.h: Try and use uint64_t for a 64-bit type.
2003-02-04 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add constants for new SHAs.
2002-11-13 David Shaw <dshaw@jabberwocky.com>
* util.h [__CYGWIN32__]: Don't need the registry prototypes. From
Werner on stable branch.
2002-11-06 David Shaw <dshaw@jabberwocky.com>
* util.h: Add wipememory2() macro (same as wipememory, but can
specify the byte to wipe with).
2002-10-31 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Prefixed all RISC OS prototypes with
riscos_*
* zlib-riscos.h: New. This is macro magic in order to make the
zlib library calls indeed call the RISC OS ZLib module.
2002-10-31 David Shaw <dshaw@jabberwocky.com>
* util.h: Add wipememory() macro.
2002-10-29 Stefan Bellon <sbellon@sbellon.de>
* util.h: Added parameter argument to make_basename() needed for
filetype support.
[__riscos__]: Added prototype.
2002-10-28 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Added prototypes for new filetype support.
2002-10-19 David Shaw <dshaw@jabberwocky.com>
* distfiles, _regex.h: Add _regex.h from glibc 2.3.1.
2002-10-14 David Shaw <dshaw@jabberwocky.com>
* keyserver.h: Go to KEYSERVER_PROTO_VERSION 1.
2002-10-08 David Shaw <dshaw@jabberwocky.com>
* keyserver.h: Add new error code KEYSERVER_UNREACHABLE.
2002-10-03 David Shaw <dshaw@jabberwocky.com>
* util.h: Add new log_warning logger command which can be switched
between log_info and log_error via log_set_strict.
2002-09-24 David Shaw <dshaw@jabberwocky.com>
* keyserver.h: Add some new error codes for better GPA support.
2002-09-10 Werner Koch <wk@gnupg.org>
* mpi.h (mpi_is_protected, mpi_set_protect_flag)
(mpi_clear_protect_flag): Removed.
(mpi_get_nbit_info, mpi_set_nbit_info): Removed.
2002-08-13 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add AES aliases for RIJNDAEL algo numbers.
2002-08-07 David Shaw <dshaw@jabberwocky.com>
* cipher.h: Add md_algo_present().
2002-08-06 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Added riscos_getchar().
2002-06-21 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Further moving away of RISC OS specific
stuff from general code.
2002-06-20 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Added riscos_set_filetype().
2002-06-14 David Shaw <dshaw@jabberwocky.com>
* util.h: Add pop_strlist() from strgutil.c.
2002-06-07 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: RISC OS needs strings.h for strcasecmp()
and strncasecmp().
2002-05-22 Werner Koch <wk@gnupg.org>
* util.h: Add strncasecmp. Removed stricmp and memicmp.
2002-05-10 Stefan Bellon <sbellon@sbellon.de>
* mpi.h: New function mpi_debug_alloc_like for M_DEBUG.
* util.h [__riscos__]: Make use of __func__ that later
Norcroft compiler provides.
* memory.h: Fixed wrong definition of m_alloc_secure_clear.
2002-04-23 David Shaw <dshaw@jabberwocky.com>
* util.h: New function answer_is_yes_no_default() to give a
default answer.
2002-04-22 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Removed riscos_open, riscos_fopen and
riscos_fstat as those special versions aren't needed anymore.
2002-02-19 David Shaw <dshaw@jabberwocky.com>
* keyserver.h: Add KEYSERVER_NOT_SUPPORTED for unsupported actions
(say, a keyserver that has no way to search, or a readonly
keyserver that has no way to add).
2002-01-02 Stefan Bellon <sbellon@sbellon.de>
* util.h [__riscos__]: Updated prototype list.
* types.h [__riscos__]: Changed comment wording.
2001-12-27 David Shaw <dshaw@jabberwocky.com>
* KEYSERVER_SCHEME_NOT_FOUND should be 127 to match the POSIX
system() (via /bin/sh) way of signaling this.
* Added G10ERR_KEYSERVER
2001-12-27 Werner Koch <wk@gnupg.org>
* util.h [MINGW32]: Fixed name of include file.
2001-12-22 Timo Schulz <ts@winpt.org>
* util.h (is_file_compressed): New.
2001-12-19 Werner Koch <wk@gnupg.org>
* util.h [CYGWIN32]: Allow this as an alias for MINGW32. Include
stdarg.h becuase we use the va_list type. By Disastry.
2001-09-28 Werner Koch <wk@gnupg.org>
* cipher.h (PUBKEY_USAGE_CERT): New.
2001-09-07 Werner Koch <wk@gnupg.org>
* util.h: Add strsep().
2001-08-30 Werner Koch <wk@gnupg.org>
* cipher.h (DEK): Added use_mdc.
2001-08-24 Werner Koch <wk@gnupg.org>
* cipher.h (md_write): Made buf arg const.
2001-08-20 Werner Koch <wk@gnupg.org>
* cipher.h (DEK): Added algo_info_printed;
* util.h [__riscos__]: Added prototypes and made sure that we
never use __attribute__.
* cipher.h, iobuf.h, memory.h, mpi.h [__riscos__]: extern hack.
* i18n.h [__riscos__]: Use another include file
2001-05-30 Werner Koch <wk@gnupg.org>
* ttyio.h (tty_printf): Add missing parenthesis for non gcc.
* http.h: Removed trailing comma to make old ccs happy. Both are
by Albert Chin.
2001-05-25 Werner Koch <wk@gnupg.org>
* ttyio.h (tty_printf): Add printf attribute.
2001-04-23 Werner Koch <wk@gnupg.org>
* http.h: New flag HTTP_FLAG_NO_SHUTDOWN.
2001-04-13 Werner Koch <wk@gnupg.org>
* iobuf.h: Removed iobuf_fopen.
2001-03-01 Werner Koch <wk@gnupg.org>
* errors.h (G10ERR_UNU_SECKEY,G10ERR_UNU_PUBKEY): New
2000-11-30 Werner Koch <wk@gnupg.org>
* iobuf.h (iobuf_translate_file_handle): Add prototype.
2000-11-11 Paul Eggert <eggert@twinsun.com>
* iobuf.h (iobuf_get_filelength): Now returns off_t, not u32.
(struct iobuf_struct, iobuf_set_limit,
iobuf_tell, iobuf_seek): Use off_t, not ulong, for file offsets.
2000-10-12 Werner Koch <wk@gnupg.org>
* mpi.h: Changed the way mpi_limb_t is defined.
Wed Sep 6 17:55:47 CEST 2000 Werner Koch <wk@openit.de>
* iobuf.c (IOBUF_FILELENGTH_LIMIT): New.
2000-03-14 14:03:43 Werner Koch (wk@habibti.openit.de)
* types.h (HAVE_U64_TYPEDEF): Defined depending on configure test.
Thu Jan 13 19:31:58 CET 2000 Werner Koch <wk@gnupg.de>
* types.h (HAVE_U64_TYPEDEF): Add a test for _LONGLONG which fixes
this long living SGI bug. Reported by Alec Habig.
Sat Dec 4 12:30:28 CET 1999 Werner Koch <wk@gnupg.de>
* iobuf.h (IOBUFCTRL_CANCEL): Nww.
Mon Oct 4 21:23:04 CEST 1999 Werner Koch <wk@gnupg.de>
* errors.h (G10ERR_NOT_PROCESSED): New.
Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* i18n.h: Add support for simple-gettext.
Tue Jun 29 21:44:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* util.h (stricmp): Use strcasecmp as replacement.
Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (MD_HANDLE): Assigned a structure name.
Fri Apr 9 12:26:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (BLOWFISH160): Removed.
Tue Apr 6 19:58:12 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (DEK): increased max. key length to 32 bytes
Sat Feb 20 21:40:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* g10lib.h: Removed file and changed all files that includes this.
Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* types.h (STRLIST): Add field flags.
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (CIPHER_ALGO_TWOFISH): Chnaged ID to 10 and renamed
the old experimenatl algorithm to xx_OLD.
Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (MD_BUFFER_SIZE): Removed.
Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* types.h: fix for SUNPRO_C
Tue Dec 8 13:15:16 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* mpi.h (MPI): Changed the structure name to gcry_mpi and
changed all users.
Tue Oct 20 11:40:00 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.h (iobuf_get_temp_buffer): New.
Tue Oct 13 12:40:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.h (iobuf_get): Now uses .nofast
(iobuf_get2): Removed.
Mon Sep 14 09:17:22 1998 Werner Koch (wk@(none))
* util.h (HAVE_ATEXIT): New.
(HAVE_RAISE): New.
Mon Jul 6 10:41:55 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h (PUBKEY_USAGE_): New.
Mon Jul 6 09:49:51 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.h (iobuf_set_error): New.
(iobuf_error): New.
Sat Jun 13 17:31:32 1998 Werner Koch (wk@isil.d.shuttle.de)
* g10lib.h: New as interface for the g10lib.
Mon Jun 8 22:14:48 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h (CIPHER_ALGO_CAST5): Changed name from .. CAST
Thu May 21 13:25:51 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h: removed ROT 5 and changed one id and add dummy
Tue May 19 18:09:05 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h (DIGEST_ALGO_TIGER): Chnaged id from 101 to 6.
Mon May 4 16:37:17 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h (PUBKEY_ALGO_ELGAMAL_E): New, with value of the
old one.
* (is_ELGAMAL, is_RSA): New macros
Sun Apr 26 14:35:24 1998 Werner Koch (wk@isil.d.shuttle.de)
* types.h: New type u64
Mon Mar 9 12:59:55 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h: Included dsa.h.
Tue Mar 3 15:11:21 1998 Werner Koch (wk@isil.d.shuttle.de)
* cipher.h (random.h): Add new header and move all relevalt
functions to this header.
Copyright 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/include/util.h b/include/util.h
index eba1c84f0..ee25be12e 100644
--- a/include/util.h
+++ b/include/util.h
@@ -1,333 +1,334 @@
/* util.h
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
- * 2004 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef G10_UTIL_H
#define G10_UTIL_H
#if defined (_WIN32) || defined (__CYGWIN32__)
#include <stdarg.h>
#endif
#include "types.h"
#include "errors.h"
#include "types.h"
#include "mpi.h"
typedef struct {
int *argc; /* pointer to argc (value subject to change) */
char ***argv; /* pointer to argv (value subject to change) */
unsigned flags; /* Global flags (DO NOT CHANGE) */
int err; /* print error about last option */
/* 1 = warning, 2 = abort */
int r_opt; /* return option */
int r_type; /* type of return value (0 = no argument found)*/
union {
int ret_int;
long ret_long;
ulong ret_ulong;
char *ret_str;
} r; /* Return values */
struct {
int idx;
int inarg;
int stopped;
const char *last;
void *aliases;
const void *cur_alias;
} internal; /* DO NOT CHANGE */
} ARGPARSE_ARGS;
typedef struct {
int short_opt;
const char *long_opt;
unsigned flags;
const char *description; /* optional option description */
} ARGPARSE_OPTS;
/*-- logger.c --*/
void log_set_logfile( const char *name, int fd );
FILE *log_stream(void);
void g10_log_print_prefix(const char *text);
void log_set_name( const char *name );
const char *log_get_name(void);
void log_set_pid( int pid );
int log_get_errorcount( int clear );
void log_inc_errorcount(void);
int log_set_strict(int val);
void g10_log_hexdump( const char *text, const char *buf, size_t len );
#if defined (__riscos__) \
|| (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ))
void g10_log_bug( const char *fmt, ... )
__attribute__ ((noreturn, format (printf,1,2)));
void g10_log_bug0( const char *, int, const char * ) __attribute__ ((noreturn));
void g10_log_fatal( const char *fmt, ... )
__attribute__ ((noreturn, format (printf,1,2)));
void g10_log_error( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
void g10_log_info( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
void g10_log_warning( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
void g10_log_debug( const char *fmt, ... ) __attribute__ ((format (printf,1,2)));
#ifndef __riscos__
#define BUG() g10_log_bug0( __FILE__ , __LINE__, __FUNCTION__ )
#else
#define BUG() g10_log_bug0( __FILE__ , __LINE__, __func__ )
#endif
#else
void g10_log_bug( const char *fmt, ... );
void g10_log_bug0( const char *, int );
void g10_log_fatal( const char *fmt, ... );
void g10_log_error( const char *fmt, ... );
void g10_log_info( const char *fmt, ... );
void g10_log_warning( const char *fmt, ... );
void g10_log_debug( const char *fmt, ... );
#define BUG() g10_log_bug0( __FILE__ , __LINE__ )
#endif
#define log_hexdump g10_log_hexdump
#define log_bug g10_log_bug
#define log_bug0 g10_log_bug0
#define log_fatal g10_log_fatal
#define log_error g10_log_error
#define log_info g10_log_info
#define log_warning g10_log_warning
#define log_debug g10_log_debug
/*-- errors.c --*/
const char * g10_errstr( int no );
/*-- argparse.c --*/
int arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
int optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts);
void usage( int level );
const char *default_strusage( int level );
/*-- (main program) --*/
const char *strusage( int level );
/*-- dotlock.c --*/
struct dotlock_handle;
typedef struct dotlock_handle *DOTLOCK;
void disable_dotlock(void);
DOTLOCK create_dotlock( const char *file_to_lock );
void destroy_dotlock ( DOTLOCK h );
int make_dotlock( DOTLOCK h, long timeout );
int release_dotlock( DOTLOCK h );
void remove_lockfiles (void);
/*-- fileutil.c --*/
char * make_basename(const char *filepath, const char *inputpath);
char * make_dirname(const char *filepath);
char *make_filename( const char *first_part, ... );
int compare_filenames( const char *a, const char *b );
const char *print_fname_stdin( const char *s );
const char *print_fname_stdout( const char *s );
int is_file_compressed(const char *s, int *r_status);
/*-- miscutil.c --*/
u32 make_timestamp(void);
u32 scan_isodatestr( const char *string );
const char *strtimevalue( u32 stamp );
const char *strtimestamp( u32 stamp ); /* GMT */
const char *isotimestamp( u32 stamp ); /* GMT with hh:mm:ss */
const char *asctimestamp( u32 stamp ); /* localized */
void print_string( FILE *fp, const byte *p, size_t n, int delim );
void print_string2( FILE *fp, const byte *p, size_t n, int delim, int delim2 );
void print_utf8_string( FILE *fp, const byte *p, size_t n );
void print_utf8_string2( FILE *fp, const byte *p, size_t n, int delim);
char *make_printable_string( const byte *p, size_t n, int delim );
int answer_is_yes_no_default( const char *s, int def_answer );
int answer_is_yes( const char *s );
int answer_is_yes_no_quit( const char *s );
int answer_is_okay_cancel (const char *s, int def_answer);
int match_multistr(const char *multistr,const char *match);
int hextobyte( const char *s );
/*-- strgutil.c --*/
void free_strlist( STRLIST sl );
#define FREE_STRLIST(a) do { free_strlist((a)); (a) = NULL ; } while(0)
STRLIST add_to_strlist( STRLIST *list, const char *string );
STRLIST add_to_strlist2( STRLIST *list, const char *string, int is_utf8 );
STRLIST append_to_strlist( STRLIST *list, const char *string );
STRLIST append_to_strlist2( STRLIST *list, const char *string, int is_utf8 );
STRLIST strlist_prev( STRLIST head, STRLIST node );
STRLIST strlist_last( STRLIST node );
char *pop_strlist( STRLIST *list );
const char *memistr( const char *buf, size_t buflen, const char *sub );
const char *ascii_memistr( const char *buf, size_t buflen, const char *sub );
char *mem2str( char *, const void *, size_t);
char *trim_spaces( char *string );
unsigned int trim_trailing_chars( byte *line, unsigned int len,
const char *trimchars);
unsigned int trim_trailing_ws( byte *line, unsigned len );
unsigned int check_trailing_chars( const byte *line, unsigned int len,
const char *trimchars );
unsigned int check_trailing_ws( const byte *line, unsigned int len );
int string_count_chr( const char *string, int c );
int set_native_charset( const char *newset );
const char* get_native_charset(void);
char *native_to_utf8( const char *string );
char *utf8_to_native( const char *string, size_t length, int delim);
int check_utf8_string( const char *string );
int ascii_isupper (int c);
int ascii_islower (int c);
int ascii_toupper (int c);
int ascii_tolower (int c);
int ascii_strcasecmp( const char *a, const char *b );
int ascii_strncasecmp( const char *a, const char *b, size_t n);
int ascii_memcasecmp( const char *a, const char *b, size_t n);
#ifndef HAVE_STPCPY
char *stpcpy(char *a,const char *b);
#endif
#ifndef HAVE_STRLWR
char *strlwr(char *a);
#endif
#ifndef HAVE_STRSEP
char *strsep (char **stringp, const char *delim);
#endif
#ifndef HAVE_STRCASECMP
int strcasecmp( const char *, const char *b);
#endif
#ifndef HAVE_STRNCASECMP
int strncasecmp (const char *, const char *b, size_t n);
#endif
#ifndef HAVE_STRTOUL
#define strtoul(a,b,c) ((unsigned long)strtol((a),(b),(c)))
#endif
#ifndef HAVE_MEMMOVE
#define memmove(d, s, n) bcopy((s), (d), (n))
#endif
/*-- membuf.c --*/
/* The definition of the structure is private, we only need it here,
so it can be allocated on the stack. */
struct private_membuf_s {
size_t len;
size_t size;
char *buf;
int out_of_core;
};
typedef struct private_membuf_s membuf_t;
void init_membuf (membuf_t *mb, int initiallen);
void put_membuf (membuf_t *mb, const void *buf, size_t len);
void *get_membuf (membuf_t *mb, size_t *len);
#if defined (_WIN32)
/*-- w32reg.c --*/
char *read_w32_registry_string( const char *root,
const char *dir, const char *name );
int write_w32_registry_string(const char *root, const char *dir,
const char *name, const char *value);
/*-- strgutil.c --*/
int vasprintf (char **result, const char *format, va_list args);
int asprintf (char **buf, const char *fmt, ...);
#endif /*_WIN32*/
/*-- pka.c --*/
char *get_pka_info (const char *address, unsigned char *fpr);
/*-- cert.c --*/
-int get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url);
+int get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url);
/**** other missing stuff ****/
#ifndef HAVE_ATEXIT /* For SunOS */
#define atexit(a) (on_exit((a),0))
#endif
#ifndef HAVE_RAISE
#define raise(a) kill(getpid(), (a))
#endif
/*-- Replacement functions from funcname.c --*/
/******** some macros ************/
#ifndef STR
#define STR(v) #v
#endif
#define STR2(v) STR(v)
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
#define DIMof(type,member) DIM(((type *)0)->member)
#define wipememory2(_ptr,_set,_len) do { volatile char *_vptr=(volatile char *)(_ptr); size_t _vlen=(_len); while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } } while(0)
#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
/*-- macros to replace ctype ones and avoid locale problems --*/
#define spacep(p) (*(p) == ' ' || *(p) == '\t')
#define digitp(p) (*(p) >= '0' && *(p) <= '9')
#define hexdigitp(a) (digitp (a) \
|| (*(a) >= 'A' && *(a) <= 'F') \
|| (*(a) >= 'a' && *(a) <= 'f'))
/* the atoi macros assume that the buffer has only valid digits */
#define atoi_1(p) (*(p) - '0' )
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))
#define atoi_4(p) ((atoi_2(p) * 100) + atoi_2((p)+2))
#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \
*(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10))
#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1))
/* Note this isn't identical to a C locale isspace() without \f and
\v, but works for the purposes used here. */
#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
/******* RISC OS stuff ***********/
#ifdef __riscos__
int riscos_load_module(const char *name, const char * const path[], int fatal);
int riscos_get_filetype_from_string(const char *string, int len);
int riscos_get_filetype(const char *filename);
void riscos_set_filetype_by_number(const char *filename, int type);
void riscos_set_filetype_by_mimetype(const char *filename, const char *mimetype);
pid_t riscos_getpid(void);
int riscos_kill(pid_t pid, int sig);
int riscos_access(const char *path, int amode);
int riscos_getchar(void);
char *riscos_make_basename(const char *filepath, const char *inputpath);
int riscos_check_regexp(const char *exp, const char *string, int debug);
int riscos_fdopenfile(const char *filename, const int allow_write);
void riscos_close_fds(void);
int riscos_renamefile(const char *old, const char *new);
char *riscos_gstrans(const char *old);
void riscos_not_implemented(const char *feature);
#ifdef DEBUG
void riscos_dump_fdlist(void);
void riscos_list_openfiles(void);
#endif
#ifndef __RISCOS__C__
#define getpid riscos_getpid
#define kill(a,b) riscos_kill((a),(b))
#define access(a,b) riscos_access((a),(b))
#endif /* !__RISCOS__C__ */
#endif /* __riscos__ */
#endif /*G10_UTIL_H*/
diff --git a/util/ChangeLog b/util/ChangeLog
index e00f146fb..b528ef0af 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,1655 +1,1659 @@
+2006-03-16 David Shaw <dshaw@jabberwocky.com>
+
+ * cert.c (get_cert): Handle the fixed IPGP type with fingerprint.
+
2006-03-08 David Shaw <dshaw@jabberwocky.com>
* argparse.c (default_strusage): Update copyright year to 2006.
2006-02-19 David Shaw <dshaw@jabberwocky.com>
* http.c (send_request): A zero length proxy is the same as no
proxy.
2006-02-14 Werner Koch <wk@gnupg.org>
* errors.c (g10_errstr): Add NO_DATA.
2006-01-26 David Shaw <dshaw@jabberwocky.com>
* cert.c (get_cert): Disable IPGP types for now until the format
questions in the draft are settled.
* srv.c (getsrv): Error on oversize SRV responses.
2005-12-24 David Shaw <dshaw@jabberwocky.com>
* cert.c (get_cert): Properly chase down CNAMEs pointing to CERTs.
2005-12-23 David Shaw <dshaw@jabberwocky.com>
* cert.c, Makefile.am: New code to do DNS CERT queries.
2005-12-22 David Shaw <dshaw@jabberwocky.com>
* srv.c, Makefile.am: Only build srv.c if we need to.
2005-12-10 Ryan Lortie <desrt@desrt.ca> (dshaw)
* ttyio.c (tty_enable_completion, tty_disable_completion): Add
checks for no_terminal so we don't try to open("/dev/tty") when
invoked with --no-tty.
2005-12-06 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: Some cleanup so we don't build files that are
completely ifdeffed out. This causes a warning on Sun's cc. Do
the internal regex code as well for consistency.
* mkdtemp.c (mkdtemp): Fix warning.
* secmem.c, assuan-buffer.c, dotlock.c: Fix a few warnings from
printf-ing %p where the arg wasn't void *.
2005-11-02 David Shaw <dshaw@jabberwocky.com>
* util.c [!HAVE_DECL_GETPAGESIZE]: Prototype getpagesize() if
unistd.h doesn't have it (for MinGW).
2005-09-22 Werner Koch <wk@g10code.com>
* iobuf.c (iobuf_get_filelength): New arg OVERFLOW.
(iobuf_get_filelength) [W32]: Use GetFileSizeEx if available.
* fileutil.c (is_file_compressed): Take care of the OVERFLOW
2005-08-31 David Shaw <dshaw@jabberwocky.com>
* fileutil.c (untilde): New. Expand ~/foo and ~username/foo
filenames into full paths using $HOME if possible, or
getpwuid/getpwnam if necessary.
(make_filename): Use it here.
2005-07-28 Werner Koch <wk@g10code.com>
* pka.c: New.
(parse_txt_record): Changed from v=1 to v=pka1.
* Makefile.am (pka-test): new.
2005-07-27 Werner Koch <wk@g10code.com>
* memory.c (FNAMEX, FNAMEXM): New macros to cope with the now used
names xmalloc style names.
2005-07-18 Werner Koch <wk@g10code.com>
* ttyio.c (do_get): Move printing of the prompt after disabling
echo. Suggested by Scott Worley.
2005-06-23 David Shaw <dshaw@jabberwocky.com>
* http.c (make_radix64_string): Add '=' padding as per standard.
(send_request, http_open, http_open_document): Clean up auth code.
Can now support different auth for a proxy and the file being
requested via that proxy. Unescape auth strings.
2005-06-22 David Shaw <dshaw@jabberwocky.com>
* memrchr.c (memrchr): Not all compilers allow initializing based
on a variable that is also being initialized. Noted by Nelson
H. F. Beebe.
2005-06-21 David Shaw <dshaw@jabberwocky.com>
* http.c (send_request, http_open, http_open_document): Pass in
auth and proxyauth that can override the in-url auth.
* http.c (send_request): Need == after the radix64-encoded basic
auth string.
2005-06-08 David Shaw <dshaw@jabberwocky.com>
* dotlock.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on
mingw32. Noted by Joe Vender.
2005-05-31 Werner Koch <wk@g10code.com>
* regcomp.c (MB_CUR_MAX) [_WIN32]: Define it only if not defined.
2005-05-29 David Shaw <dshaw@jabberwocky.com>
* strgutil.c (set_native_charset) [_WIN32]: Add alias for codepage
CP65001 to utf-8.
2005-05-19 Werner Koch <wk@g10code.com>
* membuf.c: New. Taken from gnupg 1.9.
2005-05-05 David Shaw <dshaw@jabberwocky.com>
* miscutil.c (add_days_to_timestamp): Remove as unused.
2005-04-12 David Shaw <dshaw@jabberwocky.com>
* assuan-client.c: Fix warning on OSX.
* memrchr.c: New replacement function.
* assuan-buffer.c: Use it here.
2005-04-04 Werner Koch <wk@g10code.com>
* memory.c (xcalloc, xcalloc_secure): New wrappers.
* assuan-client.c (assuan_transact): Factored all code out to ..
(assuan_transact2): .. new. Add arg OKAY_CB. Wipe the memory
processed though that callback.
2005-03-31 Werner Koch <wk@g10code.com>
* isascii.c: New. This is an autoconf replacement function.
* Makefile.am (assuan_source): New. Only used when agent support
has been requested.
* assuan-buffer.c, assuan-client.c, assuan-defs.h,
* assuan-errors.c, assuan-logging.c, assuan-socket-connect.c,
* assuan-socket.c, assuan-util.c, assuan-connect.c: New. Taken
from libassuan 0.6.9 and adjusted for our limited use of Assuan.
2005-03-18 David Shaw <dshaw@jabberwocky.com>
* ttyio.c (tty_enable_completion, tty_disable_completion): Enable
and disable readline completion.
(init_ttyfp): Completion is disabled by default.
2005-03-14 Werner Koch <wk@g10code.com>
* miscutil.c (isotimestamp): New.
2005-03-10 Werner Koch <wk@g10code.com>
* secmem.c (secmem_realloc): Take control information into account
when checking whether a resize is needed.
2005-03-08 Werner Koch <wk@g10code.com>
* miscutil.c (asctimestamp) [W32]: Don't use %Z.
2005-02-03 Werner Koch <wk@g10code.com>
* w32reg.c (read_w32_registry_string): Fallback to HKLM also for a
missing name.
* http.c (connect_server): Define ERR outside of the !W32 block.
2005-02-01 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Fix fd leak when connecting to a
round-robin server set that has some down servers. Noted by Phil
Pennock.
2005-01-20 Werner Koch <wk@g10code.com>
* simple-gettext.c (set_gettext_file): Use MO files depending on
the installation directory. Add new arg REGKEY.
2005-01-18 Werner Koch <wk@g10code.com>
* argparse.c (default_strusage): Changed default copyright year to
2005.
* strgutil.c (handle_iconv_error): Print error messages only once.
(native_to_utf8, utf8_to_native): Ditto.
2005-01-11 Werner Koch <wk@g10code.com>
* strgutil.c (set_native_charset) [W32]: Use the alias table from
libiconv 1.9.2.
2005-01-13 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Use INADDR_NONE instead of
SOCKET_ERROR. Noted by Timo.
2005-01-06 Werner Koch <wk@g10code.com>
* strgutil.c (set_native_charset): Assume that ASCII,
ANSI_X3.4-1968 and 646 are actually meant as Latin-1. If
nl_langinfo is not available get the charset from environment
variables. For W32 use GetACP as error fallback. Removed Latin-15
to Latin-1 aliasing.
2004-12-28 David Shaw <dshaw@jabberwocky.com>
* srv.h: Better implementation for the SRV check. We don't need
to actually check all the header files individually since the SRV
test compile uses them together.
2004-12-20 Werner Koch <wk@g10code.com>
* strgutil.c (handle_iconv_error): Turn diagnostics into warnings
so that gpg does not return with failure.
(native_to_utf8, utf8_to_native): Ditto.
2004-12-16 Werner Koch <wk@g10code.com>
* iobuf.c (fd_cache_strcmp) [W32]: Casting is a Bad Thing. Cast to
an unsigned char pointer and to an unsigned integer.
2004-12-18 David Shaw <dshaw@jabberwocky.com>
* ttyio.c: Use only HAVE_LIBREADLINE to detect readline
availability.
2004-12-16 David Shaw <dshaw@jabberwocky.com>
* srv.h: Don't include arpa/nameser.h unless we have it. Include
"types.h" for u16.
* secmem.c (secmem_init): Return a flag to indicate whether we got
the lock.
2004-12-06 Werner Koch <wk@g10code.com>
* iobuf.c (fd_cache_strcmp): New. Use whenever we compare
filenames for the fd_cache. This is needed because the backslash
is an alias for a slash under W32. Reported by Tobias Winkler.
2004-12-03 David Shaw <dshaw@jabberwocky.com>
* http.c (send_request): Include the port if non-80 in the Host:
header. Noted by Jason Harris.
2004-11-03 Timo Schulz <twoaday@g10code.com>
* strgutil.c (w32_strerror): New.
* ttyio.c (init_ttyfp, tty_printf, do_get): Use it here.
* iobuf.c (fd_cache_open, file_filter): Likewise.
(iobuf_seek, translate_file_handle): Likewise.
2004-11-02 Werner Koch <wk@g10code.com>
* strgutil.c (load_libiconv): Use log_info to avoid failures when
iconv.dll is not installed.
2004-10-31 Werner Koch <wk@g10code.com>
* simple-gettext.c (get_string): Removed debugging hack.
2004-10-27 Werner Koch <wk@g10code.com>
* simple-gettext.c: Removed windows.h.
(get_string): On the fly translation from utf-8 to active
character set.
* strgutil.c (load_libiconv) [_WIN32]: new.
(set_native_charset) [_WIN32]: Call it here and autodetect the
used code page.
(native_to_utf8, utf8_to_native): Reverted arguments for
iconv_open.
(handle_iconv_error): Made this function match iconv_open argumnet
ordering.
(utf8_to_native): Disable all quoting for DELIM == -1.
2004-10-26 Werner Koch <wk@g10code.com>
* strgutil.c (mem2str): Translated comment to English.
(handle_iconv_error) [USE_GNUPG_ICONV]: New.
(set_native_charset) [USE_GNUPG_ICONV]: Added iconv based
conversion checks.
(native_to_utf8, utf8_to_native): Added iconv based conversion.
2004-10-21 Werner Koch <wk@g10code.com>
* vasprintf.c: Removed. It was used only at one place and I don't
want to get into build problems in 1.4.
2004-10-18 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server, send_request): Use the URI scheme as the
SRV tag rather than hard-coding _hkp.
2004-10-16 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): [_WIN32] actually fill in the sin_addr
so we aren't always talking to localhost. Add some general sanity
checking of parameters learned from gethostbyname().
2004-10-15 Werner Koch <wk@g10code.com>
* vasprintf.c: New. Taken from gnupg 1.9.
2004-10-14 Werner Koch <wk@g10code.com>
* iobuf.c (iobuf_get_fd): Removed double check on directfp and
cats it to FILEP becuase directfp is actually a void *. Notes by
Stefan.
2004-10-13 Werner Koch <wk@g10code.com>
* logger.c (g10_log_error_f, g10_log_fatal_f, g10_log_info_f)
(g10_log_debug_f, print_prefix_f): Removed.
* iobuf.c (iobuf_is_pipe_filename): New.
(iobuf_get_fd): New.
* fileutil.c (is_file_compressed): Use it here.
2004-09-30 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (pop_filter): Make static.
* dotlock.c (destroy_dotlock): New. Remove the handle from the
list of locks.
(release_dotlock): Don't act if we don't have any locks at all.
From Werner on stable branch.
2004-09-10 David Shaw <dshaw@jabberwocky.com>
* http.c (make_radix64_string, do_parse_uri, send_request): Add
basic auth for proxies and direct requests. Suggested by Florent
Thoumie.
* http.c (main): Fix test code for http-test.
2004-09-09 Werner Koch <wk@g10code.com>
* errors.c (g10_errstr): New error codes G10ERR_NO_CARD,
G10ERR_CANCELED.
* ttyio.c (tty_get): Add readline support.
* iobuf.c (iobuf_skip_rest): New. Orginal patch by Florian
Weimer. Added new argument PARTIAL.
2004-08-19 David Shaw <dshaw@jabberwocky.com>
* http.c (insert_escapes): Fix encoding problem for non-URI-safe
characters. Noted by Vladimir Novak.
2004-05-21 David Shaw <dshaw@jabberwocky.com>
* timegm.c: New replacement function. Removes the need for
setenv.c and unsetenv.c.
* setenv.c: Removed.
* unsetenv.c: Removed.
2004-03-04 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (block_filter): Remove the old gpg indeterminate length
mode.
(iobuf_set_block_mode, iobuf_in_block_mode): Removed as
superfluous.
2004-03-01 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (block_filter): Properly handle a partial body stream
that ends with a 5-byte length that happens to be zero.
2004-02-28 David Shaw <dshaw@jabberwocky.com>
* unsetenv.c: Fixed debugging typo.
2004-02-24 Werner Koch <wk@gnupg.org>
* secmem.c (lock_pool) [_AIX]: Also set errno.
2004-02-21 David Shaw <dshaw@jabberwocky.com>
* miscutil.c (hextobyte): Moved here from g10/misc.c so I can use
it in the keyserver helpers.
2004-02-20 David Shaw <dshaw@jabberwocky.com>
* mkdtemp.c: New (moved from g10/), setenv.c: New, unsetenv.c:
New.
* Makefile.am: Include @LIBOBJS@ for replacement functions.
2004-01-15 David Shaw <dshaw@jabberwocky.com>
* argparse.c (default_strusage): Update copyright date.
(initialize): Avoid a number of -Wformat-nonliteral warnings.
These aren't actual problems, but the warnings bothered me.
* miscutil.c (print_string2): New variation on print_string that
allows two delimiters.
(print_string): Call print_string2 to do work.
2003-12-29 David Shaw <dshaw@jabberwocky.com>
* g10u.c: Dead code. Remove.
* Makefile.am: Don't compile g10u.c.
* iobuf.c (block_filter): Properly handle a partial body stream
that ends with a 5-byte length.
2003-12-28 David Shaw <dshaw@jabberwocky.com>
* http.c (send_request, http_open_document, http_open): Pass the
http proxy from outside rather than pulling it from the
evironment.
2003-12-28 Stefan Bellon <sbellon@sbellon.de>
* riscos.c [__riscos__]: Better filetype handling (use a
different SWI) and removal of unnecessary function.
* memory.c (out_of_core) [__riscos__]: Produce stack backtrace on
RISC OS if out_of_core() is called and M_GUARD is compiled in.
2003-12-06 David Shaw <dshaw@jabberwocky.com>
* http.c (send_request): Add a Host: header for virtual hosts.
2003-12-04 David Shaw <dshaw@jabberwocky.com>
* miscutil.c (answer_is_yes_no_default, answer_is_yes_no_quit):
Don't use alternate strings when not needed so we don't have to
re-translate them. Hopefully the comment will be enough to
indicate multiple match strings.
2003-11-20 David Shaw <dshaw@jabberwocky.com>
* miscutil.c (match_multistr): New. Match against each segment in
a string with tokens separated by |.
(answer_is_yes_no_default, answer_is_yes_no_quit,
answer_is_okay_cancel): Use it here to enable alternate
translations.
2003-11-01 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Differentiate between generic "can't
connect" errors and the more specific "host not found". Suggested
by Samuel Tardieu.
2003-10-29 Werner Koch <wk@gnupg.org>
* miscutil.c (answer_is_okay_cancel): New.
2003-10-25 Werner Koch <wk@gnupg.org>
* Makefile.am: Replaced INTLLIBS by LIBINTL.
2003-10-23 Werner Koch <wk@gnupg.org>
* secmem.c (lock_pool) [_AIX]: Don't use plock.
2003-10-12 David Shaw <dshaw@jabberwocky.com>
* srv.c: OSX 10.2.8/Darwin 6.8 seems to have some #include
ordering issues? Move sys/types.h up higher to work around.
2003-10-08 Werner Koch <wk@gnupg.org>
* ttyio.c (tty_print_string, tty_print_utf8_string2)
(tty_print_utf8_string): Made string arg const.
2003-09-28 Timo Schulz <twoaday@freakmail.de>
* strgutil.c [WIN32] (asprintf): New.
2003-09-28 Werner Koch <wk@gnupg.org>
* ttyio.c (tty_fprintf): New.
2003-09-21 Timo Schulz <twoaday@freakmail.de>
* http.c [WIN32]: Define MB_CUR_MAX.
(connect_server): use unsigned long since W32 does not have in_addr_t.
2003-08-28 David Shaw <dshaw@jabberwocky.com>
* dotlock.c, http.c, iobuf.c, simple-gettext.c, srv.c, srv.h,
strgutil.c, ttyio.c, w32reg.c: s/__MINGW32__/_WIN32/ to help
building on native Windows compilers. Requested by Brian Gladman.
From Werner on stable branch.
* http.c (connect_server): Oops - forgot to freeaddrinfo().
2003-08-24 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Try and use getaddrinfo if it is
available. Try for IPv6 via getaddrinfo() or a IPv6-ized
gethostbyname(). Suggested by Jun-ichiro itojun Hagino.
2003-07-10 David Shaw <dshaw@jabberwocky.com> (from Werner on stable branch)
* iobuf.c (check_special_filename): Replaced is isdigit by digitp
to avoid passing negative values and potential locale problems.
Problem noted by Christian Biere.
* strgutil.c (strlwr,strcasecmp,strncasecmp): Make sure we don't
pass a negative value.
* miscutil.c (scan_isodatestr): Ditto.
2003-05-30 David Shaw <dshaw@jabberwocky.com>
* srv.h, srv.c: Include windows.h with MINGW32.
2003-05-24 David Shaw <dshaw@jabberwocky.com>
* argparse.c, dotlock.c, fileutil.c, iobuf.c, miscutil.c,
simple-gettext.c, errors.c, http.c, memory.c, secmem.c, ttyio.c:
Edit all preprocessor instructions to remove whitespace before the
'#'. This is not required by C89, but there are some compilers
out there that don't like it.
2003-05-21 Werner Koch <wk@gnupg.org>
* fileutil.c (is_file_compressed): Fixed checking for "-" filename.
2003-04-13 David Shaw <dshaw@jabberwocky.com>
* srv.c (main): Test against wwwkeys.pgp.net.
* srv.h: Grr. The RH7.3 Linux man page defines the fourth arg of
dn_expand as unsigned char*, but it is really char* according to
resolv.h.
2003-03-23 David Shaw <dshaw@jabberwocky.com>
* argparse.c (default_strusage): Change copyright date.
2003-03-14 David Shaw <dshaw@jabberwocky.com>
* srv.h, srv.c (getsrv): Use unsigned char rather than char.
Noted by Stefan Bellon.
2003-03-11 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Use DNS SRV to get a server list. Fail
over to A records if necessary.
* Makefile.am, srv.h, srv.c: New DNS SRV handling code.
2003-02-22 David Shaw <dshaw@jabberwocky.com>
* ttyio.c (tty_print_utf8_string, tty_print_utf8_string2): Use 0
to indicate a string with no maximum size. This prevents early
truncation of strings that contain control chars which are
expanded into \xXX form.
2002-12-26 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (iobuf_flush): Only print debug info if debugging is on.
2002-11-13 David Shaw <dshaw@jabberwocky.com>
* secmem.c (lock_pool) [__CYGWIN__]: Don't print secmem warning.
From Werner on stable branch.
2002-11-09 Werner Koch <wk@gnupg.org>
* ttyio.c (TERMDEVICE): Removed.
(tty_get_ttyname): New.
(init_ttyfp): Use it here instead of the TERMDEVICE macro.
2002-11-06 David Shaw <dshaw@jabberwocky.com>
* w32reg.c (read_w32_registry_string): Fixed expanding of the
environment buffer; didn't worked at all. Reported by Thijmen
Klok. From Werner on stable branch.
* secmem.c (secmem_free, secmem_term): Use wipememory2() instead
of memset() to overwrite secure memory
* iobuf.c (direct_open): Handle mode 'b' if O_BINARY is available.
From Werner on stable branch.
* fileutil.c: Comment from stable branch.
2002-10-31 Stefan Bellon <sbellon@sbellon.de>
* riscos.c (riscos_load_module, riscos_check_regexp): New.
(riscos_set_filetype_by_mimetype, riscos_dump_fdlist)
(riscos_fdopenfile, riscos_close_fds, riscos_renamefile)
(riscos_gstrans, riscos_list_openfiles, riscos_not_implemented):
Renamed functions to contain riscos prefix.
* dotlock.c [__riscos__]: Renames due to changes in riscos.c.
* fileutil.c [__riscos__]: Likewise.
2002-10-29 Stefan Bellon <sbellon@sbellon.de>
* fileutil.c: Removed unnecessary left-over includes for RISC OS.
(make_filename): Tidied up RISC OS stuff.
(compare_filenames) [__riscos__]: Compare with ascii_strcasecmp().
(make_basename) [__riscos__]: Branch to own RISC OS routine from
here.
* riscos.c (riscos_make_basename): New.
2002-10-28 Stefan Bellon <sbellon@sbellon.de>
* fileutil.c (make_basename) [__riscos__]: Cut off RISC OS' filing
systems from filepath.
* riscos.c (riscos_get_filetype_from_string, riscos_get_filetype):
Added.
(riscos_set_filetype_by_number): Made public.
2002-10-19 David Shaw <dshaw@jabberwocky.com>
* Makefile.am, regcomp.c, regex.c, regex_internal.c,
regex_internal.h, regexec.c: Add new regex files from glibc 2.3.1.
2002-10-17 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Try all A records for names with
multiple addresses until one answers for both MINGW32 and not
MINGW32.
2002-10-10 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Properly handle a single A record that
fails connect().
2002-10-03 David Shaw <dshaw@jabberwocky.com>
* logger.c (g10_log_warning, log_set_strict): Add new log_warning
logger command which can be switched between log_info and
log_error via log_set_strict.
2002-09-24 David Shaw <dshaw@jabberwocky.com>
* http.c (connect_server): Try all A records for names with
multiple addresses until one answers (not MINGW32).
2002-09-16 Werner Koch <wk@gnupg.org>
* w32reg.c (read_w32_registry_string): Fallback to HLM.
2002-09-12 Stefan Bellon <sbellon@sbellon.de>
* fileutil.c (make_filename): Removed variable for RISC OS to
avoid compiler warning.
* secmem.c: Removed static variable for RISC OS to avoid
compiler warning.
2002-09-11 Werner Koch <wk@gnupg.org>
* simple-gettext.c: Disable charset mappings. We do it now when
installing the files.
2002-09-09 Werner Koch <wk@gnupg.org>
* w32reg.c (read_w32_registry_string): Handle REG_EXPAND_SZ.
Suggested by Ryan Malayter.
* strgutil.c (ascii_strcasecmp): Replaced by code from gnulib.
(ascii_strncasecmp): New.
2002-09-02 Werner Koch <wk@gnupg.org>
* simple-gettext.c (set_gettext_file): Make sure that we only use
backslashes.
* strgutil.c (set_native_charset): Allow NULL as argument to use
nl_langinfo for selection. Mapped latin-15 to latin-1.
2002-08-30 Werner Koch <wk@gnupg.org>
* iobuf.c (block_filter): Removed the assert, so that one can pass
the first character of a message and use the block filter for
non partial length encoded packets.
2002-08-06 Stefan Bellon <sbellon@sbellon.de>
* ttyio.c [__riscos__]: Moved low-level RISC OS stuff to riscos.c.
* riscos.c: Use new SWI calling mechanism of UnixLib.
2002-08-03 Stefan Bellon <sbellon@sbellon.de>
* secmem.c (init_pool, secmem_term): Changed #if to #ifdef in
order to avoid warning with RISC OS' Norcroft C.
2002-07-25 David Shaw <dshaw@jabberwocky.com>
* secmem.c: "Warning" -> "WARNING"
2002-07-05 Werner Koch <wk@gnupg.org>
* argparse.c (initialize): We better exit after a read error so
that we don't run into an endless loop when reading a directory.
Noted by Andrew Suffield.
2002-07-01 David Shaw <dshaw@jabberwocky.com>
* argparse.c (optfile_parse): Fix variable typo - 'p2' should be
'p' :)
2002-06-29 Werner Koch <wk@gnupg.org>
* argparse.c (optfile_parse): Renamed an auto I to P2 to avoid
shadowing warning.
2002-06-21 Stefan Bellon <sbellon@sbellon.de>
* riscos.c (riscos_global_defaults): New.
2002-06-20 Stefan Bellon <sbellon@sbellon.de>
* riscos.c (riscos_set_filetype_by_number, riscos_set_filetype):
New. Set RISC OS filetype according to MIME type.
2002-06-14 David Shaw <dshaw@jabberwocky.com>
* strgutil.c (pop_strlist): New function to pop the head off of a
strlist.
2002-06-05 Timo Schulz <ts@winpt.org>
* fileutil.c (is_file_compressed): Corrected the magic values
for bzip2 and gzip. Noted by David.
2002-05-22 Werner Koch <wk@gnupg.org>
* fileutil.c (compare_filenames): Replaced stricmp by strcasecmp.
* miscutil.c (answer_is_yes_no_quit,answer_is_yes_no_default): Ditto.
* strgutil.c (strncasecmp): New.
(memicmp): Removed.
2002-05-10 Stefan Bellon <sbellon@sbellon.de>
* memory.c (add_entry) [M_DEBUG]: Added some missing EXTRA_ALIGN.
(free_entry) [M_DEBUG]: Free secure memory via secmem_free.
(alloc_secure): Malloc at least 1 byte.
(realloc) [M_GUARD]: Added missing FNAMEARG to function call.
* logger.c (g10_log_bug0) [__riscos__]: Make use of first
g10_log_bug0 function for later Norcroft compiler.
* riscos.c: Added stdlib.h include.
2002-05-04 Werner Koch <wk@gnupg.org>
* http.c (write_server) [__MINGW32__]: Replaced WriteFile by send
because sockets don't work with WriteFile under NT anymore.
2002-05-03 David Shaw <dshaw@jabberwocky.com>
* argparse.c (optfile_parse): Remove quotes only if they totally
enclose the string, and do not occur within the string. This
makes specifying a program under Win32 easier when you need quotes
around part of a string, but not around the whole string.
2002-05-02 Werner Koch <wk@gnupg.org>
* memory.c (alloc): Malloc at least 1 byte. Noted by Winona Brown.
2002-04-23 David Shaw <dshaw@jabberwocky.com>
* miscutil.c: New function answer_is_yes_no_default() to give a
default answer.
2002-04-22 Stefan Bellon <sbellon@sbellon.de>
* riscos.c (riscos_open, riscos_fopen, riscos_fstat, set_filetype):
Removed as they're not needed anymore.
* iobuf.c (direct_open) [__riscos__]: Don't allow opening of
directories.
2002-04-08 Werner Koch <wk@gnupg.org>
Fixed filename of last entry.
2002-03-29 David Shaw <dshaw@jabberwocky.com>
* miscutil.c (print_string, utf8_to_native): If a delimiter is
used, then quote the backslash character as well. Problem noted
by Rainer Perske.
2002-03-15 Werner Koch <wk@gnupg.org>
* argparse.c (optfile_parse): Fixed missing argument handling.
2002-02-28 Timo Schulz <ts@winpt.org>
* http.c (write_server): Convert integer to a HANDLE for W32.
2002-01-27 David Shaw <dshaw@jabberwocky.com>
* iobuf.c (iobuf_fdopen, iobuf_sockopen): Do not cache fdopened
fds on close.
2002-01-08 Werner Koch <wk@gnupg.org>
* secmem.c (print_warn): Print a pointer to the FAQ.
2002-01-05 Werner Koch <wk@gnupg.org>
* argparse.c (default_strusage): Set default copyright date to 2002.
2002-01-02 Stefan Bellon <sbellon@sbellon.de>
* iobuf.c [__riscos__]: Updated include file name.
* fileutil.c [__riscos__]: Ditto.
* ttyio.d [__riscos__]: Ditto.
* riscos.c [__riscos__]: Ditto. Added debugging code and
unified error messages.
2001-12-27 David Shaw <dshaw@jabberwocky.com>
* errors.c (g10_errstr): Added G10ERR_KEYSERVER
2001-12-27 Werner Koch <wk@gnupg.org>
* simple-gettext.c [MINGW32]: Fixed last changed.
2001-12-22 Stefan Bellon <sbellon@sbellon.de>
* memory.c (realloc): Fixed realloc not working when M_GUARD is
defined and first parameter is NULL.
2001-12-22 Timo Schulz <ts@winpt.org>
* fileutil.c (is_file_compressed): New.
2001-12-19 Werner Koch <wk@gnupg.org>
* simple-gettext.c, w32reg.c [CYGWIN32]: Allow to use this file
2001-10-11 Werner Koch <wk@gnupg.org>
* http.c (do_parse_uri): Changed initialization of the port number
so that it does also work with x-hkp. By David Shaw.
2001-09-19 Werner Koch <wk@gnupg.org>
* w32reg.c (get_root_key): New.
(read_w32_registry_string): Use it here.
(write_w32_registry_string): New. Contributed by Timo.
* iobuf.c (iobuf_ioctl): New command to disable fd
caching. Implemented no_cache flag where needed.
(iobuf_sockopen): Always set no_cache flag.
* strgutil.c (utf8_to_native): Add a delim arg and changed all
callers. Make sure that quoting is done when translation is
disabled.
* miscutil.c (print_utf8_string2): New.
2001-09-17 Werner Koch <wk@gnupg.org>
* miscutil.c (print_string): Use explicit ranges and not iscntrl().
(make_printable_string): Ditto.
2001-09-07 Werner Koch <wk@gnupg.org>
* strgutil.c (strsep): New, taken from glibc 2.2.1.
2001-09-03 Werner Koch <wk@gnupg.org>
* miscutil.c (strtimestamp,asctimestamp): Avoid trigraphs.
2001-08-21 Stefan Bellon <sbellon@sbellon.de>
* riscos.c [__riscos__] (close_fds): Fixed possible endless loop.
2001-08-20 Werner Koch <wk@gnupg.org>
Applied patches from Stefan Bellon <sbellon@sbellon.de> to support
RISC OS. Nearly all of these patches are identified by the
__riscos__ macro.
* secmem.c [__riscos__]: Disabled secure memory stuff.
* dotlock.c, ttyio.c [__riscos__]: Adapted for RISC OS
* fileutil.c, iobuf.c: Adapted for RISC OS; mainly replaced
hardcoded path separators with EXTSEP_S like macros.
* http.c (send_request): Use macros for the env-var name.
* logger.c [__riscos__]: Do an fflush at the end of each log
function.
* memory.c [__riscos__]: Minor patches
* riscos.c (set_filetype): New.
* secmem.c (lock_pool): Under HPUX mlock is broken but we might
have plock, so we use this to lock the entire process. By Albert
Chin.
2001-07-03 Werner Koch <wk@gnupg.org>
* strgutil.c (utf8_to_native): Fixed printing of invalid utf-8
characters. Thomas Roessler reported that the escaping didn't work
correct.
2001-06-12 Werner Koch <wk@gnupg.org>
* strgutil.c (ascii_memistr,ascii_isupper,ascii_islower,
ascii_toupper,ascii_tolower, ascii_strcasecmp, ascii_memcasecmp): New.
(set_native_charset): Use ascii_strcasecmp()
* fileutil.c (compare_filenames): Ditto
* miscutil.c (answer_is_yes): Ditto.
(answer_is_yes_no_quit): Ditto.
2001-06-06 Werner Koch <wk@gnupg.org>
* strgutil.c (vasprintf) [__MINGW32__]: New. Taken from libiberty.
* ttyio.c (tty_printf) [__MINGW32__]: Replaced the sprintf with
the new vasprintf.
2001-06-05 Werner Koch <wk@gnupg.org>
* dotlock.c (make_dotlock): Typo fixes.
2001-05-25 Werner Koch <wk@gnupg.org>
* ttyio.c (do_get): Fixed a serious format string bug. Thanks to
fish stiqz.
2001-05-23 Werner Koch <wk@gnupg.org>
* secmem.c (EPERM): Try to work around a Slackware problem.
2001-05-05 Werner Koch <wk@gnupg.org>
* http.c (http_start_data): Flush before writing.
(http_wait_response): No need to flush here.
2001-04-27 Werner Koch <wk@gnupg.org>
* memory.c (out_of_core): Print an explanation on reasons why
secret memory can get exhausted.
2001-04-23 Werner Koch <wk@gnupg.org>
* http.c (http_wait_response): Implement new flag to inhibit the
TCP shutdown.
2001-04-20 Werner Koch <wk@gnupg.org>
* http.c (http_start_data): Use write_server and not the iobuf
stuff. I wonder why we are at all using write_server - shouldn't
it be handled by iobuf?
* strgutil.c (set_native_charset): Allow utf-8 by introducing the
new no_translation variable.
(native_to_utf8): Handle no_translation.
(utf8_to_native): Ditto.
2001-04-19 Werner Koch <wk@gnupg.org>
* miscutil.c (asctimestamp): Handle negative times. We must do
this because Windoze segvs on negative times passed to gmtime().
(strtimestamp): Ditto.
2001-04-14 Werner Koch <wk@gnupg.org>
* strgutil.c (utf8_to_native): Fixed a segv. Thanks to Keith Clayton.
2001-04-13 Werner Koch <wk@gnupg.org>
* iobuf.c (iobuf_fopen): Removed because it is not used and
furthermore mode is ignored for an fname of "-". Suggested by
Florian Weimer.
2001-04-02 Werner Koch <wk@gnupg.org>
* iobuf.c (translate_file_handle): New. Use this function
everywhere in this file.
(iobuf_translate_file_handle): Always use the osfhandle stuff here
because callers don't know the implementation details of iobuf and
they expect that the handles are translated.
2001-03-29 Werner Koch <wk@gnupg.org>
* miscutil.c (answer_is_yes): An empty string does now return no.
(answer_is_yes_no_quit): Likewise.
* iobuf.c (iobuf_close): Burn the buffers.
2001-03-26 Werner Koch <wk@gnupg.org>
* ttyio.c: Define TERMDEVICE depending on OS.
* http.c (http_start_data): send a CRLF and not just a LF.
Pointed out by Steven Murdoch.
2001-03-13 Werner Koch <wk@gnupg.org>
* iobuf.c (iobuf_sockopen): New.
(sock_filter) [__MINGW32__]: New.
(iobuf_ioctl): New.
(file_filter): Implemented keep_open mode.
* http.c (http_open, http_wait_response): Replaced iobuf_fdopen by
iobuf_sockopen and use an iobuf_ioctl to avoid the dup().
(deinit_sockets, init_sockets) [__MINGW32__]: New.
(connect_server, write_server): Add code to work with W32 sockets.
2001-03-12 Werner Koch <wk@gnupg.org>
* strgutil.c (check_trailing_chars,check_trailing_ws): New.
2001-03-08 Werner Koch <wk@gnupg.org>
* argparse.c (default_strusage): Changed year of printed copyright
to 2001.
* iobuf.c (fd_cache_invalidate, fd_cache_close, fd_cache_open): New.
(direct_open): Invalidate the fd_cache for read access.
(file_filter): Cache the close here.
(iobuf_open): Use new my_fopen_ro macro to try the cache first.
2001-03-07 Werner Koch <wk@gnupg.org>
* iobuf.c: Made the old stdio file handling cpp conditional
controlled by FILE_FILTER_USES_STDIO and added a new
open/read/close based one. We don't need the stdio buffering
becuase we are doing our own buffering anyway. And it is a
prerequesite to allow the use of ReadFile et al for W32 which in
turn is needed to make the http stuff work there. The new W32
stuff has also been implemented. Minor changes to all open functions.
(direct_open): New.
(file_filter): Core of the new read/write handling.
(iobuf_get_filelength): Use W32 API function here. But it is
currently limited to 2GB files.
(iobuf_seek): Ditto.
2001-03-01 Werner Koch <wk@gnupg.org>
* errors.c (g10_errstr): New codes UNU_SECKEY and UNU_PUBKEY.
2000-12-28 Werner Koch <wk@gnupg.org>
* dotlock.c: Made all_lockfiles volatile.
(remove_lockfiles): Made public.
2000-11-30 Werner Koch <wk@gnupg.org>
* iobuf.c (iobuf_translate_file_handle): New.
(iobuf_open, iobuf_create): Use it for special filenames
2000-11-11 Paul Eggert <eggert@twinsun.com>
* iobuf.c (iobuf_get_filelength): Now returns off_t, not u32.
Remove kludges to worry about large files; the callers check
for files that are too large, and they should already be doing
the right thing in an implementation-independent way.
(fopen, fstat): Remove macros.
* iobuf.c (iobuf_set_limit, iobuf_tell, iobuf_seek):
Use off_t, not ulong, for file offsets.
(<limits.h>): Include if needed.
(LONG_MAX, LONG_MIN): Define a substitute if needed.
(fseeko): Define a substitute if needed.
* iobuf.c (iobuf_seek): Do not use %lu to report file
2000-11-09 Werner Koch <wk@gnupg.org>
* iobuf.c (iobuf_enable_special_filenames): New.
(check_special_filename): New.
(iobuf_open): check for special filenames.
(iobuf_create): Ditto.
2000-10-23 Werner Koch <wk@gnupg.org>
* secmem.c (lock_pool): Don't print warning for Windows.
2000-10-16 Werner Koch <wk@gnupg.org>
* secmem.c (lock_pool): Fixed error checking for Linux.
By James Troup.
Thu Sep 14 14:20:38 CEST 2000 Werner Koch <wk@openit.de>
* miscutil.c (answer_is_yes_no_quit): Swapped order of yes/no test
so that no is returned for an empty input. By David Champion.
Wed Sep 6 17:55:47 CEST 2000 Werner Koch <wk@openit.de>
* iobuf.c: Use fopen64 insead of fopen when available.
(iobuf_get_filelength): Use fstat64 when available but return
2^32-1 if the file is larger than this value.
Wed Sep 6 14:59:09 CEST 2000 Werner Koch <wk@openit.de>
* secmem.c (secmem_realloc): check for failed secmem_malloc. By
Matt Kraai.
* strgutil.c (utf8_to_native): Fixed null ptr problem. By
Giampaolo Tomassoni.
Thu Jul 27 10:02:38 CEST 2000 Werner Koch <wk@openit.de>
* iobuf.c: Use setmode() at several places to set stdin and stdout
to binary mode for MSDOS based systems
* iobuf.c (underflow): Initialize dummy_len to keep memory checker happy.
Fri Jun 9 10:09:52 CEST 2000 Werner Koch <wk@openit.de>
* ttyio.c: Simulate termios with termios. By Dave Dykstra.
Thu Jun 8 20:22:00 CEST 2000 Werner Koch <wk@openit.de>
* secmem.c (lock_pool,secmem_init): Additional check for dropped privs.
Tue May 30 16:37:55 CEST 2000 Werner Koch <wk@openit.de>
* iobuf.c (iobuf_cancel): Fix for MSDOS.
Fri Apr 14 19:37:08 CEST 2000 Werner Koch <wk@openit.de>
* dotlock.c (disable_dotlock): New. Implmented this in the module.
2000-03-09 14:04:22 Werner Koch (wk@habibti.openit.de)
* argparse.c (default_strusage): Changed year of default copyright.
Tue Mar 7 18:45:31 CET 2000 Werner Koch <wk@gnupg.de>
* secmem.c (lock_pool): No more warning for QNX. By Sam Roberts.
2000-03-02 15:51:04 Werner Koch (wk@habibti.gnupg.de)
* ttyio.c (tty_print_utf8_string): Oops.
Thu Mar 2 15:37:46 CET 2000 Werner Koch <wk@gnupg.de>
* ttyio.c (tty_print_utf8_string2): New to allow a max output size.
Wed Feb 23 10:07:57 CET 2000 Werner Koch <wk@gnupg.de>
* miscutil.c (asctimestamp): Fix for possible buffer overflow by
large system returned date format string.
Fri Dec 31 14:08:15 CET 1999 Werner Koch <wk@gnupg.de>
* logger.c (log_inc_errorcount): New.
Sat Dec 4 12:30:28 CET 1999 Werner Koch <wk@gnupg.de>
* iobuf.c (iobuf_cancel): Broadcast the new Cancel mesaage to all
filters.
Mon Nov 22 11:14:53 CET 1999 Werner Koch <wk@gnupg.de>
* strgutil.c (strcasecmp): New.
* secmem.c (pool_is_mmapped): Made volatile.
Sat Oct 9 20:34:41 CEST 1999 Werner Koch <wk@gnupg.de>
* Makefile.am: Removed libtool.
Fri Oct 8 20:32:01 CEST 1999 Werner Koch <wk@gnupg.de>
* w32reg.c: New.
* simple-gettext.c: Use the Registry to locate the mo file.
* http.c (send_request): Add support for proxys; suggested by
Walter Hofmann.
(http_open_document): Pass flags to http_open.
Fri Sep 17 12:56:42 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c (lock_pool): Check for ENOSYS return my mlock() on
old SCOs.
* ttyio.c (do_get): Replaced #if __MINGW32__ by #ifdef becuase
gcc 2.95.1 assigns a floating point value (0.2) to this macro,
which in turn can't be used in an expression.
Wed Sep 15 16:22:17 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* simple-gettext.c: New.
Wed Sep 1 15:30:44 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* argparse.c (arg_parse): Add standard options to the dump-options
output.
Tue Aug 31 17:20:44 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil (utf8_to_native): Implemented.
(check_utf8_string): Removed.
* miscutil.c (make_printable_string): Fixed possible buffer overflow.
(print_utf8_string): New.
* ttyio.c (tty_print_utf8_string): New.
Mon Aug 30 20:38:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c (pool_okay): declared volatile.
* miscutil.c (answer_is_yes): Always check for plain "yes".
(answer_is_yes_no_quit): Likewise.
* dotlock.c (create_dotlock): Fixed segv during cleanup.
Mon Jul 12 14:55:34 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* argparse.c (initialize): Init ret_xxx.
(optfile_parse): Remove quotes from arguments.
Wed Jul 7 13:08:40 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* memory.c (membug): Use if either M_DEBUG or M_GUARD is used.
* miscutil.c (scan_isodatestr): New.
* logger.c (g10_log_mpidump): Moved to ../mpi/mpicoder.c
(g10_log_print_prefix): Renamed from print_prefix and made global.
* Makefile.am: Support for libtool.
Thu Jul 1 12:47:31 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* miscutil.c (make_printable_string): New.
* strgutil.c (add_to_strlist2,append_to_strlist2): New.
Tue Jun 29 21:44:25 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c (USE_CAPABILITIES): Capabilities support (Remi).
Sat Jun 26 12:15:59 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c (create_dotlock): s/uts/utsbuf/ cause there an Amdahl
system with the name UTS (Dave Dykstra).
* secmem.c (DEFAULT_POOLSIZE): Doubled the size.
Fri Jun 18 00:18:02 CEST 1999 Michael Roth <mroth@nessie.de>
* iobuf.c: file_filter() Detection of EOF on terminals
improved/fixed (see Bug #21).
Mon Jun 14 21:18:54 CEST 1999 Michael Roth <mroth@nessie.de>
* ttyio.c: tty_no_terminal() new.
Sat Jun 5 15:30:33 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil.c (set_native_charset): Support Latin-2
Tue Jun 1 16:01:46 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (iobuf_get_real_fname): Made global and now keep a
copy of the name in the iobuf struct.
Mon May 31 19:41:10 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (file_filter,block_filter): Speed patches (R駑i).
Thu May 27 09:40:55 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* miscutil.c (answer_is_yes_no_quit): New.
Sun May 23 14:20:22 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c: Tweaked to make it compile under mingw32
* http.c: Disabled for mingw32.
Sat May 22 22:47:26 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* logger.c (log_set_logfile): New.
Thu May 20 14:04:08 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* memory.c (membug): Nanu, there was a const instead of a static.
* strgutil.c (trim_trailing_chars): New.
Mon May 17 21:54:43 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* logger.c (g10_log_hexdump): Made 2nd arg a const.
Wed Apr 28 13:03:03 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* miscutil.c (asctimestamp): Use nl_langinfo (Ga? Qu駻i).
Sun Apr 18 10:11:28 CEST 1999 Werner Koch <wk@isil.d.shuttle.de>
* argparse.c (store_alias): Disabled becuase it is not used.
* ttyio.c (tty_batchmode): New
Sat Mar 20 11:44:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* http.c: Swapped to includes.
Tue Mar 2 16:44:57 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil.c (get_native_charset): New.
Fri Feb 26 17:55:41 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c (memblock_struct): Force align (R駑i Guyomarch)
Wed Feb 24 11:07:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (block_filter): Fixed the oscillating partial packet chunks.
Fri Feb 19 15:49:15 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (iobuf_push_filter2): New to allow transer of context
ownership to the iobuf. Released the context where needed.
Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil.c (add_to_strglist): Clear the new flags field
(append_to_strglist): Ditto.
* dotlock.c (read_lockfile): terminate pidstr (Michael).
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c (remove_lockfiles): Add cleanup function.
(make_dotlock): Add deadlock check.
* secmem.c (secmem_malloc): Changed error message.
Wed Jan 20 21:40:21 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* http.c (http_wait_response): Moved the shutdown behind the dup
Wed Jan 20 18:59:49 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* http.c (send_request): Removed double LF
Tue Jan 19 19:34:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* * iobuf.c (iobuf_push_filter): Allow filters for temp streams
(iobuf_write_temp): Ditto.
(iobuf_flush_temp): New.
(iobuf_unget_and_close_temp): Removed.
* http.c (close_http_document): Renamed to http_close().
(open_http_document): Renamed to http_open_document().
(http_open): New.
(http_start_data): New.
(http_wait_response): New.
Sun Jan 17 11:04:33 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* strgutil.c (trim_trailing_ws): New.
Sat Jan 16 12:03:27 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* http.c (connect_server): Fixed stupid bug.
Sat Jan 16 09:27:30 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* http.c: New
Wed Jan 13 14:10:15 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (iobuf_fdopen): New.
Sat Jan 9 16:02:23 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c (lock_pool): add another check that setuid() worked.
(secmem_init): Ditto.
Thu Jan 7 18:00:58 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* iobuf.c (iobuf_clear_eof): Removed.
(underflow): Changed the eof handling.
(iobuf_pop_filter): Made static and renamed to pop_filter.
* iobuf.c (iobuf_read_line): New.
Sun Jan 3 15:28:44 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c (make_dotlock): print another informal message.
(make_dotlock): Removed the cpp checks.
Tue Dec 29 14:41:47 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* secmem.c: Moved unistd.h out of the #ifdef
* dotlock.c (make_dotlock): Sun has no SYS_NMLN
* iobuf.c (iobuf_unget_and_close_temp): Reset .start
Sat Dec 12 18:40:32 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* argparse.c (arg_pars): fixed opts[i] with negative index.
Fri Nov 27 21:37:41 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c: Implemented
Wed Nov 25 11:30:07 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (iobuf_pop_filter): Fixed sigsegv after error.
Thu Nov 19 07:09:55 1998 Werner Koch <werner.koch@guug.de>
* miscutil.c (strtimevalue): New.
Tue Nov 10 10:01:53 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (set_native_charset): New.
(native_to_utf8): Now handles koi8-r.
Tue Nov 3 16:17:56 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (native_to_utf8): New.
(utf8_to_native): New, but only as a stub.
* argparse.c (optfile_parse): Trimmed spaces from args.
Wed Oct 28 08:01:49 1998 me,,, (wk@tobold)
* argparse.c (find_long_option): New.
(arg_parse): option=value is now allowed. Add a new internal
option "--dump-options".
Thu Oct 22 16:25:49 1998 Michael Roth (mroth@nessie.de)
* fileutil.c (make_basename): New.
(make_dirname): New.
Wed Oct 21 12:20:29 1998 Werner Koch (wk@isil.d.shuttle.de)
* util.c (iobuf_flush): autoincreasing of a temp. iobuf
(iobuf_temp_with_content): New.
Tue Oct 13 12:40:13 1998 Werner Koch (wk@isil.d.shuttle.de)
* util.c (.nofast): set this variable
Wed Oct 7 19:27:50 1998 Werner Koch (wk@isil.d.shuttle.de)
* memory.c (m_print_stats): New.
Tue Oct 6 09:53:56 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (memicmp): Add HAVE_MEMICMP.
Mon Sep 21 19:45:01 1998 Werner Koch (wk@(none))
* secmem.c: New flags to allow suspend/resume of warnings.
Fri Sep 18 16:25:47 1998 Werner Koch (wk@(none))
* secmem.c (lock_pool): Kludge for broken mlock on HPUX 10.20
Tue Sep 15 17:52:21 1998 Werner Koch (wk@(none))
* miscutil.c (asctimestamp): New.
Mon Sep 14 09:38:18 1998 Werner Koch (wk@(none))
* secmem.c (init_pool): Now mmaps /dev/zero if we do not have MAP_ANON.
Wed Sep 9 13:52:28 1998 Werner Koch (wk@(none))
* ttyio.c (do_get): Ctrl-D is now a valid but special character
Mon Sep 7 13:52:41 1998 Werner Koch (wk@(none))
* iobuf.c (get_real_fname): New and changed file_filter datastructures
and their initialization.
Tue Aug 11 15:12:35 1998 Werner Koch (wk@(none))
* miscutil.c (answer_is_yes): i18ned
Sat Aug 8 18:35:00 1998 Werner Koch (wk@(none))
* ttyio.c (cleanup): New.
Mon Aug 3 17:06:00 1998 Werner Koch (wk@(none))
* secmem.c (MAP_ANON): Add a macro test
Wed Jul 29 14:53:34 1998 Werner Koch (wk@(none))
* ttyio.c (tty_get_answer_is_yes): New.
Tue Jul 21 10:35:48 1998 Werner Koch (wk@(none))
* argparse.c: New option flag to distinguish options and commands.
Sat Jul 18 19:49:30 1998 Werner Koch (wk@(none))
* argparse.c (arg_parse): Added -? as alias for -h
Thu Jul 9 14:47:20 1998 Werner Koch (wk@isil.d.shuttle.de)
* secmem.c (secmem_init): Drops setuid if called with 0.
Tue Jul 7 11:49:25 1998 Werner Koch (wk@isil.d.shuttle.de)
* logger.c (log_set_filename): New.
Mon Jul 6 09:03:49 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (append_to_strlist): New.
Thu Jul 2 15:55:44 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (block_filter): Add writing of OP partial length headers.
Fri Jun 26 10:38:35 1998 Werner Koch (wk@isil.d.shuttle.de)
* ttyio.c (do_get): all iso8859-1 characters are now allowed.
Thu Jun 25 15:57:21 1998 Werner Koch (wk@isil.d.shuttle.de)
* secmem.c (lock_pool): Removed left over test code.
Wed Jun 10 07:39:41 1998 Werner Koch,mobil,,, (wk@tobold)
* fileutil.c (compare_filenames): New.
* argparse.c (arg_parse): New flag bit 6 to ignore --version
Thu May 14 16:45:13 1998 Werner Koch (wk@isil.d.shuttle.de)
* argparse.c (show_help): Add some formatting stuff
Fri May 8 17:06:49 1998 Werner Koch (wk@isil.d.shuttle.de)
* errors.c (strerror): New if !HAVE_STRERROR
Mon May 4 19:48:03 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (iobuf_read): Code is now faster.
* (iobuf_write): ditto.
Mon Apr 27 11:01:32 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (memicmp): New.
Thu Mar 19 11:29:03 1998 Werner Koch (wk@isil.d.shuttle.de)
* strgutil.c (memistr): Add const to return and first arg.
Sat Mar 7 11:54:35 1998 Werner Koch (wk@isil.d.shuttle.de)
* miscutil.c (print_string): New arg delim; changed all callers.
Thu Mar 5 12:19:30 1998 Werner Koch (wk@isil.d.shuttle.de)
* errors.c: New strings.
Thu Mar 5 12:06:31 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (iobuf_open): A name of "-" now opens stdin.
* fileutil.c (print_fname_stdout, print_fname_stdin): New.
Fri Feb 27 10:20:03 1998 Werner Koch (wk@isil.d.shuttle.de)
* memory.c (m_is_secure): Removed.
* secmem.c (m_is_secure): Moved to here.
* secmem.c (secmem_realloc): New.
* memory.c (M_GUARD,EXTRA_ALIGN): New (all functions).
Thu Feb 26 14:36:51 1998 Werner Koch (wk@isil.d.shuttle.de)
* secmem.c (lock_pool): No error if EAGAIN is returned instead
of EPERM.
Fri Feb 20 17:43:05 1998 Werner Koch (wk@isil.d.shuttle.de)
* ttyio.c [MINGW32]: Add support for mingw32.
Tue Feb 17 19:43:44 1998 Werner Koch (wk@isil.d.shuttle.de)
* memory.c (dump_table_at_exit): New.
Mon Feb 16 10:07:28 1998 Werner Koch (wk@isil.d.shuttle.de)
* argparse.c (show_version, show_help, default_strusage): Changed
according to GNU standards.
Mon Feb 16 08:58:25 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (iobuf_peek): New
Fri Feb 13 19:34:59 1998 Werner Koch (wk@isil.d.shuttle.de)
* iobuf.c (iobuf_seek): Set counters to new offset.
Fri Feb 13 17:13:04 1998 Werner Koch (wk@isil.d.shuttle.de)
* logger.c (log_set_name, log_get_name): New.
(print_prefix, pgm_name): New, changed all function to make use it.
(log_mpidump): Removed the "DBG" prefix.
(log_hexdump): Ditto.
* logger.c (printstr): Removed.
Fri Feb 13 15:14:13 1998 Werner Koch (wk@isil.d.shuttle.de)
* argparse.c (show_help): New '\v' kludge.
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
modifications, as long as this notice is preserved.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/util/cert.c b/util/cert.c
index e37544e01..bae1b196f 100644
--- a/util/cert.c
+++ b/util/cert.c
@@ -1,208 +1,251 @@
/* cert.c - DNS CERT code
- * Copyright (C) 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2005, 2006 Free Software Foundation, Inc.
*
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <sys/types.h>
#ifdef USE_DNS_CERT
#ifdef _WIN32
#include <windows.h>
#else
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#endif
#include <string.h>
#include "memory.h"
#endif
#include "iobuf.h"
+#include "util.h"
/* Not every installation has gotten around to supporting CERTs
yet... */
#ifndef T_CERT
#define T_CERT 37
#endif
#ifdef USE_DNS_CERT
/* Returns -1 on error, 0 for no answer, 1 for PGP provided and 2 for
IPGP provided. */
int
-get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url)
+get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url)
{
unsigned char *answer;
int r,ret=-1;
u16 count;
+ if(fpr)
+ *fpr=NULL;
+
+ if(url)
+ *url=NULL;
+
answer=xmalloc(max_size);
r=res_query(name,C_IN,T_CERT,answer,max_size);
/* Not too big, not too small, no errors and at least 1 answer. */
if(r>=sizeof(HEADER) && r<=max_size
&& (((HEADER *)answer)->rcode)==NOERROR
&& (count=ntohs(((HEADER *)answer)->ancount)))
{
int rc;
unsigned char *pt,*emsg;
emsg=&answer[r];
pt=&answer[sizeof(HEADER)];
/* Skip over the query */
rc=dn_skipname(pt,emsg);
if(rc==-1)
goto fail;
pt+=rc+QFIXEDSZ;
/* There are several possible response types for a CERT request.
We're interested in the PGP (a key) and IPGP (a URI) types.
Skip all others. TODO: A key is better than a URI since
we've gone through all this bother to fetch it, so favor that
if we have both PGP and IPGP? */
while(count-->0 && pt<emsg)
{
u16 type,class,dlen,ctype;
rc=dn_skipname(pt,emsg); /* the name we just queried for */
if(rc==-1)
break;
pt+=rc;
- /* Truncated message? */
+ /* Truncated message? 15 bytes takes us to the point where
+ we start looking at the ctype. */
if((emsg-pt)<15)
break;
type=*pt++ << 8;
type|=*pt++;
class=*pt++ << 8;
class|=*pt++;
/* We asked for IN and got something else !? */
if(class!=C_IN)
break;
/* ttl */
pt+=4;
/* data length */
dlen=*pt++ << 8;
dlen|=*pt++;
/* We asked for CERT and got something else - might be a
CNAME, so loop around again. */
if(type!=T_CERT)
{
pt+=dlen;
continue;
}
/* The CERT type */
ctype=*pt++ << 8;
ctype|=*pt++;
/* Skip the CERT key tag and algo which we don't need. */
pt+=3;
dlen-=5;
- if(ctype==3 && iobuf)
+ /* 15 bytes takes us to here */
+
+ if(ctype==3 && iobuf && dlen)
{
/* PGP type */
*iobuf=iobuf_temp_with_content((char *)pt,dlen);
ret=1;
break;
}
-#if 0
- else if(ctype==6 && dlen<1023 && url)
+ else if(ctype==6 && dlen && dlen<1023 && dlen>=pt[0]+1
+ && fpr && fpr_len && url)
{
- /* Sanity check the IPGP URL type that the URL isn't too
- long */
+ /* IPGP type */
+ *fpr_len=pt[0];
+
+ if(*fpr_len)
+ {
+ *fpr=xmalloc(*fpr_len);
+ memcpy(*fpr,&pt[1],*fpr_len);
+ }
+ else
+ *fpr=NULL;
+
+ if(dlen>*fpr_len+1)
+ {
+ *url=xmalloc(dlen-(*fpr_len+1)+1);
+ memcpy(*url,&pt[*fpr_len+1],dlen-(*fpr_len+1));
+ (*url)[dlen-(*fpr_len+1)]='\0';
+ }
+ else
+ *url=NULL;
- *url=xmalloc(dlen+1);
- memcpy(*url,pt,dlen);
- (*url)[dlen]='\0';
ret=2;
break;
}
-#endif
/* Neither type matches, so go around to the next answer. */
pt+=dlen;
}
}
fail:
xfree(answer);
return ret;
}
#else /* !USE_DNS_CERT */
int
-get_cert(const char *name,size_t max_size,IOBUF *iobuf,char **url)
+get_cert(const char *name,size_t max_size,IOBUF *iobuf,
+ unsigned char **fpr,size_t *fpr_len,char **url)
{
return -1;
}
#endif
/* Test with simon.josefsson.org */
#ifdef TEST
int
main(int argc,char *argv[])
{
+ unsigned char *fpr;
+ size_t fpr_len;
char *url;
int rc;
IOBUF iobuf;
if(argc!=2)
{
printf("cert-test [name]\n");
return 1;
}
printf("CERT lookup on %s\n",argv[1]);
- rc=get_cert(argv[1],16384,&iobuf,&url);
+ rc=get_cert(argv[1],16384,&iobuf,&fpr,&fpr_len,&url);
if(rc==-1)
printf("error\n");
else if(rc==0)
printf("no answer\n");
else if(rc==1)
{
printf("key found: %d bytes\n",iobuf_get_temp_length(iobuf));
iobuf_close(iobuf);
}
else if(rc==2)
{
- printf("URL found: %s\n",url);
+ if(fpr)
+ {
+ size_t i;
+ printf("Fingerprint found (%d bytes): ",fpr_len);
+ for(i=0;i<fpr_len;i++)
+ printf("%02X",fpr[i]);
+ printf("\n");
+ }
+ else
+ printf("No fingerprint found\n");
+
+ if(url)
+ printf("URL found: %s\n",url);
+ else
+ printf("No URL found\n");
+
+ xfree(fpr);
xfree(url);
}
return 0;
}
#endif /* TEST */

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jan 24, 11:08 PM (9 h, 59 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
08/36/15400f8be4842e41b53aa71d2c4e

Event Timeline