[svn] GnuPG - r4027 - trunk/g10
svn author dshaw
cvs at cvs.gnupg.org
Fri Feb 24 15:27:24 CET 2006
Author: dshaw
Date: 2006-02-24 15:27:22 +0100 (Fri, 24 Feb 2006)
New Revision: 4027
Modified:
trunk/g10/ChangeLog
trunk/g10/getkey.c
trunk/g10/gpg.c
trunk/g10/gpgv.c
trunk/g10/keydb.h
trunk/g10/keyserver-internal.h
trunk/g10/keyserver.c
trunk/g10/options.h
Log:
* 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.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/ChangeLog 2006-02-24 14:27:22 UTC (rev 4027)
@@ -1,3 +1,18 @@
+2006-02-24 David Shaw <dshaw at jabberwocky.com>
+
+ * 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 <dshaw at jabberwocky.com>
* keyserver.c (parse_keyserver_options): Only change max_cert if
Modified: trunk/g10/getkey.c
===================================================================
--- trunk/g10/getkey.c 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/getkey.c 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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 @@
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 @@
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)
{
Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/gpg.c 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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 @@
oRequireBacksigs,
oNoRequireBacksigs,
oAutoKeyLocate,
+ oNoAutoKeyLocate,
oNoop
};
@@ -698,15 +699,16 @@
#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 @@
#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 @@
log_error(_("invalid auto-key-locate list\n"));
}
break;
+ case oNoAutoKeyLocate:
+ release_akl();
+ break;
case oNoop: break;
Modified: trunk/g10/gpgv.c
===================================================================
--- trunk/g10/gpgv.c 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/gpgv.c 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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 @@
* 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 )
{
Modified: trunk/g10/keydb.h
===================================================================
--- trunk/g10/keydb.h 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/keydb.h 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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_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 --*/
Modified: trunk/g10/keyserver-internal.h
===================================================================
--- trunk/g10/keyserver-internal.h 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/keyserver-internal.h 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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,
Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/keyserver.c 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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 @@
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 @@
/* 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)
Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h 2006-02-24 03:57:11 UTC (rev 4026)
+++ trunk/g10/options.h 2006-02-24 14:27:22 UTC (rev 4027)
@@ -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 @@
{
unsigned int direct_uri:1;
} flags;
+ struct keyserver_spec *next;
} *keyserver;
struct
{
More information about the Gnupg-commits
mailing list