* ksutil.h, ksutil.c (parse_ks_options): New keyserver-option exact-name.
authorDavid Shaw <dshaw@jabberwocky.com>
Thu, 18 Aug 2005 21:14:16 +0000 (21:14 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Thu, 18 Aug 2005 21:14:16 +0000 (21:14 +0000)
The last of exact-name and exact-email overrides the earlier.

* gpgkeys_ldap.c (search_key), gpgkeys_hkp.c (search_key): Use it here to
do a name-only search.

keyserver/ChangeLog
keyserver/gpgkeys_hkp.c
keyserver/gpgkeys_ldap.c
keyserver/ksutil.c
keyserver/ksutil.h

index 0a0b224..ad33db0 100644 (file)
@@ -1,5 +1,12 @@
 2005-08-18  David Shaw  <dshaw@jabberwocky.com>
 
+       * ksutil.h, ksutil.c (parse_ks_options): New keyserver-option
+       exact-name.  The last of exact-name and exact-email overrides the
+       earlier.
+
+       * gpgkeys_ldap.c (search_key), gpgkeys_hkp.c (search_key): Use it
+       here to do a name-only search.
+
        * gpgkeys_ldap.c (ldap_quote): \-quote a string for LDAP.
 
        * gpgkeys_ldap.c (search_key): Use it here to escape reserved
index b231420..a0ea310 100644 (file)
@@ -291,7 +291,25 @@ search_key(char *searchkey)
   char *searchkey_encoded=NULL;
   int ret=KEYSERVER_INTERNAL_ERROR;
 
-  if(opt->flags.exact_email)
+  if(opt->flags.exact_name)
+    {
+      char *bracketed;
+
+      bracketed=malloc(strlen(searchkey)+2+1);
+      if(!bracketed)
+       {
+         fprintf(console,"gpgkeys: out of memory\n");
+         ret=KEYSERVER_NO_MEMORY;
+         goto fail;
+       }
+
+      strcpy(bracketed,searchkey);
+      strcat(bracketed," <");
+
+      searchkey_encoded=curl_escape(bracketed,0);
+      free(bracketed);
+    }
+  else if(opt->flags.exact_email)
     {
       char *bracketed;
 
@@ -341,7 +359,7 @@ search_key(char *searchkey)
   append_path(request,"/pks/lookup?op=index&options=mr&search=");
   strcat(request,searchkey_encoded);
 
-  if(opt->flags.exact_email)
+  if(opt->flags.exact_name || opt->flags.exact_email)
     strcat(request,"&exact=on");
 
   if(opt->verbose>2)
index eb40fab..a64d460 100644 (file)
@@ -1158,6 +1158,9 @@ ldap_quote(char *buffer,const char *string)
        }
     }
 
+  if(buffer)
+    *buffer='\0';
+
   return count;
 }
 
@@ -1173,7 +1176,7 @@ search_key(char *searchkey)
   /* The maximum size of the search, including the optional stuff and
      the trailing \0 */
   char *expanded_search;
-  char search[2+12+1+MAX_LINE+1+2+15+14+1+1];
+  char search[2+12+1+1+MAX_LINE+1+2+2+15+14+1+1];
   char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
                 "pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
                 "pgpkeysize","pgpkeytype",NULL};
@@ -1192,11 +1195,13 @@ search_key(char *searchkey)
 
   /* Build the search string */
 
-  sprintf(search,"%s(pgpuserid=*%s%s%s*)%s%s%s",
+  sprintf(search,"%s(pgpuserid=%s%s%s%s%s*)%s%s%s",
          (!(opt->flags.include_disabled&&opt->flags.include_revoked))?"(&":"",
+         opt->flags.exact_name?"":"*",
          opt->flags.exact_email?"<":"",
          expanded_search,
          opt->flags.exact_email?">":"",
+         opt->flags.exact_name?" <":"",
          opt->flags.include_disabled?"":"(pgpdisabled=0)",
          opt->flags.include_revoked?"":"(pgprevoked=0)",
          !(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
index 7878416..287f502 100644 (file)
@@ -304,7 +304,20 @@ parse_ks_options(char *line,struct ks_options *opt)
          if(no)
            opt->flags.exact_email=0;
          else
-           opt->flags.exact_email=1;
+           {
+             opt->flags.exact_email=1;
+             opt->flags.exact_name=0;
+           }
+       }
+      else if(strcasecmp(start,"exact-name")==0)
+       {
+         if(no)
+           opt->flags.exact_name=0;
+         else
+           {
+             opt->flags.exact_name=1;
+             opt->flags.exact_email=0;
+           }
        }
     }
 
index 8e17914..e9d875f 100644 (file)
@@ -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_name:1;
     unsigned int exact_email:1;
   } flags;
   unsigned int verbose;