[svn] GnuPG - r4100 - trunk/keyserver
svn author dshaw
cvs at cvs.gnupg.org
Tue Apr 11 05:00:51 CEST 2006
Author: dshaw
Date: 2006-04-11 05:00:50 +0200 (Tue, 11 Apr 2006)
New Revision: 4100
Modified:
trunk/keyserver/ChangeLog
trunk/keyserver/gpgkeys_ldap.c
trunk/keyserver/ksutil.c
trunk/keyserver/ksutil.h
Log:
* 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.
Modified: trunk/keyserver/ChangeLog
===================================================================
--- trunk/keyserver/ChangeLog 2006-04-09 23:22:24 UTC (rev 4099)
+++ trunk/keyserver/ChangeLog 2006-04-11 03:00:50 UTC (rev 4100)
@@ -1,3 +1,12 @@
+2006-04-10 David Shaw <dshaw at jabberwocky.com>
+
+ * 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 <dshaw at jabberwocky.com>
* gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so
Modified: trunk/keyserver/gpgkeys_ldap.c
===================================================================
--- trunk/keyserver/gpgkeys_ldap.c 2006-04-09 23:22:24 UTC (rev 4099)
+++ trunk/keyserver/gpgkeys_ldap.c 2006-04-11 03:00:50 UTC (rev 4100)
@@ -1291,7 +1291,7 @@
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,18 +1317,83 @@
/* 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);
if(opt->verbose>2)
Modified: trunk/keyserver/ksutil.c
===================================================================
--- trunk/keyserver/ksutil.c 2006-04-09 23:22:24 UTC (rev 4099)
+++ trunk/keyserver/ksutil.c 2006-04-11 03:00:50 UTC (rev 4100)
@@ -346,8 +346,6 @@
{
switch(**search)
{
- default:
- return KS_SEARCH_SUBSTR;
case '*':
(*search)++;
return KS_SEARCH_SUBSTR;
@@ -355,10 +353,30 @@
(*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;
}
}
Modified: trunk/keyserver/ksutil.h
===================================================================
--- trunk/keyserver/ksutil.h 2006-04-09 23:22:24 UTC (rev 4099)
+++ trunk/keyserver/ksutil.h 2006-04-11 03:00:50 UTC (rev 4100)
@@ -75,7 +75,8 @@
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
{
More information about the Gnupg-commits
mailing list