]> granicus.if.org Git - sudo/commitdiff
Preserve SHELL variable for "sudo -s". Otherwise we can end up
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 13 Jun 2011 11:21:18 +0000 (07:21 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 13 Jun 2011 11:21:18 +0000 (07:21 -0400)
with a situation where the SHELL variable and the actual shell being
run do not match.

--HG--
branch : 1.7

env.c

diff --git a/env.c b/env.c
index 654565edc36d5da2ebb7ebc53d953f1d27dd4e83..5eb1a2acfa976f0c2515b4f57caaac4f9eb8a222 100644 (file)
--- a/env.c
+++ b/env.c
@@ -568,6 +568,10 @@ matches_env_keep(var)
     size_t len;
     int iswild, keepit = FALSE;
 
+    /* Preserve SHELL variable for "sudo -s". */
+    if (ISSET(sudo_mode, MODE_SHELL) && strncmp(var, "SHELL=", 6) == 0)
+       return TRUE;
+
     for (cur = def_env_keep; cur; cur = cur->next) {
        len = strlen(cur->value);
        /* Deal with '*' wildcard */