]> granicus.if.org Git - sudo/commitdiff
do the set_perms(PERM_USER, sudo_mode) after we have gotten the passwd entry
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 23 Nov 1997 06:51:49 +0000 (06:51 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 23 Nov 1997 06:51:49 +0000 (06:51 +0000)
sudo.c

diff --git a/sudo.c b/sudo.c
index 7bfeffc43e704f7ab2d5a9f0eb7da3f0117c703d..ac3d2ae58223c160ecfd0103ecfd4467a813d6e5 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -405,10 +405,7 @@ static void load_globals(sudo_mode)
      * if necesary.  It is assumed that euid is 0 at this point so we
      * can read the shadow passwd file if necesary.
      */
-    user_pw_ent = sudo_getpwuid(getuid());
-    set_perms(PERM_ROOT, sudo_mode);
-    set_perms(PERM_USER, sudo_mode);
-    if (user_pw_ent == NULL) {
+    if ((user_pw_ent = sudo_getpwuid(getuid())) == NULL) {
        /* need to make a fake user_pw_ent */
        struct passwd pw_ent;
        char pw_name[MAX_UID_T_LEN+1];
@@ -425,6 +422,10 @@ static void load_globals(sudo_mode)
        exit(1);
     }
 
+    /* Set euid == user and ruid == root */
+    set_perms(PERM_ROOT, sudo_mode);
+    set_perms(PERM_USER, sudo_mode);
+
 #ifdef HAVE_TZSET
     (void) tzset();            /* set the timezone if applicable */
 #endif /* HAVE_TZSET */