diff options
author | David Shaw <dshaw@jabberwocky.com> | 2002-07-03 06:01:21 +0200 |
---|---|---|
committer | David Shaw <dshaw@jabberwocky.com> | 2002-07-03 06:01:21 +0200 |
commit | bccb780228121a6ade6b08aecc50449455d9d1aa (patch) | |
tree | 8ebce5ee3f47f9a7fc1948e0622c7caf6111f4bc /g10/exec.c | |
parent | * options.h, g10.c (main), keyserver.c (keyserver_refresh): Maintain and (diff) | |
download | gnupg2-bccb780228121a6ade6b08aecc50449455d9d1aa.tar.xz gnupg2-bccb780228121a6ade6b08aecc50449455d9d1aa.zip |
* exec.h, exec.c (set_exec_path, exec_write), g10.c (main): If
USE_EXEC_PATH is defined at compile time, use it to lock the exec-path and
not allow the user to change it.
Diffstat (limited to 'g10/exec.c')
-rw-r--r-- | g10/exec.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/g10/exec.c b/g10/exec.c index 893718ad1..cfdf6d057 100644 --- a/g10/exec.c +++ b/g10/exec.c @@ -51,6 +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; } #else /* ! NO_EXEC */ @@ -90,6 +91,19 @@ static int win_system(const char *command) } #endif +int set_exec_path(const char *path) +{ + /* Notice that path is never freed. That is intentional due to the + way putenv() works. */ + char *p=m_alloc(5+strlen(path)+1); + strcpy(p,"PATH="); + strcat(p,path); + if(putenv(p)!=0) + return G10ERR_GENERAL; + else + return 0; +} + /* Makes a temp directory and filenames */ static int make_tempdir(struct exec_info *info) { @@ -298,6 +312,10 @@ int exec_write(struct exec_info **info,const char *program, if(program==NULL && args_in==NULL) BUG(); +#ifdef USE_EXEC_PATH + set_exec_path(USE_EXEC_PATH); +#endif + *info=m_alloc_clear(sizeof(struct exec_info)); if(name) |