mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
* 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.
This commit is contained in:
parent
1bf02666fb
commit
3011a39284
@ -1,3 +1,12 @@
|
|||||||
|
2006-04-10 David Shaw <dshaw@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@jabberwocky.com>
|
2006-03-27 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so
|
* gpgkeys_ldap.c: #define LDAP_DEPRECATED for newer OpenLDAPs so
|
||||||
|
@ -1291,7 +1291,7 @@ search_key(const char *searchkey)
|
|||||||
char *expanded_search;
|
char *expanded_search;
|
||||||
/* 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+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",
|
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
|
||||||
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
|
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
|
||||||
"pgpkeysize","pgpkeytype",NULL};
|
"pgpkeysize","pgpkeytype",NULL};
|
||||||
@ -1317,17 +1317,82 @@ search_key(const char *searchkey)
|
|||||||
|
|
||||||
/* Build the search string */
|
/* Build the search string */
|
||||||
|
|
||||||
sprintf(search,"%s(pgpuserid=%s%s%s)%s%s%s",
|
search[0]='\0';
|
||||||
(!(opt->flags.include_disabled&&opt->flags.include_revoked))?"(&":"",
|
|
||||||
(search_type==KS_SEARCH_EXACT)?"":
|
if(!opt->flags.include_disabled || !opt->flags.include_revoked)
|
||||||
(search_type==KS_SEARCH_MAILSUB)?"*<*":"*",
|
strcat(search,"(&");
|
||||||
expanded_search,
|
|
||||||
(search_type==KS_SEARCH_EXACT
|
strcat(search,"(");
|
||||||
|| search_type==KS_SEARCH_MAIL)?"":
|
|
||||||
(search_type==KS_SEARCH_MAILSUB)?"*>":"*",
|
switch(search_type)
|
||||||
opt->flags.include_disabled?"":"(pgpdisabled=0)",
|
{
|
||||||
opt->flags.include_revoked?"":"(pgprevoked=0)",
|
case KS_SEARCH_KEYID_SHORT:
|
||||||
!(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
|
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);
|
free(expanded_search);
|
||||||
|
|
||||||
|
@ -346,8 +346,6 @@ classify_ks_search(const char **search)
|
|||||||
{
|
{
|
||||||
switch(**search)
|
switch(**search)
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
return KS_SEARCH_SUBSTR;
|
|
||||||
case '*':
|
case '*':
|
||||||
(*search)++;
|
(*search)++;
|
||||||
return KS_SEARCH_SUBSTR;
|
return KS_SEARCH_SUBSTR;
|
||||||
@ -355,10 +353,30 @@ classify_ks_search(const char **search)
|
|||||||
(*search)++;
|
(*search)++;
|
||||||
return KS_SEARCH_EXACT;
|
return KS_SEARCH_EXACT;
|
||||||
case '<':
|
case '<':
|
||||||
|
(*search)++;
|
||||||
return KS_SEARCH_MAIL;
|
return KS_SEARCH_MAIL;
|
||||||
case '@':
|
case '@':
|
||||||
(*search)++;
|
(*search)++;
|
||||||
return KS_SEARCH_MAILSUB;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,8 @@ int register_timeout(void);
|
|||||||
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
|
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
|
||||||
|
|
||||||
enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,
|
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
|
struct ks_options
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user