]> granicus.if.org Git - sudo/commitdiff
For PERM_ROOT when using setreuid(), only set the euid to 0 prior
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Feb 2012 18:29:19 +0000 (13:29 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Feb 2012 18:29:19 +0000 (13:29 -0500)
to the call to setuid(0) if the current euid is non-zero.  This
effectively restores the state of things prior to rev 7bfeb629fccb.
Fixes a problem on AIX where LDR_PRELOAD was not being honored for
the command being executed.

plugins/sudoers/set_perms.c

index 53c48dd3e9c0bbd93b39a38b596078ba548c3eb9..31e7f5f22275243185b9fa663d5d05c2035711ec 100644 (file)
@@ -392,12 +392,13 @@ set_perms(int perm)
 
     case PERM_ROOT:
        /*
-        * setreuid(0, 0) may fail on some systems
-        * when the euid is not already 0.
+        * setuid(0) may fail on some systems if the euid is not already 0.
         */
-       if (setreuid(-1, ROOT_UID)) {
-           errstr = "setreuid(-1, ROOT_UID)";
-           goto bad;
+       if (ostate->euid != ROOT_UID) {
+           if (setreuid(-1, ROOT_UID)) {
+               errstr = "setreuid(-1, ROOT_UID)";
+               goto bad;
+           }
        }
        if (setuid(ROOT_UID)) {
            errstr = "setuid(ROOT_UID)";