[svn] GnuPG - r3871 - trunk/g10
svn author dshaw
cvs at cvs.gnupg.org
Sun Aug 21 22:58:48 CEST 2005
Author: dshaw
Date: 2005-08-21 22:58:46 +0200 (Sun, 21 Aug 2005)
New Revision: 3871
Modified:
trunk/g10/ChangeLog
trunk/g10/Makefile.am
trunk/g10/keyserver.c
trunk/g10/main.h
trunk/g10/misc.c
Log:
* Makefile.am: No need to link with curl any longer.
* main.h, misc.c (path_access): New. Same as access() but does a PATH
search like execlp.
* keyserver.c (curl_can_handle): Removed. Replaced by...
(curl_cant_handle): We are now relying on curl as the handler of last
resort. This is necessary because PGP LDAP and curl LDAP are apples
and oranges. (keyserver_typemap): Only test for ldap and ldaps.
(keyserver_spawn): If a given handler is unusable (as determined by
path_access()) then try gpgkeys_curl.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2005-08-21 14:20:27 UTC (rev 3870)
+++ trunk/g10/ChangeLog 2005-08-21 20:58:46 UTC (rev 3871)
@@ -1,5 +1,18 @@
2005-08-21 David Shaw <dshaw at jabberwocky.com>
+ * Makefile.am: No need to link with curl any longer.
+
+ * main.h, misc.c (path_access): New. Same as access() but does a
+ PATH search like execlp.
+
+ * keyserver.c (curl_can_handle): Removed. Replaced by...
+ (curl_cant_handle): We are now relying on curl as the handler of
+ last resort. This is necessary because PGP LDAP and curl LDAP are
+ apples and oranges.
+ (keyserver_typemap): Only test for ldap and ldaps.
+ (keyserver_spawn): If a given handler is unusable (as determined
+ by path_access()) then try gpgkeys_curl.
+
* exec.h, exec.c (make_tempdir, expand_args, exec_write,
exec_read): Minor cleanup to use bitfield flags instead of a bunch
of integers.
Modified: trunk/g10/Makefile.am
===================================================================
--- trunk/g10/Makefile.am 2005-08-21 14:20:27 UTC (rev 3870)
+++ trunk/g10/Makefile.am 2005-08-21 20:58:46 UTC (rev 3871)
@@ -124,8 +124,7 @@
verify.c
LDADD = $(needed_libs) $(other_libs) @ZLIBS@ @W32LIBS@ @LIBREADLINE@
-gpg_LDADD = $(LDADD) @DLLIBS@ @NETLIBS@ @LIBUSB@ @LIBCURL@
-##gpg_CPPFLAGS = @LIBCURL_CPPFLAGS@
+gpg_LDADD = $(LDADD) @DLLIBS@ @NETLIBS@ @LIBUSB@
$(PROGRAMS): $(needed_libs)
Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c 2005-08-21 14:20:27 UTC (rev 3870)
+++ trunk/g10/keyserver.c 2005-08-21 20:58:46 UTC (rev 3871)
@@ -49,6 +49,16 @@
#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;
@@ -830,47 +840,29 @@
xfree(line);
}
-static int
-curl_can_handle(const char *scheme)
-{
-#if defined(HAVE_LIBCURL)
-
- const char * const *proto;
- curl_version_info_data *data=curl_version_info(CURLVERSION_NOW);
-
- assert(data);
-
- for(proto=data->protocols;*proto;proto++)
- if(strcasecmp(*proto,scheme)==0)
- return 1;
-
-#elif defined(FAKE_CURL)
-
- /* If we're faking curl, then we only support HTTP */
- if(strcasecmp(scheme,"http")==0)
- return 1;
-
-#endif
-
- return 0;
-}
-
/* We sometimes want to use a different gpgkeys_xxx for a given
protocol (for example, ldaps is handled by gpgkeys_ldap). Map
these here. */
static const char *
keyserver_typemap(const char *type)
{
- if(strcmp(type,"ldap")==0)
+ if(strcmp(type,"ldaps")==0)
return "ldap";
- else if(strcmp(type,"ldaps")==0)
- return "ldap";
- else if(curl_can_handle(type))
- return "curl";
else
return type;
}
+#ifdef GPGKEYS_CURL
+static int
+curl_cant_handle(const char *scheme)
+{
+ if(strcmp(scheme,"ldap")==0 || strcmp(scheme,"ldaps")==0)
+ return 1;
+
+ return 0;
+}
+#endif
+
#define KEYSERVER_ARGS_KEEP " -o \"%O\" \"%I\""
#define KEYSERVER_ARGS_NOKEEP " -o \"%o\" \"%i\""
@@ -881,7 +873,7 @@
int ret=0,i,gotversion=0,outofband=0;
STRLIST temp;
unsigned int maxlen,buflen;
- char *command,*searchstr=NULL;
+ char *command,*end,*searchstr=NULL;
byte *line=NULL;
struct parse_options *kopts;
struct exec_info *spawn;
@@ -923,7 +915,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(strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
+ command=xmalloc(GPGKEYS_PREFIX_LEN+strlen(scheme)+1);
command[0]='\0';
}
else
@@ -931,14 +923,21 @@
{
/* Specify a full path to gpgkeys_foo. */
command=xmalloc(strlen(libexecdir)+strlen(DIRSEP_S)+
- strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
+ GPGKEYS_PREFIX_LEN+strlen(scheme)+1);
strcpy(command,libexecdir);
strcat(command,DIRSEP_S);
}
+ end=command+strlen(command);
+
strcat(command,GPGKEYS_PREFIX);
strcat(command,scheme);
+#ifdef GPGKEYS_CURL
+ if(!curl_cant_handle(scheme) && path_access(command,X_OK)!=0)
+ strcpy(end,GPGKEYS_CURL);
+#endif
+
if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
{
if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
Modified: trunk/g10/main.h
===================================================================
--- trunk/g10/main.h 2005-08-21 14:20:27 UTC (rev 3870)
+++ trunk/g10/main.h 2005-08-21 20:58:46 UTC (rev 3871)
@@ -129,8 +129,8 @@
int is_valid_mailbox (const char *name);
char *default_homedir (void);
const char *get_libexecdir (void);
+int path_access(const char *file,int mode);
-
/*-- helptext.c --*/
void display_online_help( const char *keyword );
Modified: trunk/g10/misc.c
===================================================================
--- trunk/g10/misc.c 2005-08-21 14:20:27 UTC (rev 3870)
+++ trunk/g10/misc.c 2005-08-21 20:58:46 UTC (rev 3871)
@@ -1,6 +1,6 @@
/* misc.c - miscellaneous functions
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- * 2004, 2005 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ * 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -1223,3 +1223,38 @@
return GNUPG_LIBEXECDIR;
}
+
+int
+path_access(const char *file,int mode)
+{
+ char *envpath;
+ int ret=-1;
+
+ envpath=getenv("PATH");
+
+ if(file[0]=='/' || !envpath)
+ return access(file,mode);
+ else
+ {
+ /* At least as large as, but most often larger than we need. */
+ char *buffer=xmalloc(strlen(envpath)+1+strlen(file)+1);
+ char *split,*item,*path=xstrdup(envpath);
+
+ split=path;
+
+ while((item=strsep(&split,PATHSEP_S)))
+ {
+ strcpy(buffer,item);
+ strcat(buffer,"/");
+ strcat(buffer,file);
+ ret=access(buffer,mode);
+ if(ret==0)
+ break;
+ }
+
+ xfree(path);
+ xfree(buffer);
+ }
+
+ return ret;
+}
More information about the Gnupg-commits
mailing list