]> granicus.if.org Git - sudo/commitdiff
Ignore set_logname (which is now the default) for sudoedit since
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 10 Oct 2011 17:13:42 +0000 (13:13 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 10 Oct 2011 17:13:42 +0000 (13:13 -0400)
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

env.c

diff --git a/env.c b/env.c
index 5eb1a2acfa976f0c2515b4f57caaac4f9eb8a222..95bd84a81efc4c695c7813428691694d95dab790 100644 (file)
--- 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))