[svn] GnuPG - r4126 - trunk/g10

svn author dshaw cvs at cvs.gnupg.org
Thu Apr 27 05:14:19 CEST 2006


Author: dshaw
Date: 2006-04-27 05:14:17 +0200 (Thu, 27 Apr 2006)
New Revision: 4126

Modified:
   trunk/g10/ChangeLog
   trunk/g10/keyserver.c
Log:
* keyserver.c (path_makes_direct): New.  (keyserver_spawn): Used here
to add "_uri" to certain gpgkeys_xxx helpers when the meaning is
different if a path is provided (i.e. ldap).


Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2006-04-26 21:49:43 UTC (rev 4125)
+++ trunk/g10/ChangeLog	2006-04-27 03:14:17 UTC (rev 4126)
@@ -1,3 +1,10 @@
+2006-04-26  David Shaw  <dshaw at jabberwocky.com>
+
+	* keyserver.c (path_makes_direct): New.
+	(keyserver_spawn): Used here to add "_uri" to certain gpgkeys_xxx
+	helpers when the meaning is different if a path is provided
+	(i.e. ldap).
+
 2006-04-22  David Shaw  <dshaw at jabberwocky.com>
 
 	* keyserver.c: Fix build problem with platforms that stick libcurl

Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c	2006-04-26 21:49:43 UTC (rev 4125)
+++ trunk/g10/keyserver.c	2006-04-27 03:14:17 UTC (rev 4126)
@@ -41,18 +41,6 @@
 #include "keyserver-internal.h"
 #include "util.h"
 
-#define GPGKEYS_PREFIX "gpgkeys_"
-
-#if defined(HAVE_LIBCURL) || defined(FAKE_CURL)
-#define GPGKEYS_CURL "gpgkeys_curl"
-#endif
-
-#ifdef GPGKEYS_CURL
-#define GPGKEYS_PREFIX_LEN (strlen(GPGKEYS_PREFIX)+strlen(GPGKEYS_CURL))
-#else
-#define GPGKEYS_PREFIX_LEN (strlen(GPGKEYS_PREFIX))
-#endif
-
 struct keyrec
 {
   KEYDB_SEARCH_DESC desc;
@@ -415,7 +403,7 @@
       else
 	keyserver->path=xstrdup("/");
 
-      if(keyserver->path[1]!='\0')
+      if(keyserver->path[1])
 	keyserver->flags.direct_uri=1;
     }
   else if(uri[0]!='/')
@@ -937,19 +925,20 @@
     return type;
 }
 
-#ifdef GPGKEYS_CURL
 /* 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,unsigned int direct_uri)
+direct_uri_map(const char *scheme,unsigned int is_direct)
 {
-  if(!direct_uri && (strcmp(scheme,"ldap")==0 || strcmp(scheme,"ldaps")==0))
+  if(is_direct && strcmp(scheme,"ldap")==0)
     return 1;
 
   return 0;
 }
-#endif
 
+#define GPGKEYS_PREFIX "gpgkeys_"
+#define GPGKEYS_CURL GPGKEYS_PREFIX "curl" EXEEXT
+#define GPGKEYS_PREFIX_LEN (strlen(GPGKEYS_CURL))
 #define KEYSERVER_ARGS_KEEP " -o \"%O\" \"%I\""
 #define KEYSERVER_ARGS_NOKEEP " -o \"%o\" \"%i\""
 
@@ -1017,19 +1006,29 @@
 
   end=command+strlen(command);
 
+  /* Build a path for the keyserver helper.  If it is direct_uri
+     (i.e. an object fetch and not a keyserver), then add "_uri" to
+     the end to distinguish the keyserver helper from an object
+     fetcher that can speak that protocol (this is a problem for
+     LDAP). */
+
   strcat(command,GPGKEYS_PREFIX); 
   strcat(command,scheme);
 
-  if(keyserver->flags.direct_uri)
-    strcat(command,"uri");
+  /* This "_uri" thing is in case we need to call a direct handler
+     instead of the keyserver handler.  This lets us use gpgkeys_curl
+     or gpgkeys_ldap_uri (we don't provide it, but a user might)
+     instead of gpgkeys_ldap to fetch things like
+     ldap://keyserver.pgp.com/o=PGP%20keys?pgpkey?sub?pgpkeyid=99242560 */
 
+  if(direct_uri_map(scheme,keyserver->flags.direct_uri))
+    strcat(command,"_uri");
+
   strcat(command,EXEEXT);
 
-#ifdef GPGKEYS_CURL
-  if(!curl_cant_handle(scheme,keyserver->flags.direct_uri)
-     && path_access(command,X_OK)!=0)
+  /* Can we execute it?  If not, try curl as our catchall. */
+  if(path_access(command,X_OK)!=0)
     strcpy(end,GPGKEYS_CURL);
-#endif
 
   if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
     {
@@ -1946,15 +1945,6 @@
 	{
 	  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(KS_GET,NULL,&desc,1,NULL,NULL,spec);
 	  if(rc)
 	    log_info (_("WARNING: unable to fetch URI %s: %s\n"),




More information about the Gnupg-commits mailing list