From: Todd C. Miller Date: Mon, 10 Oct 2011 17:13:42 +0000 (-0400) Subject: Ignore set_logname (which is now the default) for sudoedit since X-Git-Tag: SUDO_1_7_8~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2fedf8c9e682e8631ef266e787949539423e3b3;p=sudo Ignore set_logname (which is now the default) for sudoedit since we want the LOGNAME, USER and USERNAME environment variables to refer to the calling user since that is who the editor runs as. This allows the editor to find the user's startup files. Fixes bugzilla #515 --HG-- branch : 1.7 --- diff --git a/env.c b/env.c index 5eb1a2acf..95bd84a81 100644 --- a/env.c +++ b/env.c @@ -765,8 +765,13 @@ rebuild_env(noexec) SET(didvar, DID_PATH); } - /* Set $USER, $LOGNAME and $USERNAME to target if "set_logname" is true. */ - if (def_set_logname && !ISSET(sudo_mode, MODE_LOGIN_SHELL)) { + /* + * Set $USER, $LOGNAME and $USERNAME to target if "set_logname" is not + * disabled. We skip this if we are running a login shell (because + * they have already been set them) or sudoedit (because we want the + * editor to find the user's startup files). + */ + if (def_set_logname && !ISSET(sudo_mode, MODE_LOGIN_SHELL|MODE_EDIT)) { if (!ISSET(didvar, KEPT_LOGNAME)) sudo_setenv("LOGNAME", runas_pw->pw_name, TRUE); if (!ISSET(didvar, KEPT_USER))