2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

Fix -H flag. runas_homedir is only valid after set_perms(PERM_RUNAS, mode)

This commit is contained in:
Todd C. Miller
2000-04-15 20:32:59 +00:00
parent aef6d6ddb7
commit 978e3f8bc0

8
sudo.c
View File

@@ -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);