1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* options.h, exec.h, exec.c (set_exec_path, exec_write), g10.c (main),

keyserver.c (keyserver_spawn): If the user does not use "exec-path",
completely replace $PATH with GNUPG_LIBEXECDIR before calling the
keyserver helper.  If the user does use "exec-path", append
GNUPG_LIBEXECDIR after the specified path.
This commit is contained in:
David Shaw 2002-07-24 19:24:08 +00:00
parent 0ecc2099ac
commit d0c643a6c5
6 changed files with 42 additions and 8 deletions

View file

@ -51,7 +51,7 @@ int exec_write(struct exec_info **info,const char *program,
int exec_read(struct exec_info *info) { return G10ERR_GENERAL; }
int exec_finish(struct exec_info *info) { return G10ERR_GENERAL; }
int set_exec_path(const char *path) { return G10ERR_GENERAL; }
int set_exec_path(const char *path,int method) { return G10ERR_GENERAL; }
#else /* ! NO_EXEC */
@ -91,13 +91,31 @@ static int win_system(const char *command)
}
#endif
int set_exec_path(const char *path)
/* method==0 to replace current $PATH, and 1 to append to current
$PATH. */
int set_exec_path(const char *path,int method)
{
/* Notice that path is never freed. That is intentional due to the
way putenv() works. */
char *p=m_alloc(5+strlen(path)+1);
char *p,*curpath=NULL;
size_t curlen=0;
if(method==1 && (curpath=getenv("PATH")))
curlen=strlen(curpath)+1;
p=m_alloc(5+curlen+strlen(path)+1);
strcpy(p,"PATH=");
if(curpath)
{
strcat(p,curpath);
strcat(p,":");
}
strcat(p,path);
/* Notice that path is never freed. That is intentional due to the
way putenv() works. This leaks a few bytes if we call
set_exec_path multiple times. */
if(putenv(p)!=0)
return G10ERR_GENERAL;
else
@ -313,7 +331,7 @@ int exec_write(struct exec_info **info,const char *program,
BUG();
#ifdef FIXED_EXEC_PATH
set_exec_path(FIXED_EXEC_PATH);
set_exec_path(FIXED_EXEC_PATH,0);
#endif
*info=m_alloc_clear(sizeof(struct exec_info));