aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2006-04-11 03:00:50 +0000
committerDavid Shaw <[email protected]>2006-04-11 03:00:50 +0000
commit3011a392843f4a34587309187793cda8eb388475 (patch)
tree13cab45ee9595ddab78fa22fa86386e0da1e675f
parent* gpg.sgml: Some typo fixes. This is Debian 361324. (diff)
downloadgnupg-3011a392843f4a34587309187793cda8eb388475.tar.gz
gnupg-3011a392843f4a34587309187793cda8eb388475.zip
* ksutil.h, ksutil.c (classify_ks_search): Add KS_SEARCH_KEYID_SHORT
and KS_SEARCH_KEYID_LONG to search for a key ID. * gpgkeys_ldap.c (search_key): Use it here to flip from pgpUserID searches to pgpKeyID or pgpCertID.
Diffstat (limited to '')
-rw-r--r--keyserver/ChangeLog9
-rw-r--r--keyserver/gpgkeys_ldap.c89
-rw-r--r--keyserver/ksutil.c22
-rw-r--r--keyserver/ksutil.h3
4 files changed, 108 insertions, 15 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index 1c3dc663b..972a3255b 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,3 +1,12 @@
+2006-04-10 David Shaw <[email protected]>
+
+ * ksutil.h, ksutil.c (classify_ks_search): Add
+ KS_SEARCH_KEYID_SHORT and KS_SEARCH_KEYID_LONG to search for a key
+ ID.
+
+ * gpgkeys_ldap.c (search_key): Use it here to flip from pgpUserID
+ searches to pgpKeyID or pgpCertID.
+
2006-03-27 David Shaw <[email protected]>
* gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so
diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c
index c47831907..59984b113 100644
--- a/keyserver/gpgkeys_ldap.c
+++ b/keyserver/gpgkeys_ldap.c
@@ -1291,7 +1291,7 @@ search_key(const char *searchkey)
char *expanded_search;
/* The maximum size of the search, including the optional stuff and
the trailing \0 */
- char search[2+11+3+MAX_LINE+2+15+14+1+1+20];
+ char search[2+1+9+1+3+(MAX_LINE*3)+3+1+15+1+1];
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
"pgpkeysize","pgpkeytype",NULL};
@@ -1317,17 +1317,82 @@ search_key(const char *searchkey)
/* Build the search string */
- sprintf(search,"%s(pgpuserid=%s%s%s)%s%s%s",
- (!(opt->flags.include_disabled&&opt->flags.include_revoked))?"(&":"",
- (search_type==KS_SEARCH_EXACT)?"":
- (search_type==KS_SEARCH_MAILSUB)?"*<*":"*",
- expanded_search,
- (search_type==KS_SEARCH_EXACT
- || search_type==KS_SEARCH_MAIL)?"":
- (search_type==KS_SEARCH_MAILSUB)?"*>":"*",
- opt->flags.include_disabled?"":"(pgpdisabled=0)",
- opt->flags.include_revoked?"":"(pgprevoked=0)",
- !(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
+ search[0]='\0';
+
+ if(!opt->flags.include_disabled || !opt->flags.include_revoked)
+ strcat(search,"(&");
+
+ strcat(search,"(");
+
+ switch(search_type)
+ {
+ case KS_SEARCH_KEYID_SHORT:
+ strcat(search,"pgpKeyID");
+ break;
+
+ case KS_SEARCH_KEYID_LONG:
+ strcat(search,"pgpCertID");
+ break;
+
+ default:
+ strcat(search,"pgpUserID");
+ break;
+ }
+
+ strcat(search,"=");
+
+ switch(search_type)
+ {
+ case KS_SEARCH_SUBSTR:
+ strcat(search,"*");
+ break;
+
+ case KS_SEARCH_MAIL:
+ strcat(search,"*<");
+ break;
+
+ case KS_SEARCH_MAILSUB:
+ strcat(search,"*<*");
+ break;
+
+ case KS_SEARCH_EXACT:
+ case KS_SEARCH_KEYID_LONG:
+ case KS_SEARCH_KEYID_SHORT:
+ break;
+ }
+
+ strcat(search,expanded_search);
+
+ switch(search_type)
+ {
+ case KS_SEARCH_SUBSTR:
+ strcat(search,"*");
+ break;
+
+ case KS_SEARCH_MAIL:
+ strcat(search,">*");
+ break;
+
+ case KS_SEARCH_MAILSUB:
+ strcat(search,"*>*");
+ break;
+
+ case KS_SEARCH_EXACT:
+ case KS_SEARCH_KEYID_LONG:
+ case KS_SEARCH_KEYID_SHORT:
+ break;
+ }
+
+ strcat(search,")");
+
+ if(!opt->flags.include_disabled)
+ strcat(search,"(pgpDisabled=0)");
+
+ if(!opt->flags.include_revoked)
+ strcat(search,"(pgpRevoked=0)");
+
+ if(!opt->flags.include_disabled || !opt->flags.include_revoked)
+ strcat(search,")");
free(expanded_search);
diff --git a/keyserver/ksutil.c b/keyserver/ksutil.c
index 53fa294c2..9bd697fff 100644
--- a/keyserver/ksutil.c
+++ b/keyserver/ksutil.c
@@ -346,8 +346,6 @@ classify_ks_search(const char **search)
{
switch(**search)
{
- default:
- return KS_SEARCH_SUBSTR;
case '*':
(*search)++;
return KS_SEARCH_SUBSTR;
@@ -355,10 +353,30 @@ classify_ks_search(const char **search)
(*search)++;
return KS_SEARCH_EXACT;
case '<':
+ (*search)++;
return KS_SEARCH_MAIL;
case '@':
(*search)++;
return KS_SEARCH_MAILSUB;
+ case '0':
+ if((*search)[1]=='x')
+ {
+ if(strlen(*search)==10
+ && strspn(*search,"abcdefABCDEF1234567890x")==10)
+ {
+ (*search)+=2;
+ return KS_SEARCH_KEYID_SHORT;
+ }
+ else if(strlen(*search)==18
+ && strspn(*search,"abcdefABCDEF1234567890x")==18)
+ {
+ (*search)+=2;
+ return KS_SEARCH_KEYID_LONG;
+ }
+ }
+ /* fall through */
+ default:
+ return KS_SEARCH_SUBSTR;
}
}
diff --git a/keyserver/ksutil.h b/keyserver/ksutil.h
index b5e67bb63..0ef14f595 100644
--- a/keyserver/ksutil.h
+++ b/keyserver/ksutil.h
@@ -75,7 +75,8 @@ int register_timeout(void);
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,
- KS_SEARCH_MAIL,KS_SEARCH_MAILSUB};
+ KS_SEARCH_MAIL,KS_SEARCH_MAILSUB,
+ KS_SEARCH_KEYID_LONG,KS_SEARCH_KEYID_SHORT};
struct ks_options
{