]> granicus.if.org Git - sudo/commitdiff
added runas_homedir
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 25 Aug 1996 17:27:36 +0000 (17:27 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 25 Aug 1996 17:27:36 +0000 (17:27 +0000)
sudo.c

diff --git a/sudo.c b/sudo.c
index d298f0f4efc825e185c633a42e38b12d744f0360..3897c21f44021e0db4343a3e891601df594dc467 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -150,6 +150,7 @@ char host[MAXHOSTNAMELEN + 1];
 char *shost;
 char cwd[MAXPATHLEN + 1];
 struct stat cmnd_st;
+static char *runas_homedir = NULL;
 extern struct interface *interfaces;
 extern int num_interfaces;
 extern int printmatches;
@@ -322,6 +323,11 @@ int main(argc, argv)
 
            /* become specified user or root */
            set_perms(PERM_RUNAS);
+
+           /* set $HOME for `sudo -s' */
+           if ((sudo_mode & MODE_SHELL) && runas_homedir)
+               (void) sudo_setenv("HOME", runas_homedir);
+
 #ifndef PROFILING
            if ((sudo_mode & MODE_BACKGROUND) && fork() > 0) {
                exit(0);
@@ -896,7 +902,7 @@ void set_perms(perm)
                                        exit(1);
                                    }
 
-                                   (void) sudo_setenv("HOME", pw_ent->pw_dir);
+                                   runas_homedir = pw_ent->pw_dir;
                                }
 
                                break;