[svn] GnuPG - r3867 - trunk/keyserver

svn author dshaw cvs at cvs.gnupg.org
Thu Aug 18 23:14:17 CEST 2005


Author: dshaw
Date: 2005-08-18 23:14:16 +0200 (Thu, 18 Aug 2005)
New Revision: 3867

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-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.


Modified: trunk/keyserver/ChangeLog
===================================================================
--- trunk/keyserver/ChangeLog	2005-08-18 17:40:04 UTC (rev 3866)
+++ trunk/keyserver/ChangeLog	2005-08-18 21:14:16 UTC (rev 3867)
@@ -1,5 +1,12 @@
 2005-08-18  David Shaw  <dshaw at 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

Modified: trunk/keyserver/gpgkeys_hkp.c
===================================================================
--- trunk/keyserver/gpgkeys_hkp.c	2005-08-18 17:40:04 UTC (rev 3866)
+++ trunk/keyserver/gpgkeys_hkp.c	2005-08-18 21:14:16 UTC (rev 3867)
@@ -291,10 +291,28 @@
   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;
+
       bracketed=malloc(1+strlen(searchkey)+1+1);
       if(!bracketed)
 	{
@@ -341,7 +359,7 @@
   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)

Modified: trunk/keyserver/gpgkeys_ldap.c
===================================================================
--- trunk/keyserver/gpgkeys_ldap.c	2005-08-18 17:40:04 UTC (rev 3866)
+++ trunk/keyserver/gpgkeys_ldap.c	2005-08-18 21:14:16 UTC (rev 3867)
@@ -1158,6 +1158,9 @@
 	}
     }
 
+  if(buffer)
+    *buffer='\0';
+
   return count;
 }
 
@@ -1173,7 +1176,7 @@
   /* 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 @@
 
   /* 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)?")":"");

Modified: trunk/keyserver/ksutil.c
===================================================================
--- trunk/keyserver/ksutil.c	2005-08-18 17:40:04 UTC (rev 3866)
+++ trunk/keyserver/ksutil.c	2005-08-18 21:14:16 UTC (rev 3867)
@@ -304,8 +304,21 @@
 	  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;
+	    }
+	}
     }
 
   return -1;

Modified: trunk/keyserver/ksutil.h
===================================================================
--- trunk/keyserver/ksutil.h	2005-08-18 17:40:04 UTC (rev 3866)
+++ trunk/keyserver/ksutil.h	2005-08-18 21:14:16 UTC (rev 3867)
@@ -89,6 +89,7 @@
     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;




More information about the Gnupg-commits mailing list