[svn] GnuPG - r3959 - trunk/g10

svn author dshaw cvs at cvs.gnupg.org
Thu Dec 8 06:52:42 CET 2005


Author: dshaw
Date: 2005-12-08 06:52:41 +0100 (Thu, 08 Dec 2005)
New Revision: 3959

Modified:
   trunk/g10/ChangeLog
   trunk/g10/keyserver.c
   trunk/g10/options.h
Log:
* options.h, keyserver.c (curl_cant_handle, keyserver_spawn,
keyserver_fetch): Set a flag to indicate that we're doing a direct URI
fetch so we can differentiate between a keyserver operation and a URI
fetch for protocols like LDAP that can do either.


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2005-12-08 05:29:35 UTC (rev 3958)
+++ trunk/g10/ChangeLog	2005-12-08 05:52:41 UTC (rev 3959)
@@ -1,3 +1,10 @@
+2005-12-08  David Shaw  <dshaw at jabberwocky.com>
+
+	* options.h, keyserver.c (curl_cant_handle, keyserver_spawn,
+	keyserver_fetch): Set a flag to indicate that we're doing a direct
+	URI fetch so we can differentiate between a keyserver operation
+	and a URI fetch for protocols like LDAP that can do either.
+
 2005-12-07  David Shaw  <dshaw at jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Don't print "searching for key

Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c	2005-12-08 05:29:35 UTC (rev 3958)
+++ trunk/g10/keyserver.c	2005-12-08 05:52:41 UTC (rev 3959)
@@ -867,9 +867,9 @@
 /* The PGP LDAP and the curl fetch-a-LDAP-object methodologies are
    sufficiently different that we can't use curl to do LDAP. */
 static int
-curl_cant_handle(const char *scheme)
+curl_cant_handle(const char *scheme,unsigned int direct_uri)
 {
-  if(strcmp(scheme,"ldap")==0 || strcmp(scheme,"ldaps")==0)
+  if(!direct_uri && (strcmp(scheme,"ldap")==0 || strcmp(scheme,"ldaps")==0))
     return 1;
 
   return 0;
@@ -883,7 +883,7 @@
 keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
 		int count,int *prog,struct keyserver_spec *keyserver)
 {
-  int ret=0,i,gotversion=0,outofband=0,quiet=0;
+  int ret=0,i,gotversion=0,outofband=0;
   STRLIST temp;
   unsigned int maxlen,buflen;
   char *command,*end,*searchstr=NULL;
@@ -928,7 +928,7 @@
       /* If exec-path was set, and DISABLE_KEYSERVER_PATH is
 	 undefined, then don't specify a full path to gpgkeys_foo, so
 	 that the PATH can work. */
-      command=xmalloc(GPGKEYS_PREFIX_LEN+strlen(scheme)+1);
+      command=xmalloc(GPGKEYS_PREFIX_LEN+strlen(scheme)+3+1);
       command[0]='\0';
     }
   else
@@ -936,7 +936,7 @@
     {
       /* Specify a full path to gpgkeys_foo. */
       command=xmalloc(strlen(libexecdir)+strlen(DIRSEP_S)+
-		      GPGKEYS_PREFIX_LEN+strlen(scheme)+1);
+		      GPGKEYS_PREFIX_LEN+strlen(scheme)+3+1);
       strcpy(command,libexecdir);
       strcat(command,DIRSEP_S);
     }
@@ -946,8 +946,12 @@
   strcat(command,GPGKEYS_PREFIX); 
   strcat(command,scheme);
 
+  if(keyserver->flags.direct_uri)
+    strcat(command,"uri");
+
 #ifdef GPGKEYS_CURL
-  if(!curl_cant_handle(scheme) && path_access(command,X_OK)!=0)
+  if(!curl_cant_handle(scheme,keyserver->flags.direct_uri)
+     && path_access(command,X_OK)!=0)
     strcpy(end,GPGKEYS_CURL);
 #endif
 
@@ -1018,6 +1022,8 @@
 
 	for(i=0;i<count;i++)
 	  {
+	    int quiet=0;
+
 	    if(desc[i].mode==KEYDB_SEARCH_MODE_FPR20)
 	      {
 		int f;
@@ -1829,10 +1835,22 @@
       spec=parse_keyserver_uri(sl->d,1,NULL,0);
       if(spec)
 	{
-	  int rc=keyserver_work(GET,NULL,&desc,1,spec);
+	  int rc;
+
+	  /*
+	    Set the direct_uri flag so we know later to call a direct
+	    handler instead of the keyserver style.  This lets us use
+	    gpgkeys_curl or gpgkeys_ldapuri instead of gpgkeys_ldap to
+	    fetch things like
+	    ldap://keyserver.pgp.com/o=PGP%20keys?pgpkey?sub?pgpkeyid=99242560
+	  */
+	  spec->flags.direct_uri=1;
+
+	  rc=keyserver_work(GET,NULL,&desc,1,spec);
 	  if(rc)
 	    log_info("WARNING: unable to fetch URI %s: %s\n",
 		     sl->d,g10_errstr(rc));
+
 	  free_keyserver_spec(spec);
 	}
       else

Modified: trunk/g10/options.h
===================================================================
--- trunk/g10/options.h	2005-12-08 05:29:35 UTC (rev 3958)
+++ trunk/g10/options.h	2005-12-08 05:52:41 UTC (rev 3959)
@@ -134,6 +134,10 @@
     char *port;
     char *path;
     char *opaque;
+    struct
+    {
+      unsigned int direct_uri:1;
+    } flags;
   } *keyserver;
   struct
   {




More information about the Gnupg-commits mailing list