Clean up environment after executing scripts.
This commit is contained in:
parent
9e44f116bf
commit
e5e0dd7534
1 changed files with 10 additions and 3 deletions
|
@ -363,6 +363,7 @@ bool execute_script(const char *name, char **envp)
|
||||||
int status, len;
|
int status, len;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
char *scriptname;
|
char *scriptname;
|
||||||
|
int i;
|
||||||
|
|
||||||
cp();
|
cp();
|
||||||
|
|
||||||
|
@ -386,8 +387,8 @@ bool execute_script(const char *name, char **envp)
|
||||||
#ifdef HAVE_PUTENV
|
#ifdef HAVE_PUTENV
|
||||||
/* Set environment */
|
/* Set environment */
|
||||||
|
|
||||||
while(*envp)
|
for(i = 0; envp[i]; i++)
|
||||||
putenv(*envp++);
|
putenv(envp[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
scriptname[len - 1] = '\"';
|
scriptname[len - 1] = '\"';
|
||||||
|
@ -395,7 +396,13 @@ bool execute_script(const char *name, char **envp)
|
||||||
|
|
||||||
free(scriptname);
|
free(scriptname);
|
||||||
|
|
||||||
/* Unset environment? */
|
/* Unset environment */
|
||||||
|
|
||||||
|
for(i = 0; envp[i]; i++) {
|
||||||
|
char *e = strchr(envp[i], '=');
|
||||||
|
if(e)
|
||||||
|
putenv(strndupa(envp[i], e - envp[i]));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WEXITSTATUS
|
#ifdef WEXITSTATUS
|
||||||
if(status != -1) {
|
if(status != -1) {
|
||||||
|
|
Loading…
Reference in a new issue