The PATH problem (was Re: Libcurl)
David Shaw
dshaw at jabberwocky.com
Fri Mar 25 05:50:12 CET 2005
On Wed, Mar 23, 2005 at 06:24:57PM +0100, Carlo Luciano Bianco wrote:
> Maybe it is possible to run the keyserver helpers not just by their
> name, but by their *entire* name: instead of running
> "gpgkeys_xxx.exe", gpg.exe should run
> "c:\programmi\gnupg\gpgkeys_xxx.exe". In other words, instead of
> putting its own folder in the PATH, gpg.exe should put its own
> folder in front of the name of the keyserver helper to be executed.
>
> In this way you should be pretty sure that you execute the right
> file, and you can keep the system PATH as it is. But maybe it is not
> so simple...
That is basically the plan. The only (not very) complex thing is that
it needs to take into account --exec-path as well as the configure
option --disable-keyserver-path, and the various combinations of those
options or lack thereof.
Can you try this patch?
David
-------------- next part --------------
Index: keyserver.c
===================================================================
RCS file: /cvs/gnupg/gnupg/g10/keyserver.c,v
retrieving revision 1.82
diff -u -r1.82 keyserver.c
--- keyserver.c 17 Mar 2005 22:55:17 -0000 1.82
+++ keyserver.c 25 Mar 2005 04:42:35 -0000
@@ -860,20 +860,39 @@
opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
#endif
- /* Push the libexecdir into path. If DISABLE_KEYSERVER_PATH is set,
- use the 0 arg to replace the path. */
+ /* Build the filename for the helper to execute */
+ scheme=keyserver_typemap(keyserver->scheme);
+
#ifdef DISABLE_KEYSERVER_PATH
- set_exec_path(GNUPG_LIBEXECDIR,0);
+ /* Destroy any path we might have. Note that this sets PATH to an
+ empty string, rather than deleting the PATH environment variable.
+ That's intentional, so we don't fall back to a system built-in
+ PATH. This is not that meaningful on Unix-like systems (since
+ we're going to give a full path to gpgkeys_foo), but on W32 it
+ prevents loading any DLLs from directories in %PATH%. */
+ set_exec_path("",0);
#else
- set_exec_path(GNUPG_LIBEXECDIR,opt.exec_path_set);
+ if(opt.exec_path_set)
+ {
+ /* 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=m_alloc(strlen("gpgkeys_")+strlen(scheme)+1);
+ command[0]='\0';
+ }
+ else
#endif
+ {
+ /* Specify a full path to gpgkeys_foo. */
+ command=m_alloc(strlen(GNUPG_LIBEXECDIR)+1+
+ strlen("gpgkeys_")+strlen(scheme)+1);
+ strcpy(command,GNUPG_LIBEXECDIR);
+ strcat(command,"/");
+ }
- /* Build the filename for the helper to execute */
- scheme=keyserver_typemap(keyserver->scheme);
- command=m_alloc(strlen("gpgkeys_")+strlen(scheme)+1);
- strcpy(command,"gpgkeys_");
+ strcat(command,"gpgkeys_");
strcat(command,scheme);
-
+
if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
{
if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
More information about the Gnupg-users
mailing list