mirror of
git://git.gnupg.org/gnupg.git
synced 2024-05-31 22:18:03 +02:00
* 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.
This commit is contained in:
parent
c6feade425
commit
bccb780228
|
@ -1,3 +1,9 @@
|
||||||
|
2002-07-03 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
2002-07-02 David Shaw <dshaw@jabberwocky.com>
|
2002-07-02 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* options.h, g10.c (main), keyserver.c (keyserver_refresh):
|
* options.h, g10.c (main), keyserver.c (keyserver_refresh):
|
||||||
|
|
18
g10/exec.c
18
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_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; }
|
||||||
|
|
||||||
#else /* ! NO_EXEC */
|
#else /* ! NO_EXEC */
|
||||||
|
|
||||||
|
@ -90,6 +91,19 @@ static int win_system(const char *command)
|
||||||
}
|
}
|
||||||
#endif
|
#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 */
|
/* Makes a temp directory and filenames */
|
||||||
static int make_tempdir(struct exec_info *info)
|
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)
|
if(program==NULL && args_in==NULL)
|
||||||
BUG();
|
BUG();
|
||||||
|
|
||||||
|
#ifdef USE_EXEC_PATH
|
||||||
|
set_exec_path(USE_EXEC_PATH);
|
||||||
|
#endif
|
||||||
|
|
||||||
*info=m_alloc_clear(sizeof(struct exec_info));
|
*info=m_alloc_clear(sizeof(struct exec_info));
|
||||||
|
|
||||||
if(name)
|
if(name)
|
||||||
|
|
|
@ -18,5 +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);
|
||||||
|
|
||||||
#endif /* !_EXEC_H_ */
|
#endif /* !_EXEC_H_ */
|
||||||
|
|
14
g10/g10.c
14
g10/g10.c
|
@ -46,6 +46,7 @@
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
#include "g10defs.h"
|
#include "g10defs.h"
|
||||||
#include "keyserver-internal.h"
|
#include "keyserver-internal.h"
|
||||||
|
#include "exec.h"
|
||||||
|
|
||||||
enum cmd_and_opt_values { aNull = 0,
|
enum cmd_and_opt_values { aNull = 0,
|
||||||
oArmor = 'a',
|
oArmor = 'a',
|
||||||
|
@ -1331,15 +1332,10 @@ main( int argc, char **argv )
|
||||||
break;
|
break;
|
||||||
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 USE_EXEC_PATH
|
||||||
/* Notice that path is never freed. That is
|
if(set_exec_path(pargs.r.ret_str))
|
||||||
intentional due to the way putenv() works. */
|
log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str);
|
||||||
char *path=m_alloc(5+strlen(pargs.r.ret_str)+1);
|
#endif
|
||||||
strcpy(path,"PATH=");
|
|
||||||
strcat(path,pargs.r.ret_str);
|
|
||||||
if(putenv(path)!=0)
|
|
||||||
log_error(_("unable to set exec-path to %s\n"),path);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case oNotation:
|
case oNotation:
|
||||||
add_notation_data( pargs.r.ret_str, 0 );
|
add_notation_data( pargs.r.ret_str, 0 );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user