[svn] GnuPG - r3865 - trunk/keyserver
svn author dshaw
cvs at cvs.gnupg.org
Thu Aug 18 06:17:27 CEST 2005
Author: dshaw
Date: 2005-08-18 06:17:20 +0200 (Thu, 18 Aug 2005)
New Revision: 3865
Modified:
trunk/keyserver/ChangeLog
trunk/keyserver/gpgkeys_hkp.c
trunk/keyserver/gpgkeys_ldap.c
trunk/keyserver/ksutil.c
trunk/keyserver/ksutil.h
Log:
* ksutil.h, ksutil.c (parse_ks_options): New keyserver-option
exact-email.
* gpgkeys_ldap.c (search_key), gpgkeys_hkp.c (search_key): Use it here
to do an email-only search.
Modified: trunk/keyserver/ChangeLog
===================================================================
--- trunk/keyserver/ChangeLog 2005-08-16 09:15:09 UTC (rev 3864)
+++ trunk/keyserver/ChangeLog 2005-08-18 04:17:20 UTC (rev 3865)
@@ -1,3 +1,11 @@
+2005-08-17 David Shaw <dshaw at jabberwocky.com>
+
+ * ksutil.h, ksutil.c (parse_ks_options): New keyserver-option
+ exact-email.
+
+ * gpgkeys_ldap.c (search_key), gpgkeys_hkp.c (search_key): Use it
+ here to do an email-only search.
+
2005-08-08 David Shaw <dshaw at jabberwocky.com>
* Makefile.am: Include LDAP_CPPFLAGS when building LDAP.
Modified: trunk/keyserver/gpgkeys_hkp.c
===================================================================
--- trunk/keyserver/gpgkeys_hkp.c 2005-08-16 09:15:09 UTC (rev 3864)
+++ trunk/keyserver/gpgkeys_hkp.c 2005-08-18 04:17:20 UTC (rev 3865)
@@ -287,13 +287,40 @@
search_key(char *searchkey)
{
CURLcode res;
- char *request;
- char *searchkey_encoded;
+ char *request=NULL;
+ char *searchkey_encoded=NULL;
int ret=KEYSERVER_INTERNAL_ERROR;
- searchkey_encoded=curl_escape(searchkey,0);
+ if(opt->flags.exact_email)
+ {
+ char *bracketed;
- request=malloc(MAX_URL+50+strlen(searchkey_encoded));
+ bracketed=malloc(1+strlen(searchkey)+1+1);
+ if(!bracketed)
+ {
+ fprintf(console,"gpgkeys: out of memory\n");
+ ret=KEYSERVER_NO_MEMORY;
+ goto fail;
+ }
+
+ strcpy(bracketed,"<");
+ strcat(bracketed,searchkey);
+ strcat(bracketed,">");
+
+ searchkey_encoded=curl_escape(bracketed,0);
+ free(bracketed);
+ }
+ else
+ searchkey_encoded=curl_escape(searchkey,0);
+
+ if(!searchkey_encoded)
+ {
+ fprintf(console,"gpgkeys: out of memory\n");
+ ret=KEYSERVER_NO_MEMORY;
+ goto fail;
+ }
+
+ request=malloc(MAX_URL+60+strlen(searchkey_encoded));
if(!request)
{
fprintf(console,"gpgkeys: out of memory\n");
@@ -314,6 +341,9 @@
append_path(request,"/pks/lookup?op=index&options=mr&search=");
strcat(request,searchkey_encoded);
+ if(opt->flags.exact_email)
+ strcat(request,"&exact=on");
+
if(opt->verbose>2)
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
Modified: trunk/keyserver/gpgkeys_ldap.c
===================================================================
--- trunk/keyserver/gpgkeys_ldap.c 2005-08-16 09:15:09 UTC (rev 3864)
+++ trunk/keyserver/gpgkeys_ldap.c 2005-08-18 04:17:20 UTC (rev 3865)
@@ -1141,7 +1141,7 @@
struct keylist *dupelist=NULL;
/* The maximum size of the search, including the optional stuff and
the trailing \0 */
- char search[2+12+MAX_LINE+2+15+14+1+1];
+ char search[2+12+1+MAX_LINE+1+2+15+14+1+1];
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
"pgpkeysize","pgpkeytype",NULL};
@@ -1150,9 +1150,11 @@
/* Build the search string */
- sprintf(search,"%s(pgpuserid=*%s*)%s%s%s",
+ sprintf(search,"%s(pgpuserid=*%s%s%s*)%s%s%s",
(!(opt->flags.include_disabled&&opt->flags.include_revoked))?"(&":"",
+ opt->flags.exact_email?"<":"",
searchkey,
+ opt->flags.exact_email?">":"",
opt->flags.include_disabled?"":"(pgpdisabled=0)",
opt->flags.include_revoked?"":"(pgprevoked=0)",
!(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
@@ -1198,7 +1200,12 @@
}
if(err==LDAP_SIZELIMIT_EXCEEDED)
- fprintf(console,"gpgkeys: search results exceeded server limit. First %d results shown.\n",count);
+ {
+ if(count==1)
+ fprintf(console,"gpgkeys: search results exceeded server limit. First %d result shown.\n",count);
+ else
+ fprintf(console,"gpgkeys: search results exceeded server limit. First %d results shown.\n",count);
+ }
free_keylist(dupelist);
dupelist=NULL;
Modified: trunk/keyserver/ksutil.c
===================================================================
--- trunk/keyserver/ksutil.c 2005-08-16 09:15:09 UTC (rev 3864)
+++ trunk/keyserver/ksutil.c 2005-08-18 04:17:20 UTC (rev 3865)
@@ -298,6 +298,14 @@
return KEYSERVER_NO_MEMORY;
}
}
+ else if(strcasecmp(start,"exact-email")==0
+ || strcasecmp(start,"exact-mail")==0)
+ {
+ if(no)
+ opt->flags.exact_email=0;
+ else
+ opt->flags.exact_email=1;
+ }
}
return -1;
Modified: trunk/keyserver/ksutil.h
===================================================================
--- trunk/keyserver/ksutil.h 2005-08-16 09:15:09 UTC (rev 3864)
+++ trunk/keyserver/ksutil.h 2005-08-18 04:17:20 UTC (rev 3865)
@@ -89,6 +89,7 @@
unsigned int include_revoked:1;
unsigned int include_subkeys:1;
unsigned int check_cert:1;
+ unsigned int exact_email:1;
} flags;
unsigned int verbose;
unsigned int debug;
More information about the Gnupg-commits
mailing list