version 1.16, 2007/08/01 22:36:04 |
version 1.17, 2008/07/31 16:44:03 |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
__unused static const char rcsid[] = "$Sudo: env.c,v 1.39.2.17 2007/07/31 18:04:31 millert Exp $"; |
__unused static const char rcsid[] = "$Sudo: env.c,v 1.39.2.19 2008/06/21 19:04:07 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
static const char *initial_keepenv_table[] = { |
static const char *initial_keepenv_table[] = { |
"COLORS", |
"COLORS", |
"DISPLAY", |
"DISPLAY", |
|
"HOME", |
"HOSTNAME", |
"HOSTNAME", |
"KRB5CCNAME", |
"KRB5CCNAME", |
"LS_COLORS", |
"LS_COLORS", |
|
|
ps1 = NULL; |
ps1 = NULL; |
didvar = 0; |
didvar = 0; |
memset(&env, 0, sizeof(env)); |
memset(&env, 0, sizeof(env)); |
if (def_env_reset) { |
if (def_env_reset || ISSET(sudo_mode, MODE_LOGIN_SHELL)) { |
/* Pull in vars we want to keep from the old environment. */ |
/* Pull in vars we want to keep from the old environment. */ |
for (ep = envp; *ep; ep++) { |
for (ep = envp; *ep; ep++) { |
int keepit; |
int keepit; |
|
|
#endif |
#endif |
|
|
/* Set $USER, $LOGNAME and $USERNAME to target if "set_logname" is true. */ |
/* Set $USER, $LOGNAME and $USERNAME to target if "set_logname" is true. */ |
|
/* XXX - not needed for MODE_LOGIN_SHELL */ |
if (def_set_logname && runas_pw->pw_name) { |
if (def_set_logname && runas_pw->pw_name) { |
if (!ISSET(didvar, KEPT_LOGNAME)) |
if (!ISSET(didvar, KEPT_LOGNAME)) |
insert_env(format_env("LOGNAME", runas_pw->pw_name, VNULL), &env, 1); |
insert_env(format_env("LOGNAME", runas_pw->pw_name, VNULL), &env, 1); |
|
|
} |
} |
|
|
/* Set $HOME for `sudo -H'. Only valid at PERM_FULL_RUNAS. */ |
/* Set $HOME for `sudo -H'. Only valid at PERM_FULL_RUNAS. */ |
|
/* XXX - not needed for MODE_LOGIN_SHELL */ |
if (runas_pw->pw_dir) { |
if (runas_pw->pw_dir) { |
if (ISSET(sudo_mode, MODE_RESET_HOME) || |
if (ISSET(sudo_mode, MODE_RESET_HOME) || |
(ISSET(sudo_mode, MODE_RUN) && (def_always_set_home || |
(ISSET(sudo_mode, MODE_RUN) && (def_always_set_home || |