summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-10 07:30:18 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-10 07:30:18 +0000
commit6b5ad7c5b203b7ffa8b86b1d0b9b15df56a90a27 (patch)
tree3418e391f39f859a553db6c1d92cc3e525efe32e /process.c
parentab9be24857d58a8300ccfb2bfbb093bcfe9807ab (diff)
setres[ug]id, NORETURN
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/process.c b/process.c
index 9015397..ebc76d5 100644
--- a/process.c
+++ b/process.c
@@ -952,10 +952,11 @@ proc_setuid(obj, id)
int uid;
uid = NUM2INT(id);
-#ifdef HAVE_SETREUID
+#if defined HAVE_SETRESUID
+ setresuid(uid, -1, -1);
+#elif defined HAVE_SETREUID
setreuid(uid, -1);
-#else
-#ifdef HAVE_SETRUID
+#elif defined HAVE_SETRUID
setruid(uid);
#else
{
@@ -965,7 +966,6 @@ proc_setuid(obj, id)
rb_notimplement();
}
#endif
-#endif
return INT2FIX(uid);
}
@@ -984,11 +984,12 @@ proc_setgid(obj, id)
int gid;
gid = NUM2INT(id);
-#ifdef HAS_SETRGID
- setrgid((GIDTYPE)gid);
-#else
-#ifdef HAVE_SETREGID
+#if defined HAVE_SETRESGID
+ setresgid(gid, -1, -1);
+#elif defined HAVE_SETREGID
setregid(gid, -1);
+#elif defined HAS_SETRGID
+ setrgid((GIDTYPE)gid);
#else
{
if (getegid() == gid)
@@ -997,7 +998,6 @@ proc_setgid(obj, id)
rb_notimplement();
}
#endif
-#endif
return INT2FIX(gid);
}
@@ -1013,11 +1013,12 @@ static VALUE
proc_seteuid(obj, euid)
VALUE obj, euid;
{
-#ifdef HAVE_SETEUID
- if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
-#else
-#ifdef HAVE_SETREUID
+#if defined HAVE_SETRESUID
+ if (setresuid(-1, NUM2INT(euid), -1) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETREUID
if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETEUID
+ if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
#else
euid = NUM2INT(euid);
if (euid == getuid())
@@ -1025,7 +1026,6 @@ proc_seteuid(obj, euid)
else
rb_notimplement();
#endif
-#endif
return euid;
}
@@ -1042,11 +1042,12 @@ proc_setegid(obj, egid)
VALUE obj, egid;
{
rb_secure(2);
-#ifdef HAVE_SETEGID
- if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
-#else
-#ifdef HAVE_SETREGID
+#if defined HAVE_SETRESGID
+ if (setresgid(-1, NUM2INT(egid), -1) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETREGID
if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETEGID
+ if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
#else
egid = NUM2INT(egid);
if (egid == getgid())
@@ -1054,7 +1055,6 @@ proc_setegid(obj, egid)
else
rb_notimplement();
#endif
-#endif
return egid;
}