From 27c2a3d1589c4122787d6a3699b47388b1208744 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 9 Sep 2015 10:45:56 -0600 Subject: [PATCH] Fix running commands as non-root when neither setresuid() not setreuid() are available. At this point we are already root so setuid() must succeed. Bug #713 --- src/sudo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sudo.c b/src/sudo.c index 7dd76b2cd..64fd65787 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -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 */ -- 2.40.0