1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-18 14:17:03 +01:00

* options.h, keyserver-internal.h, keyserver.c (keyserver_import_name),

getkey.c (free_akl, parse_auto_key_locate, get_pubkey_byname): The obvious
next step: allow arbitrary keyservers in the auto-key-locate list.
This commit is contained in:
David Shaw 2006-02-22 23:37:23 +00:00
parent 482a3a0101
commit 1ae024ef81
6 changed files with 45 additions and 9 deletions

View File

@ -1,5 +1,10 @@
2006-02-22 David Shaw <dshaw@jabberwocky.com> 2006-02-22 David Shaw <dshaw@jabberwocky.com>
* options.h, keyserver-internal.h, keyserver.c
(keyserver_import_name), getkey.c (free_akl,
parse_auto_key_locate, get_pubkey_byname): The obvious next step:
allow arbitrary keyservers in the auto-key-locate list.
* options.h, keyserver.c (parse_keyserver_options): Remove * options.h, keyserver.c (parse_keyserver_options): Remove
auto-cert-retrieve as it is no longer meaningful. Add auto-cert-retrieve as it is no longer meaningful. Add
max-cert-size to allow users to pick a max key size retrieved via max-cert-size to allow users to pick a max key size retrieved via

View File

@ -979,7 +979,7 @@ get_pubkey_byname (PKT_public_key *pk,
if(opt.keyserver) if(opt.keyserver)
{ {
glo_ctrl.in_auto_key_retrieve++; glo_ctrl.in_auto_key_retrieve++;
res=keyserver_import_name(name); res=keyserver_import_name(name,opt.keyserver);
glo_ctrl.in_auto_key_retrieve--; glo_ctrl.in_auto_key_retrieve--;
if(res==0) if(res==0)
@ -987,6 +987,16 @@ get_pubkey_byname (PKT_public_key *pk,
name,opt.keyserver->uri); name,opt.keyserver->uri);
} }
break; break;
case AKL_SPEC:
glo_ctrl.in_auto_key_retrieve++;
res=keyserver_import_name(name,akl->spec);
glo_ctrl.in_auto_key_retrieve--;
if(res==0)
log_info(_("Automatically retrieved `%s' via %s\n"),
name,akl->spec->uri);
break;
} }
rc = key_byname( NULL, namelist, pk, NULL, 0, rc = key_byname( NULL, namelist, pk, NULL, 0,
@ -2879,6 +2889,15 @@ get_ctx_handle(GETKEY_CTX ctx)
return ctx->kr_handle; return ctx->kr_handle;
} }
static void
free_akl(struct akl *akl)
{
if(akl->spec)
free_keyserver_spec(akl->spec);
xfree(akl);
}
int int
parse_auto_key_locate(char *options) parse_auto_key_locate(char *options)
{ {
@ -2901,9 +2920,11 @@ parse_auto_key_locate(char *options)
akl->type=AKL_LDAP; akl->type=AKL_LDAP;
else if(ascii_strcasecmp(tok,"keyserver")==0) else if(ascii_strcasecmp(tok,"keyserver")==0)
akl->type=AKL_KEYSERVER; akl->type=AKL_KEYSERVER;
else if((akl->spec=parse_keyserver_uri(tok,1,NULL,0)))
akl->type=AKL_SPEC;
else else
{ {
xfree(akl); free_akl(akl);
return 0; return 0;
} }
@ -2911,9 +2932,15 @@ parse_auto_key_locate(char *options)
for(last=opt.auto_key_locate;last && last->next;last=last->next) for(last=opt.auto_key_locate;last && last->next;last=last->next)
{ {
/* Check for duplicates */ /* Check for duplicates */
if(last && last->type==akl->type) if(last && last->type==akl->type
&& (akl->type!=AKL_SPEC
|| (akl->type==AKL_SPEC
&& strcmp(last->spec->uri,akl->spec->uri)==0)))
{
free_akl(akl);
return 0; return 0;
} }
}
if(last) if(last)
last->next=akl; last->next=akl;

View File

@ -287,7 +287,10 @@ int
keyserver_import_pka(const char *name,unsigned char *fpr) { return -1; } keyserver_import_pka(const char *name,unsigned char *fpr) { return -1; }
int int
keyserver_import_name(const char *name) { return -1; } keyserver_import_name(const char *name,struct keyserver_spec *spec)
{
return -1;
}
int int
keyserver_import_ldap(const char *name) { return -1; } keyserver_import_ldap(const char *name) { return -1; }

View File

@ -43,7 +43,7 @@ int keyserver_search(STRLIST tokens);
int keyserver_fetch(STRLIST urilist); int keyserver_fetch(STRLIST urilist);
int keyserver_import_cert(const char *name); int keyserver_import_cert(const char *name);
int keyserver_import_pka(const char *name,unsigned char *fpr); int keyserver_import_pka(const char *name,unsigned char *fpr);
int keyserver_import_name(const char *name); int keyserver_import_name(const char *name,struct keyserver_spec *keyserver);
int keyserver_import_ldap(const char *name); int keyserver_import_ldap(const char *name);
#endif /* !_KEYSERVER_INTERNAL_H_ */ #endif /* !_KEYSERVER_INTERNAL_H_ */

View File

@ -2001,14 +2001,14 @@ keyserver_import_pka(const char *name,unsigned char *fpr)
/* Import all keys that match name */ /* Import all keys that match name */
int int
keyserver_import_name(const char *name) keyserver_import_name(const char *name,struct keyserver_spec *keyserver)
{ {
STRLIST list=NULL; STRLIST list=NULL;
int rc; int rc;
append_to_strlist(&list,name); append_to_strlist(&list,name);
rc=keyserver_work(KS_GETNAME,list,NULL,0,opt.keyserver); rc=keyserver_work(KS_GETNAME,list,NULL,0,keyserver);
free_strlist(list); free_strlist(list);

View File

@ -224,7 +224,8 @@ struct
keyring. */ keyring. */
struct akl struct akl
{ {
enum {AKL_CERT, AKL_PKA, AKL_LDAP, AKL_KEYSERVER} type; enum {AKL_CERT, AKL_PKA, AKL_LDAP, AKL_KEYSERVER, AKL_SPEC} type;
struct keyserver_spec *spec;
struct akl *next; struct akl *next;
} *auto_key_locate; } *auto_key_locate;