Skip to content

Commit

Permalink
* process.c (proc_setuid, proc_setgid, proc_seteuid, proc_setegid):
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
nobu committed Aug 16, 2006
1 parent cf15997 commit ac815e9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Wed Aug 16 11:45:36 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>

* process.c (proc_setuid, proc_setgid, proc_seteuid, proc_setegid):
get rid of bogus implementations on Mac OS X.

Tue Aug 15 19:10:18 2006 Eric Hodel <drbrain@segment7.net>

* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_class_comment): Fix
Expand Down
36 changes: 33 additions & 3 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ac815e9

Please sign in to comment.