]> granicus.if.org Git - sudo/commitdiff
Fix -H flag. runas_homedir is only valid after set_perms(PERM_RUNAS, mode)
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 15 Apr 2000 20:32:59 +0000 (20:32 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 15 Apr 2000 20:32:59 +0000 (20:32 +0000)
sudo.c

diff --git a/sudo.c b/sudo.c
index 4c2572ecf0745e66a851a029d6b5cb065e650cf6..f36656f174788d0c861bdaa59e7bd154755a6dd8 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -342,10 +342,6 @@ main(argc, argv)
            exit(0);
        }
 
-       /* Set $HOME for `sudo -H' */
-       if ((sudo_mode & MODE_RESET_HOME) && runas_homedir)
-           (void) sudo_setenv("HOME", runas_homedir);
-
        /* This *must* have been set if we got a match but... */
        if (safe_cmnd == NULL) {
            log_error(MSG_ONLY,
@@ -384,6 +380,10 @@ main(argc, argv)
        /* Become specified user or root. */
        set_perms(PERM_RUNAS, sudo_mode);
 
+       /* Set $HOME for `sudo -H'.  Only valid at PERM_RUNAS. */
+       if ((sudo_mode & MODE_RESET_HOME) && runas_homedir)
+           (void) sudo_setenv("HOME", runas_homedir);
+
 #ifndef PROFILING
        if ((sudo_mode & MODE_BACKGROUND) && fork() > 0)
            exit(0);