summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-16 02:46:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-16 02:46:10 +0000
commitac815e97ba31eafecbdcc54f8ef975439dc64dc7 (patch)
tree246e9bccdedc9c5b323b225c1f3e60eb30995852 /process.c
parentcf15997d317085c9a170a7b66f3237fff2f70c21 (diff)
* process.c (proc_setuid, proc_setgid, proc_seteuid, proc_setegid):
get rid of bogus implementations on Mac OS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/process.c b/process.c
index 9192f4e..a473fe9 100644
--- a/process.c
+++ b/process.c
@@ -2152,8 +2152,23 @@ proc_setuid(obj, id)
*
*/
-static int SAVED_USER_ID;
+static int SAVED_USER_ID = -1;
+#ifdef BROKEN_SETREUID
+int
+setreuid(ruid, euid)
+ rb_uid_t ruid, euid;
+{
+ if (ruid != -1 && ruid != getuid()) {
+ if (euid == -1) euid = geteuid();
+ if (setuid(ruid) < 0) return -1;
+ }
+ if (euid != -1 && euid != geteuid()) {
+ if (seteuid(euid) < 0) return -1;
+ }
+ return 0;
+}
+#endif
/*
* call-seq:
@@ -2497,7 +2512,7 @@ proc_setgid(obj, id)
#elif defined HAVE_SETREGID
if (setregid(gid, -1) < 0) rb_sys_fail(0);
#elif defined HAVE_SETRGID
- if (setrgid((GIDTYPE)gid) < 0) rb_sys_fail(0);
+ if (setrgid(gid) < 0) rb_sys_fail(0);
#elif defined HAVE_SETGID
{
if (getegid() == gid) {
@@ -2702,8 +2717,23 @@ proc_setmaxgroups(VALUE obj, VALUE val)
*
*/
-static int SAVED_GROUP_ID;
+static int SAVED_GROUP_ID = -1;
+#ifdef BROKEN_SETREGID
+int
+setregid(rgid, egid)
+ rb_gid_t rgid, egid;
+{
+ if (rgid != -1 && rgid != getgid()) {
+ if (egid == -1) egid = getegid();
+ if (setgid(rgid) < 0) return -1;
+ }
+ if (egid != -1 && egid != getegid()) {
+ if (setegid(egid) < 0) return -1;
+ }
+ return 0;
+}
+#endif
/*
* call-seq: