1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-23 15:07:03 +01:00

* 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.
This commit is contained in:
David Shaw 2005-08-18 04:17:20 +00:00
parent 0a3eda24ee
commit e9b444a9d0
5 changed files with 61 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2005-08-17 David Shaw <dshaw@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@jabberwocky.com> 2005-08-08 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: Include LDAP_CPPFLAGS when building LDAP. * Makefile.am: Include LDAP_CPPFLAGS when building LDAP.

View File

@ -287,13 +287,40 @@ int
search_key(char *searchkey) search_key(char *searchkey)
{ {
CURLcode res; CURLcode res;
char *request; char *request=NULL;
char *searchkey_encoded; char *searchkey_encoded=NULL;
int ret=KEYSERVER_INTERNAL_ERROR; int ret=KEYSERVER_INTERNAL_ERROR;
if(opt->flags.exact_email)
{
char *bracketed;
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); searchkey_encoded=curl_escape(searchkey,0);
request=malloc(MAX_URL+50+strlen(searchkey_encoded)); 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) if(!request)
{ {
fprintf(console,"gpgkeys: out of memory\n"); fprintf(console,"gpgkeys: out of memory\n");
@ -314,6 +341,9 @@ search_key(char *searchkey)
append_path(request,"/pks/lookup?op=index&options=mr&search="); append_path(request,"/pks/lookup?op=index&options=mr&search=");
strcat(request,searchkey_encoded); strcat(request,searchkey_encoded);
if(opt->flags.exact_email)
strcat(request,"&exact=on");
if(opt->verbose>2) if(opt->verbose>2)
fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request); fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);

View File

@ -1141,7 +1141,7 @@ search_key(char *searchkey)
struct keylist *dupelist=NULL; struct keylist *dupelist=NULL;
/* The maximum size of the search, including the optional stuff and /* The maximum size of the search, including the optional stuff and
the trailing \0 */ 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", char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp", "pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
"pgpkeysize","pgpkeytype",NULL}; "pgpkeysize","pgpkeytype",NULL};
@ -1150,9 +1150,11 @@ search_key(char *searchkey)
/* Build the search string */ /* 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.include_disabled&&opt->flags.include_revoked))?"(&":"",
opt->flags.exact_email?"<":"",
searchkey, searchkey,
opt->flags.exact_email?">":"",
opt->flags.include_disabled?"":"(pgpdisabled=0)", opt->flags.include_disabled?"":"(pgpdisabled=0)",
opt->flags.include_revoked?"":"(pgprevoked=0)", opt->flags.include_revoked?"":"(pgprevoked=0)",
!(opt->flags.include_disabled&&opt->flags.include_revoked)?")":""); !(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
@ -1198,7 +1200,12 @@ search_key(char *searchkey)
} }
if(err==LDAP_SIZELIMIT_EXCEEDED) if(err==LDAP_SIZELIMIT_EXCEEDED)
{
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); fprintf(console,"gpgkeys: search results exceeded server limit. First %d results shown.\n",count);
}
free_keylist(dupelist); free_keylist(dupelist);
dupelist=NULL; dupelist=NULL;

View File

@ -298,6 +298,14 @@ parse_ks_options(char *line,struct ks_options *opt)
return KEYSERVER_NO_MEMORY; 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; return -1;

View File

@ -89,6 +89,7 @@ struct ks_options
unsigned int include_revoked:1; unsigned int include_revoked:1;
unsigned int include_subkeys:1; unsigned int include_subkeys:1;
unsigned int check_cert:1; unsigned int check_cert:1;
unsigned int exact_email:1;
} flags; } flags;
unsigned int verbose; unsigned int verbose;
unsigned int debug; unsigned int debug;