aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2005-08-21 20:58:46 +0000
committerDavid Shaw <[email protected]>2005-08-21 20:58:46 +0000
commit24adfe678d1e0b26186d65cf4be48b9ed2f215e7 (patch)
tree68bb3d0f4d0d4c64972a843b178cb34ffb446b86 /g10/misc.c
parent* exec.h, exec.c (make_tempdir, expand_args, exec_write, exec_read): (diff)
downloadgnupg-24adfe678d1e0b26186d65cf4be48b9ed2f215e7.tar.gz
gnupg-24adfe678d1e0b26186d65cf4be48b9ed2f215e7.zip
* 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.
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 14848eed2..31348b324 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -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 @@ get_libexecdir (void)
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;
+}