int cmnd_status;
int sudo_mode;
int pwflag;
+ char **new_environ;
sigaction_t sa;
extern int printmatches;
extern char **environ;
log_error(NO_MAIL|MSG_ONLY, "no passwd entry for %s!", *user_runas);
}
- /* Customize environment and get rid of any nasty bits. */
- environ = rebuild_env(sudo_mode, envp);
+ /* Build up custom environment that avoids any nasty bits. */
+ new_environ = rebuild_env(sudo_mode, envp);
/* This goes after the sudoers parse since we honor sudoers options. */
if (sudo_mode == MODE_KILL || sudo_mode == MODE_INVALIDATE) {
/* Become specified user or root. */
set_perms(PERM_RUNAS, sudo_mode);
+ /* Install the new environment. */
+ environ = new_environ;
+
#ifndef PROFILING
if ((sudo_mode & MODE_BACKGROUND) && fork() > 0)
exit(0);