aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog15
-rw-r--r--g10/getkey.c32
-rw-r--r--g10/gpg.c33
-rw-r--r--g10/gpgv.c8
-rw-r--r--g10/keydb.h5
-rw-r--r--g10/keyserver-internal.h3
-rw-r--r--g10/keyserver.c40
-rw-r--r--g10/options.h5
8 files changed, 114 insertions, 27 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index d16b83ce2..395d39a6a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,18 @@
+2006-02-24 David Shaw <[email protected]>
+
+ * keydb.h, getkey.c (release_akl), gpg.c (main): Add
+ --no-auto-key-locate.
+
+ * options.h, gpg.c (main): Keep track of each keyserver registered
+ so we can match on them later.
+
+ * keyserver-internal.h, keyserver.c (cmp_keyserver_spec,
+ keyserver_match), gpgv.c: New. Find a keyserver that matches ours
+ and return its spec.
+
+ * getkey.c (get_pubkey_byname): Use it here to get the
+ per-keyserver options from an earlier keyserver.
+
2006-02-23 David Shaw <[email protected]>
* keyserver.c (parse_keyserver_options): Only change max_cert if
diff --git a/g10/getkey.c b/g10/getkey.c
index 81b15b2e2..6c64c77f8 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1,6 +1,6 @@
/* getkey.c - Get a key from the database
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 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.
*
@@ -989,13 +989,18 @@ get_pubkey_byname (PKT_public_key *pk,
break;
case AKL_SPEC:
- glo_ctrl.in_auto_key_retrieve++;
- res=keyserver_import_name(name,akl->spec);
- glo_ctrl.in_auto_key_retrieve--;
+ {
+ struct keyserver_spec *keyserver;
- if(res==0)
- log_info(_("Automatically retrieved `%s' via %s\n"),
- name,akl->spec->uri);
+ keyserver=keyserver_match(akl->spec);
+ glo_ctrl.in_auto_key_retrieve++;
+ res=keyserver_import_name(name,keyserver);
+ glo_ctrl.in_auto_key_retrieve--;
+
+ if(res==0)
+ log_info(_("Automatically retrieved `%s' via %s\n"),
+ name,akl->spec->uri);
+ }
break;
}
@@ -2898,6 +2903,17 @@ free_akl(struct akl *akl)
xfree(akl);
}
+void
+release_akl(void)
+{
+ while(opt.auto_key_locate)
+ {
+ struct akl *akl2=opt.auto_key_locate;
+ opt.auto_key_locate=opt.auto_key_locate->next;
+ free_akl(akl2);
+ }
+}
+
int
parse_auto_key_locate(char *options)
{
diff --git a/g10/gpg.c b/g10/gpg.c
index a3557e7ff..03440538f 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -1,6 +1,6 @@
/* gpg.c - The GnuPG utility (main for gpg)
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 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.
*
@@ -361,6 +361,7 @@ enum cmd_and_opt_values
oRequireBacksigs,
oNoRequireBacksigs,
oAutoKeyLocate,
+ oNoAutoKeyLocate,
oNoop
};
@@ -698,15 +699,16 @@ static ARGPARSE_OPTS opts[] = {
#if defined(ENABLE_CARD_SUPPORT) && defined(HAVE_LIBUSB)
{ oDebugCCIDDriver, "debug-ccid-driver", 0, "@"},
#endif
- /* These are aliases to help users of the PGP command line product
- use gpg with minimal pain. Many commands are common already as
- they seem to have borrowed commands from us. Now I'm returning
- the favor. */
+ /* These two are aliases to help users of the PGP command line
+ product use gpg with minimal pain. Many commands are common
+ already as they seem to have borrowed commands from us. Now
+ I'm returning the favor. */
{ oLocalUser, "sign-with", 2, "@" },
{ oRecipient, "user", 2, "@" },
{ oRequireBacksigs, "require-backsigs", 0, "@"},
{ oNoRequireBacksigs, "no-require-backsigs", 0, "@"},
{ oAutoKeyLocate, "auto-key-locate", 2, "@"},
+ { oNoAutoKeyLocate, "no-auto-key-locate", 0, "@"},
{0,NULL,0,NULL}
};
@@ -2416,10 +2418,18 @@ main (int argc, char **argv )
#endif /* __riscos__ */
break;
case oKeyServer:
- opt.keyserver=parse_keyserver_uri(pargs.r.ret_str,0,
- configname,configlineno);
- if(!opt.keyserver)
- log_error(_("could not parse keyserver URL\n"));
+ {
+ struct keyserver_spec *keyserver;
+ keyserver=parse_keyserver_uri(pargs.r.ret_str,0,
+ configname,configlineno);
+ if(!keyserver)
+ log_error(_("could not parse keyserver URL\n"));
+ else
+ {
+ keyserver->next=opt.keyserver;
+ opt.keyserver=keyserver;
+ }
+ }
break;
case oKeyServerOptions:
if(!parse_keyserver_options(pargs.r.ret_str))
@@ -2655,6 +2665,9 @@ main (int argc, char **argv )
log_error(_("invalid auto-key-locate list\n"));
}
break;
+ case oNoAutoKeyLocate:
+ release_akl();
+ break;
case oNoop: break;
diff --git a/g10/gpgv.c b/g10/gpgv.c
index 1644461ec..5192c26fc 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -1,6 +1,6 @@
/* gpgv.c - The GnuPG signature verify utility
- * Copyright (C) 1998, 1999, 2000, 2001, 2002,
- * 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -274,6 +274,10 @@ get_ownertrust (PKT_public_key *pk)
* Because we only work with trusted keys, it does not make sense to
* get them from a keyserver
*/
+
+struct keyserver_spec *
+keyserver_match(struct keyserver_spec *spec) { return NULL; }
+
int
keyserver_import_keyid( u32 *keyid, void *dummy )
{
diff --git a/g10/keydb.h b/g10/keydb.h
index 2c97b81a0..aed87c2a0 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -1,6 +1,6 @@
/* keydb.h - Key database
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 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.
*
@@ -258,6 +258,7 @@ char*get_long_user_id_string( u32 *keyid );
char*get_user_id( u32 *keyid, size_t *rn );
char*get_user_id_native( u32 *keyid );
KEYDB_HANDLE get_ctx_handle(GETKEY_CTX ctx);
+void release_akl(void);
int parse_auto_key_locate(char *options);
/*-- keyid.c --*/
diff --git a/g10/keyserver-internal.h b/g10/keyserver-internal.h
index c35c57134..64accbaa0 100644
--- a/g10/keyserver-internal.h
+++ b/g10/keyserver-internal.h
@@ -1,5 +1,5 @@
/* keyserver-internal.h - Keyserver internals
- * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -29,6 +29,7 @@
int parse_keyserver_options(char *options);
void free_keyserver_spec(struct keyserver_spec *keyserver);
+struct keyserver_spec *keyserver_match(struct keyserver_spec *spec);
struct keyserver_spec *parse_keyserver_uri(const char *string,
int require_scheme,
const char *configname,
diff --git a/g10/keyserver.c b/g10/keyserver.c
index ee20e427b..302e5f6d5 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1,5 +1,6 @@
/* keyserver.c - generic keyserver code
- * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2004, 2005,
+ * 2006 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -196,6 +197,41 @@ free_keyserver_spec(struct keyserver_spec *keyserver)
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. */
@@ -1050,7 +1086,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
/* Write per-keyserver options */
- for(temp=opt.keyserver->options;temp;temp=temp->next)
+ for(temp=keyserver->options;temp;temp=temp->next)
fprintf(spawn->tochild,"OPTION %s\n",temp->d);
switch(action)
diff --git a/g10/options.h b/g10/options.h
index 36de6331b..28b813250 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -1,6 +1,6 @@
/* options.h
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
- * 2005 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.
*
@@ -141,6 +141,7 @@ struct
{
unsigned int direct_uri:1;
} flags;
+ struct keyserver_spec *next;
} *keyserver;
struct
{