mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-02 16:43:03 +01: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:
parent
0ecc2099ac
commit
d0c643a6c5
@ -1,3 +1,11 @@
|
|||||||
|
2002-07-24 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2002-07-23 David Shaw <dshaw@jabberwocky.com>
|
2002-07-23 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* import.c (parse_import_options), export.c
|
* import.c (parse_import_options), export.c
|
||||||
|
30
g10/exec.c
30
g10/exec.c
@ -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_read(struct exec_info *info) { return G10ERR_GENERAL; }
|
||||||
int exec_finish(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 */
|
#else /* ! NO_EXEC */
|
||||||
|
|
||||||
@ -91,13 +91,31 @@ static int win_system(const char *command)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
char *p,*curpath=NULL;
|
||||||
way putenv() works. */
|
size_t curlen=0;
|
||||||
char *p=m_alloc(5+strlen(path)+1);
|
|
||||||
|
if(method==1 && (curpath=getenv("PATH")))
|
||||||
|
curlen=strlen(curpath)+1;
|
||||||
|
|
||||||
|
p=m_alloc(5+curlen+strlen(path)+1);
|
||||||
strcpy(p,"PATH=");
|
strcpy(p,"PATH=");
|
||||||
|
|
||||||
|
if(curpath)
|
||||||
|
{
|
||||||
|
strcat(p,curpath);
|
||||||
|
strcat(p,":");
|
||||||
|
}
|
||||||
|
|
||||||
strcat(p,path);
|
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)
|
if(putenv(p)!=0)
|
||||||
return G10ERR_GENERAL;
|
return G10ERR_GENERAL;
|
||||||
else
|
else
|
||||||
@ -313,7 +331,7 @@ int exec_write(struct exec_info **info,const char *program,
|
|||||||
BUG();
|
BUG();
|
||||||
|
|
||||||
#ifdef FIXED_EXEC_PATH
|
#ifdef FIXED_EXEC_PATH
|
||||||
set_exec_path(FIXED_EXEC_PATH);
|
set_exec_path(FIXED_EXEC_PATH,0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*info=m_alloc_clear(sizeof(struct exec_info));
|
*info=m_alloc_clear(sizeof(struct exec_info));
|
||||||
|
@ -18,6 +18,6 @@ int exec_write(struct exec_info **info,const char *program,
|
|||||||
const char *args_in,const char *name,int writeonly,int binary);
|
const char *args_in,const char *name,int writeonly,int binary);
|
||||||
int exec_read(struct exec_info *info);
|
int exec_read(struct exec_info *info);
|
||||||
int exec_finish(struct exec_info *info);
|
int exec_finish(struct exec_info *info);
|
||||||
int set_exec_path(const char *path);
|
int set_exec_path(const char *path,int method);
|
||||||
|
|
||||||
#endif /* !_EXEC_H_ */
|
#endif /* !_EXEC_H_ */
|
||||||
|
@ -1361,8 +1361,10 @@ main( int argc, char **argv )
|
|||||||
case oTempDir: opt.temp_dir=pargs.r.ret_str; break;
|
case oTempDir: opt.temp_dir=pargs.r.ret_str; break;
|
||||||
case oExecPath:
|
case oExecPath:
|
||||||
#ifndef FIXED_EXEC_PATH
|
#ifndef FIXED_EXEC_PATH
|
||||||
if(set_exec_path(pargs.r.ret_str))
|
if(set_exec_path(pargs.r.ret_str,0))
|
||||||
log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str);
|
log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str);
|
||||||
|
else
|
||||||
|
opt.exec_path_set=1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case oNotation:
|
case oNotation:
|
||||||
|
@ -339,6 +339,11 @@ keyserver_spawn(int action,STRLIST list,
|
|||||||
opt.keyserver_options.use_temp_files=1;
|
opt.keyserver_options.use_temp_files=1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FIXED_EXEC_PATH
|
||||||
|
/* Push the libdir into path */
|
||||||
|
set_exec_path(GNUPG_LIBEXECDIR,opt.exec_path_set);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Build the filename for the helper to execute */
|
/* Build the filename for the helper to execute */
|
||||||
|
|
||||||
command=m_alloc(strlen("gpgkeys_")+strlen(opt.keyserver_scheme)+1);
|
command=m_alloc(strlen("gpgkeys_")+strlen(opt.keyserver_scheme)+1);
|
||||||
|
@ -133,6 +133,7 @@ struct {
|
|||||||
STRLIST other;
|
STRLIST other;
|
||||||
} keyserver_options;
|
} keyserver_options;
|
||||||
int exec_disable;
|
int exec_disable;
|
||||||
|
int exec_path_set;
|
||||||
unsigned int import_options;
|
unsigned int import_options;
|
||||||
unsigned int export_options;
|
unsigned int export_options;
|
||||||
char *def_preference_list;
|
char *def_preference_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user