]> granicus.if.org Git - sudo/commitdiff
Deal with systems that have no way of setting the effective uid such as
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 27 May 2004 23:12:02 +0000 (23:12 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 27 May 2004 23:12:02 +0000 (23:12 +0000)
nsr-tandem-nsk.

set_perms.c

index 916d5d86093a2d2a079d84085746d413cab31509..2839fdd3aa6ba7d55366c0c46a62e01e8eb5f182 100644 (file)
@@ -306,6 +306,7 @@ set_perms_suid(perm)
 }
 
 # else
+#  ifdef HAVE_SETREUID
 
 /*
  * Set real and effective uids and gids based on perm.
@@ -375,6 +376,47 @@ set_perms_nosuid(perm)
                                break;
     }
 }
+
+#  else
+
+/*
+ * Set uids and gids based on perm via setuid() and setgid().
+ * NOTE: does not support the "stay_setuid" or timestampowner options.
+ *       Also, SUDOERS_UID and SUDOERS_GID are not used.
+ */
+void
+set_perms_nosuid(perm)
+    int perm;
+{
+
+    switch (perm) {
+       case PERM_FULL_ROOT:
+       case PERM_ROOT:
+                               if (setuid(ROOT_UID))
+                                       fatal("setuid(ROOT_UID)", 1);
+                               break;
+
+       case PERM_FULL_USER:
+                               (void) setgid(user_gid);
+                               if (setuid(user_uid))
+                                   fatal("setuid(user_uid)", 1);
+                               break;
+                               
+       case PERM_FULL_RUNAS:
+                               runas_setup();
+                               if (setuid(runas_pw->pw_uid))
+                                   fatal("unable to change to runas uid", 1);
+                               break;
+
+       case PERM_USER:
+       case PERM_SUDOERS:
+       case PERM_RUNAS:
+       case PERM_TIMESTAMP:
+                               /* Unsupported since we can't set euid. */
+                               break;
+    }
+}
+#  endif /* HAVE_SETEUID */
 # endif /* HAVE_SETREUID */
 #endif /* HAVE_SETRESUID */