diff --git a/g10/ChangeLog b/g10/ChangeLog index eb16eba2f..a3ba904a0 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2006-04-26 David Shaw + + * 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 * keyserver.c: Fix build problem with platforms that stick libcurl diff --git a/g10/keyserver.c b/g10/keyserver.c index a4e890c2e..f5044f75c 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -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 @@ parse_keyserver_uri(const char *string,int require_scheme, 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 @@ keyserver_typemap(const char *type) 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 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc, 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 @@ keyserver_fetch(STRLIST urilist) { 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"),