]> granicus.if.org Git - sudo/commitdiff
Fix running commands as non-root when neither setresuid() not
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 9 Sep 2015 16:45:56 +0000 (10:45 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 9 Sep 2015 16:45:56 +0000 (10:45 -0600)
setreuid() are available.  At this point we are already root so
setuid() must succeed.  Bug #713

src/sudo.c

index 7dd76b2cddbedbc2aab2fb0ce1b2648a060617b3..64fd65787b50b44e0781808e787840f0a98a60fa 100644 (file)
@@ -1028,9 +1028,10 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
        goto done;
     }
 #else
-    if (seteuid(details->euid) != 0 || setuid(details->euid) != 0) {
+    /* Cannot support real user ID that is different from effective user ID. */
+    if (setuid(details->euid) != 0) {
        sudo_warn(U_("unable to change to runas uid (%u, %u)"),
-           (unsigned int)details->uid, (unsigned int)details->euid);
+           (unsigned int)details->euid, (unsigned int)details->euid);
        goto done;
     }
 #endif /* !HAVE_SETRESUID && !HAVE_SETREUID */