From 1d051e8ed5c6c869587b12ba05e552da1f3bc97c Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 8 Dec 2005 05:52:41 +0000 Subject: [PATCH] * 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. --- g10/ChangeLog | 7 +++++++ g10/keyserver.c | 32 +++++++++++++++++++++++++------- g10/options.h | 4 ++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index b1154458b..1aad49789 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,10 @@ +2005-12-08 David Shaw + + * 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 * keyserver.c (keyserver_spawn): Don't print "searching for key diff --git a/g10/keyserver.c b/g10/keyserver.c index 69391ec82..47c03c97b 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -867,9 +867,9 @@ keyserver_typemap(const char *type) /* 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 @@ static int 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 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc, /* 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 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc, { /* 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 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc, 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 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc, for(i=0;id,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 diff --git a/g10/options.h b/g10/options.h index ade26dcc4..57f225c6b 100644 --- a/g10/options.h +++ b/g10/options.h @@ -134,6 +134,10 @@ struct char *port; char *path; char *opaque; + struct + { + unsigned int direct_uri:1; + } flags; } *keyserver; struct {