summaryrefslogtreecommitdiffstats
path: root/g10/keyserver.c
diff options
context:
space:
mode:
authorDavid Shaw <dshaw@jabberwocky.com>2006-02-24 15:27:22 +0100
committerDavid Shaw <dshaw@jabberwocky.com>2006-02-24 15:27:22 +0100
commitf4f5ea43e76fff8941a8148e70f237b7c4033b41 (patch)
treec9bde0dd601fb120ca0b4b81ff279a318cb42b52 /g10/keyserver.c
parent* keyserver.c (parse_keyserver_options): Only change max_cert if it is (diff)
downloadgnupg2-f4f5ea43e76fff8941a8148e70f237b7c4033b41.tar.xz
gnupg2-f4f5ea43e76fff8941a8148e70f237b7c4033b41.zip
* 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.
Diffstat (limited to 'g10/keyserver.c')
-rw-r--r--g10/keyserver.c40
1 files changed, 38 insertions, 2 deletions
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)