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:
parent
0a3eda24ee
commit
e9b444a9d0
@ -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>
|
||||
|
||||
* Makefile.am: Include LDAP_CPPFLAGS when building LDAP.
|
||||
|
@ -287,13 +287,40 @@ int
|
||||
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 @@ search_key(char *searchkey)
|
||||
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);
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ search_key(char *searchkey)
|
||||
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 @@ search_key(char *searchkey)
|
||||
|
||||
/* 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 @@ search_key(char *searchkey)
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -298,6 +298,14 @@ parse_ks_options(char *line,struct ks_options *opt)
|
||||
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;
|
||||
|
@ -89,6 +89,7 @@ struct ks_options
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user