diff --git a/g10/ChangeLog b/g10/ChangeLog index d01bbc8f5..aaf842d35 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2005-03-31 David Shaw + + * exec.h, exec.c (set_exec_path): Remove some dead code and change + all callers. We no longer need to append to $PATH. + 2005-03-31 Werner Koch * keydb.c (keydb_add_resource): Clarify meaning of flags. Add new diff --git a/g10/exec.c b/g10/exec.c index 0ba85a564..e9c9554f7 100644 --- a/g10/exec.c +++ b/g10/exec.c @@ -1,5 +1,5 @@ /* exec.c - generic call-a-program code - * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -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,int method) { return G10ERR_GENERAL; } +int set_exec_path(const char *path) { return G10ERR_GENERAL; } #else /* ! NO_EXEC */ @@ -91,29 +91,17 @@ static int win_system(const char *command) } #endif -/* method==0 to replace current $PATH, and 1 to append to current - $PATH. */ -int set_exec_path(const char *path,int method) +/* Replaces current $PATH */ +int set_exec_path(const char *path) { - char *p,*curpath=NULL; - size_t curlen=0; + char *p; - if(method==1 && (curpath=getenv("PATH"))) - curlen=strlen(curpath)+1; - - p=m_alloc(5+curlen+strlen(path)+1); + p=m_alloc(5+strlen(path)+1); strcpy(p,"PATH="); - - if(curpath) - { - strcat(p,curpath); - strcat(p,":"); - } - strcat(p,path); if(DBG_EXTPROG) - log_debug("set_exec_path method %d: %s\n",method,p); + log_debug("set_exec_path: %s\n",p); /* Notice that path is never freed. That is intentional due to the way putenv() works. This leaks a few bytes if we call diff --git a/g10/exec.h b/g10/exec.h index 25369dc34..81e578bc6 100644 --- a/g10/exec.h +++ b/g10/exec.h @@ -1,5 +1,5 @@ /* exec.h - * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -38,6 +38,6 @@ int exec_write(struct exec_info **info,const char *program, const char *args_in,const char *name,int writeonly,int binary); int exec_read(struct exec_info *info); int exec_finish(struct exec_info *info); -int set_exec_path(const char *path,int method); +int set_exec_path(const char *path); #endif /* !_EXEC_H_ */ diff --git a/g10/g10.c b/g10/g10.c index 12362172b..79a1e2008 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -2379,7 +2379,7 @@ main( int argc, char **argv ) break; case oTempDir: opt.temp_dir=pargs.r.ret_str; break; case oExecPath: - if(set_exec_path(pargs.r.ret_str,0)) + if(set_exec_path(pargs.r.ret_str)) log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str); else opt.exec_path_set=1; diff --git a/g10/keyserver.c b/g10/keyserver.c index 19786c770..d52c95f0e 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -876,7 +876,7 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc, 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(GNUPG_LIBEXECDIR,0); + set_exec_path(GNUPG_LIBEXECDIR); #else if(opt.exec_path_set) {