[#74825] Millisecond in time. — place4oracle@... (Warren)

Hi,

17 messages 2003/07/01
[#74827] Re: Millisecond in time. — Harry Ohlsen <harryo@...> 2003/07/01

Warren wrote:

[#74841] Re: Millisecond in time. — Anders Borch <spam@...> 2003/07/01

Harry Ohlsen wrote:

[#74853] Aeditor-0.1 is unleashed — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

Aeditor is a editor-widget written in Ruby. The primary

17 messages 2003/07/01

[#74884] Speaking of I18N... — "Hal E. Fulton" <hal9000@...>

I don't suppose anyone has implemented any

17 messages 2003/07/01

[#74894] rb_gc() and scan stack — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I were experimenting with Init_stack, when I discovered a flaw in my mind.

12 messages 2003/07/01

[#74912] Ruby9i now available — Jim Cain <list@...>

All,

18 messages 2003/07/02

[#74980] OT: It's that time of year again ... — james_b <james_b@...>

Happy Birthmonth to all fellow Rubyists born in July!

19 messages 2003/07/02

[#75023] A Quick Guide to SQLite and Ruby — why the lucky stiff <ruby-talk@...>

-Talkers:

17 messages 2003/07/02

[#75119] purpose of replace method — Ian Macdonald <ian@...>

Hi,

17 messages 2003/07/04

[#75137] How to create Shell Links on Windows? — Timon Christl <me@...>

Is there an easy way to create or modify shell links (.lnk) with ruby on

12 messages 2003/07/04

[#75160] seeking feedback on my first Ruby program — "Joe Cheng" <code@...>

I just took my first stab at writing a useful Ruby program. My programming

11 messages 2003/07/04

[#75307] Need regex to match "^\n" — Jim Freeze <jim@...>

Hi:

16 messages 2003/07/06

[#75369] Code Snippet: Array.shuffle — Stefan Arentz <stefan.arentz@...>

14 messages 2003/07/08

[#75420] My brief and torrid affair with Ruby. — Ray Cote <rgacote@...>

Hi List:

150 messages 2003/07/08
[#75421] Re: My brief and torrid affair with Ruby. — Daniel Carrera <dcarrera@...> 2003/07/09

-----BEGIN PGP SIGNED MESSAGE-----

[#75425] Re: My brief and torrid affair with Ruby. — Ray Cote <rgacote@...> 2003/07/09

At 9:08 AM +0900 7/9/03, Daniel Carrera wrote:

[#75426] Re: My brief and torrid affair with Ruby. — Daniel Carrera <dcarrera@...> 2003/07/09

-----BEGIN PGP SIGNED MESSAGE-----

[#75433] Re: My brief and torrid affair with Ruby. — Stephyn Butcher <tendzin.dorje@...> 2003/07/09

They don't call GPL a legal virus for nothing:

[#75527] Re: My brief and torrid affair with Ruby. — "Hal E. Fulton" <hal9000@...> 2003/07/09

----- Original Message -----

[#75529] Re: My brief and torrid affair with Ruby. — Daniel Carrera <dcarrera@...> 2003/07/09

-----BEGIN PGP SIGNED MESSAGE-----

[#75548] OT: GPL - was Re: My brief and torrid affair with Ruby. — "Hal E. Fulton" <hal9000@...> 2003/07/09

> > Are you honestly saying that you don't understand

[#75565] Re: OT: GPL - was Re: My brief and torrid affair with Ruby. — Chalmers <feldt@...> 2003/07/09

Sorry for this long post and rambling. Just skip if you're not in

[#75588] Re: OT: GPL - was Re: My brief and torrid affair with Ruby. — Austin Ziegler <austin@...> 2003/07/10

-----BEGIN PGP SIGNED MESSAGE-----

[#75610] Re: OT: GPL - was Re: My brief and torrid affair with Ruby. — Robert Feldt <feldt@...> 2003/07/10

Austin Ziegler <austin@halostatue.ca> skrev den Thu, 10 Jul 2003 10:10:03

[#75530] Re: My brief and torrid affair with Ruby. — "Michael Campbell" <michael_s_campbell@...> 2003/07/09

[#75531] Re: My brief and torrid affair with Ruby. — Daniel Carrera <dcarrera@...> 2003/07/09

-----BEGIN PGP SIGNED MESSAGE-----

[#75711] Re: My brief and torrid affair with Ruby. — "Sean O'Dell" <sean@...> 2003/07/11

"Daniel Carrera" <dcarrera@math.umd.edu> wrote in message

[#75712] Re: My brief and torrid affair with Ruby. — Daniel Carrera <dcarrera@...> 2003/07/11

-----BEGIN PGP SIGNED MESSAGE-----

[#75536] Re: My brief and torrid affair with Ruby. — "Hal E. Fulton" <hal9000@...> 2003/07/09

----- Original Message -----

[#75539] Re: My brief and torrid affair with Ruby. — "Gennady" <gfb@...> 2003/07/09

OK, Daniel, let's put it this way: if you do not use something there's

[#75438] NASA using Ruby? — Harry Ohlsen <harryo@...>

I noticed a reference in the intro blurb for Dave Thomas's talk at OSCON to NASA doing numerical simulations using Ruby.

24 messages 2003/07/09

[#75570] Ruby T-Shirt Idea — shout@... (Austin King)

Keywords: advocacy, silly t-shirts, Request For Feedback

43 messages 2003/07/09

[#75654] Re: Ruby T-Shirt Idea — "Orion Hunter" <orion2480@...>

What we need is a code snippet that is excessively long and obfuscate in

31 messages 2003/07/10

[#75767] Getting my IP address — Philip Mak <pmak@...>

Is there a piece of Ruby code somewhere that will tell me what my IP

13 messages 2003/07/11

[#75777] Re: OSCON report — "Volkmann, Mark" <Mark.Volkmann@...>

> -----Original Message-----

19 messages 2003/07/11
[#75810] Re: OSCON report — matz@... (Yukihiro Matsumoto) 2003/07/11

Hi,

[#75811] Re: OSCON report — Matt Lawrence <matt@...> 2003/07/11

On Sat, 12 Jul 2003, Yukihiro Matsumoto wrote:

[#75852] ruby-mysql library load error — eric.anderson@... (Eric Anderson)

I am trying to get the ruby dbi library up and running on my machine.

10 messages 2003/07/12

[#75963] Custom method_missing doesn't trap super call — Richard Dale <Richard_Dale@...>

When I run the code below it produces the following output:

26 messages 2003/07/14

[#75975] Booleans — "Mark J. Reed" <markjreed@...>

Okay, as a convert from Perl to Ruby, I have to say that I love

14 messages 2003/07/14

[#75991] ruby-specific CGI question (I think) — "Kurt M. Dresner" <kdresner@...>

I'm using sessions and forms in my cgi script.

15 messages 2003/07/14

[#76058] How to reduce Ruby runtime error? — Xiangrong Fang <xrfang@...>

Hi my friends,

17 messages 2003/07/15

[#76121] Keyword "with" — "Robert Klemme" <bob.news@...>

66 messages 2003/07/16
[#76134] Re: Keyword "with" — "Robert Klemme" <bob.news@...> 2003/07/16

[#76143] Re: Keyword "with" — Peter Hickman <peter@...> 2003/07/16

Robert Klemme wrote:

[#76148] Other languages' features in Ruby — Ben Giddings <ben@...> 2003/07/16

Hrm, well I'm a Ruby/Java/C/C++/Python/Perl/Lisp/Javascript/PHP...

[#76149] Re: Keyword "with" — "Mark J. Reed" <markjreed@...> 2003/07/16

Peter (having a bad day) Hickman wrote:

[#76181] Re: Keyword "with" — Mark Wilson <mwilson13@...> 2003/07/16

[#76184] Re: Keyword "with" — "Michael Campbell" <michael_s_campbell@...> 2003/07/16

[#76293] Re: Keyword "with" — "Hal E. Fulton" <hal9000@...> 2003/07/17

----- Original Message -----

[#76145] Advocacy: Ruby on/with .net — "Thomas Sondergaard" <thomass@...>

I'd like a minute or two of your time as I try to sell you the idea of ruby

34 messages 2003/07/16

[#76196] OO Design question for Net::HTTP caching extension — Aredridel <aredridel@...>

I'm in the process of writing an HTTP-1.1 extension to Net::HTTP. At

10 messages 2003/07/16

[#76254] What's the point? — Jim Freeze <jim@...>

Hi

19 messages 2003/07/17

[#76336] Aliased setter methods behave differently than other methods? — Jim Cain <list@...>

Here's another question... I am aliasing and redefining certain methods,

11 messages 2003/07/18

[#76372] Binary counter — ptkwt@...1.aracnet.com (Phil Tomson)

I needed to test a class which had a certain number of 'binary' inputs (ie. each input

14 messages 2003/07/18

[#76396] chaining comparisons — "Kurt M. Dresner" <kdresner@...>

When I learned python I was overjoyed that I could evaluate 1 < 2 < 3

36 messages 2003/07/19

[#76424] Proposal: Array#to_h, to simplify hash generation — Gavin Sinclair <gsinclair@...>

Hi -talk,

41 messages 2003/07/19
[#76512] Re: Proposal: Array#to_h, to simplify hash generation — Martin DeMello <martindemello@...> 2003/07/20

Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#76513] Re: Proposal: Array#to_h, to simplify hash generation — dblack@... 2003/07/20

Hi --

[#76530] Re: Proposal: Array#to_h, to simplify hash generation — Martin DeMello <martindemello@...> 2003/07/21

dblack@superlink.net wrote:

[#76532] Re: Proposal: Array#to_h, to simplify hash generation — "Gavin Sinclair" <gsinclair@...> 2003/07/21

>

[#76540] Re: Proposal: Array#to_h, to simplify hash generation — dblack@... 2003/07/21

Hi --

[#76473] ruby documentation generator? — "Kurt M. Dresner" <kdresner@...>

I've been googling for a few minutes but I haven't found anything yet.

12 messages 2003/07/20

[#76497] Parsing POST and GET variables simultaneously? — David Heinemeier Hansson <david@...>

Isn't it possible to get variables from POST and GET simultaneously?

13 messages 2003/07/20

[#76499] From Windows internal format to UTF-8? — "renoX" <renZYX@...>

Hello,

13 messages 2003/07/20

[#76551] matz thoughts on Rite ? — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I don't know much about Rite, therefore I ask.

30 messages 2003/07/21

[#76563] Deep copy — Jim Freeze <jim@...>

Hi

15 messages 2003/07/21

[#76619] Should String#strip take a parameter? — "Warren Brown" <wkb@...>

All,

18 messages 2003/07/21

[#76625] RubyForge.org — Richard Kilmer <rich@...>

All,

37 messages 2003/07/22
[#76831] Re: [ANN] RubyForge.org — "Simon Strandgaard" <0bz63fz3m1qt3001@...> 2003/07/23

On Tue, 22 Jul 2003 12:43:41 +0200, Oliver Bolzer wrote:

[#76693] Bug report: ruby-1.8.0p3 fails to compile under FreeBSD-4.7 — Brian Candler <B.Candler@...>

gcc -fPIC -g -O2 -DDB_DBM_HSEARCH -DDBM_HDR="<db.h>" -I. -I/u/home/telinco/build/ruby/ruby-1.8.0 -I/u/home/telinco/build/ruby/ruby-1.8.0 -I/u/home/telinco/build/ruby/ruby-1.8.0/ext/dbm -DHAVE_DB_H -DHAVE_SYS_CDEFS_H -DHAVE___DB_NDBM_OPEN -DHAVE___DB_NDBM_CLEARERR -c dbm.c

10 messages 2003/07/22

[#76697] String substitution without RegEx — Andreas Schwarz <usenet@...>

I wanted to do a simple string substitution, and was surprised to see

20 messages 2003/07/22

[#76751] New RDoc template, and a question — Dave Thomas <dave@...>

Michael Granger has produced a wonderful new RDoc template, which looks

37 messages 2003/07/23

[#76783] Embedding problem - SEGV — Brian Candler <B.Candler@...>

I have a problem with embedding Ruby, which hopefully someone can shed some

16 messages 2003/07/23

[#76843] Re: [OT] subversion, was [ANN] RubyForge.org — "Bennett, Patrick" <Patrick.Bennett@...>

Hmm, the linuxworld article didn't really say anything useful about

12 messages 2003/07/23

[#76892] ruby 1.8.0 preview4 — matz@... (Yukihiro Matsumoto)

Hello,

44 messages 2003/07/24

[#76984] Patches to 1.8.0p4 to add Bessel functions for those that have 'em — Mike Hall <mghall@...>

Here's some simple patches to configure.in, configure and math.c

23 messages 2003/07/25
[#77006] Re: Patches to 1.8.0p4 to add Bessel functions for those that have 'em — matz@... (Yukihiro Matsumoto) 2003/07/25

Hi,

[#76991] Confused about locking a file via file.flock(File::LOCK_EX) — Ludwigi Beethoven <aix_tech@...>

I am writing a ruby appl under AIX where I need to

11 messages 2003/07/25

[#77082] Set doesn't have [] instance method — Gavin Sinclair <gsinclair@...>

It should, shouldn't it? It's meant to combine the fast lookup of

15 messages 2003/07/26

[#77087] What's wrong with ruby garden? — "Carl Youngblood" <carl@...>

It seems that Ruby Garden is down right now. Does anyone know what's

10 messages 2003/07/26

[#77129] Ruby in Ruby — Austin Ziegler <austin@...>

Over on the pragprog list, Ron Jeffries suggested that it might be

15 messages 2003/07/28

[#77144] ruby 1.8.0 preview5 — matz@... (Yukihiro Matsumoto)

Hello,

16 messages 2003/07/28

[#77149] winsock problem? — Xiangrong Fang <xrfang@...>

Hi,

14 messages 2003/07/28

[#77176] Fishing for ideas: Ruby-talk for Java coders — Armin Roehrl <armin@...>

Hi all,

19 messages 2003/07/28

[#77197] Parser generator — "Rodrigo B. de Oliveira" <rodrigob@...>

I'm evaluating language/frameworks for creating a toy language compiler =

13 messages 2003/07/29

[#77227] Warnings? — Tim Bates <tim@...>

Hi all,

15 messages 2003/07/29
[#77242] Re: Warnings? — matz@... (Yukihiro Matsumoto) 2003/07/29

Hi,

[#77354] Ruby could be wildly more popular if it had ... — quixoticsycophant@... (Jeff Mitchell)

Brackets.

40 messages 2003/07/30
[#77694] Re: Ruby could be wildly more popular if it had ... — Martin DeMello <martindemello@...> 2003/08/01

Chris Thomas <chris@m-audio.com> wrote:

[#77359] Hm... nice, Euclid is a one-liner — Rudolf Polzer <denshimeiru-sapmctacher@...>

a, b = b, a % b while b != 0

12 messages 2003/07/30

[#77408] Bignum multiplication — Harry Ohlsen <harryo@...>

I was just reading about Python 2.3 and they talked about how they've changed their arbitrary-precision integer multiplication to use the Karatsuba multiplication algorithm.

21 messages 2003/07/30

[#77516] wanted: official mirrors for 1.8.0 — matz@... (Yukihiro Matsumoto)

Hello,

24 messages 2003/07/31

[#77528] ruby 1.8.0 preview6 — matz@... (Yukihiro Matsumoto)

Hello,

14 messages 2003/07/31

[#77590] Spam at ruby-talk — Daniel Carrera <dcarrera@...>

I don't know who runs the ruby-talk mailing list. I've noticed that

13 messages 2003/07/31
[#77595] Re: Spam at ruby-talk — Dave Thomas <dave@...> 2003/07/31

Daniel Carrera wrote:

[#77592] Changing ==,>,<, etc — elbows@... (Nathan Weston)

The latest Perl exegesis

15 messages 2003/07/31

[#77623] Extracting a parent class — Michael Garriss <mgarriss@...>

Sorry about the newbie question but....

14 messages 2003/07/31

portable(?) user/group ID control

From: Hidetoshi NAGAI <nagai@...>
Date: 2003-07-17 04:12:03 UTC
List: ruby-talk #76218
Hi, 

About 2 years ago, there was a small thread of discussion on
ruby-dev ML. It was about the portablity of user/group ID control. 
Process.uid= and Process.euid= are not enough for adequate control 
of privileges. Systemcalls (such as setuid or setreuid) have only 
low portability because of dependency on OS. The discussion was 
about the set of methods and specification of each method which 
has higher portability for privileges control than the current 
method set of Ruby. 

Here is a sample of specification. A patch for CVS head (1.8.0) 
is attached to this mail. In a lot of cases, the purpose of 
user/group ID control is (1) to exchange a user privilege to 
another privilege temporarily, or (2) to drop to a user privilege 
permanently. If based on this patch, Process::UserID.eid = new_id 
and Process::UserID.swith will work for case (1), and 
Process::UserID.to(new_id) will work for case (2). Which systemcalls
must be used for the purpose on the current environment is determined
by Ruby.

Your comments and suggestions (include better names of methods) are
welcome. 

# As you know, I can write only a little English. 
# So, I'm very sorry but I may not be able to give you answers 
# enough to satisfy your question. 

=*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*=

module Process::ID_Syscall
    * Simple implementation of systemcalls.
    * These methods have low portability. 
  getuid
  geteuid
  getgid
  getegid
  setuid
  setgid
  setruid
  setrgid
  seteuid
  setegid
  setreuid
  setregid
  setresuid
  setresgid

module Process::UserID
    * manipulate user IDs of the process

module Process::GroupID
    * manipulate group IDs of the process

============================================================

Process::UserID.rid [Process::GroupID.rid]

  SPEC : gets the real user ID of the current process.

============================================================

Process::UserID.eid [Process::GroupID.eid]

  SPEC : gets the effective user ID of the current process.

============================================================

Process::UserID.to(id) [Process::GroupID.to(id)]

  SPEC : sets the real/effective/saved user ID to id. 
         If succeed, returns id. 
         If fail to change some of IDs, raise a exception. 
         After the exception, it is unknown whether each of IDs 
         keeps the old value. 

  Attention : 
         There is no compatibility with Process.uid=. 
         If you use the method implemented by setreuid(id,-1), 
         for example, please rewrite the script to the following. 

         Process::UserID.ex_reid   # (r,e,s)==(u1,u2,??) ==> (u2,u1,??)
         Process::UserID.eid = id  # (u2,u1,??) ==> (u2,id,??)
         Process::UserID.ex_reid   # (u2,id,??) ==> (id,u2,??)

============================================================

Process::UserID.eid=(id) [Process::GroupID.eid=(id)]

  SPEC : sets the effecttive user ID to id. 
         If succeeed, returns id. 
         It depends on the value of Process::UserID.ex_reid? whether 
         the saved user ID is changed or not at the same time.
	 If Process::UserID.ex_reid? returns false, the saved user ID 
         is not changed. If Process::UserID.ex_reid? returns true and 
         succeed to change the effective user ID to the different
         value from the real user ID, the saved user ID is changed to 
         the new effective user ID.
         If fail to change, raise a exception. 

============================================================

Process::UserID.ex_reid [Process::GroupID.ex_reid]

  SPEC : exchanges the real user ID and the effective user ID.
         the saved user ID is set to the same value as the new
         effective user ID.
	 If not implemented (depends on specification of systemcalls
         of your OS), raise a exception. 
         If succeed, returns the new effective user ID.

============================================================

Process::UserID.ex_reid? [Process::GroupID.ex_reid?]

  SPEC : returns whether can exchange or not the real user ID and the 
         effective user ID (whether Process::UserID.ex_reid is
         implemented or not) on your environment.
         If implemented, returns true.

============================================================

Process::UserID.has_sid? [Process::GroupID.has_sid?]

  SPEC : returns whether your OS supports the saved user ID or not. 
         If supports, returns true. 

  Attention : 
         On the current version, if one of the following rules is
         satisfied, this method gesses the environment supports the
         saved user ID.
          (1) has setresuid() systemcall.
          (2) has seteuid() systemcall.
          (3) define _POSIX_SAVED_IDS as true

============================================================

Process::UserID.switch         [Process::GroupID.switch]
Process::UserID.switch { ... } [Process::GroupID.switch { ... }]

  SPEC : changes the user privilege temporarily.
         If a block is given, evaluate the block under the switched
         user privilege and back to the original privilege. 
         Without a block, it works to switch the two privileges. 
         As far as the real/effective/saved user ID are not changed by
         other methods, this method toggles the two privileges. 
         Without a block, this method returns a user ID which is
         restorable. With a block, returns a value of the block. 
	 If the status of current real/effective/saved user ID cannot
         support switching privileges, raise a exception. 
         If with a block and cannot change back to original privilege
         after evaluating the block (e.g. calls Process::UserID.to(id)
         in the block), raise a exception. 
         The privilage to be changed to is the current real user ID's
         privilege or the current saved ID's privilege. If your
         enviromnet doesn't have the saved user ID, the real user ID
         is changed by this method. 

============================================================

=*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*==*=

Index: configure.in
===================================================================
RCS file: /src/ruby/configure.in,v
retrieving revision 1.179
diff -u -r1.179 configure.in
--- configure.in	11 Jul 2003 13:37:22 -0000	1.179
+++ configure.in	16 Jul 2003 03:45:50 -0000
@@ -371,9 +371,9 @@
 	      truncate chsize times utimes fcntl lockf lstat symlink readlink\
 	      setitimer setruid seteuid setreuid setresuid setproctitle\
 	      setrgid setegid setregid setresgid pause lchown lchmod\
-	      getpgrp setpgrp getpgid setpgid getgroups setgroups getpriority getrlimit\
-	      dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod\
-	      mktime timegm cosh sinh tanh)
+	      getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
+	      getpriority getrlimit dlopen sigprocmask sigaction _setjmp\
+	      setsid telldir seekdir fchmod mktime timegm cosh sinh tanh)
 AC_STRUCT_TIMEZONE
 AC_CACHE_CHECK(for struct tm.tm_gmtoff, rb_cv_member_struct_tm_tm_gmtoff,
   [AC_TRY_COMPILE([#include <time.h>],
Index: process.c
===================================================================
RCS file: /src/ruby/process.c,v
retrieving revision 1.73
diff -u -r1.73 process.c
--- process.c	15 Jul 2003 07:35:10 -0000	1.73
+++ process.c	16 Jul 2003 03:45:52 -0000
@@ -1158,6 +1158,66 @@
 }
 
 static VALUE
+p_sys_setuid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETUID
+    if (setuid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setruid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETRUID
+    if (setruid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_seteuid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETEUID
+    if (seteuid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setreuid(obj, rid, eid)
+    VALUE obj, rid, eid;
+{
+#if defined HAVE_SETREUID
+    if (setreuid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setresuid(obj, rid, eid, sid)
+    VALUE obj, rid, eid, sid;
+{
+#if defined HAVE_SETRESUID
+    if (setresuid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
 proc_getuid(obj)
     VALUE obj;
 {
@@ -1177,7 +1237,7 @@
     if (setreuid(uid, -1) < 0) rb_sys_fail(0);
 #elif defined HAVE_SETRUID
     if (setruid(uid) < 0) rb_sys_fail(0);
-#else
+#elif defined HAVE_SETUID
     {
 	if (geteuid() == uid) {
 	    if (setuid(uid) < 0) rb_sys_fail(0);
@@ -1186,10 +1246,203 @@
 	    rb_notimplement();
 	}
     }
+#else
+    rb_notimplement();
 #endif
     return INT2FIX(uid);
 }
 
+static int SAVED_USER_ID;
+
+static VALUE
+p_uid_set_to(obj, id)
+    VALUE obj, id;
+{
+    extern int errno;
+    int uid;
+
+    uid = NUM2INT(id);
+
+    if (geteuid() == 0) { /* root-user */
+#if defined(HAVE_SETRESUID)
+      if (setresuid(uid, uid, uid) < 0) rb_sys_fail(0);
+      SAVED_USER_ID = uid;
+#elif defined HAVE_SETUID
+      if (setuid(uid) < 0) rb_sys_fail(0);
+      SAVED_USER_ID = uid;
+#elif defined HAVE_SETREUID
+      if (getuid() == uid) {
+	if (SAVED_USER_ID == uid) {
+	  if (setreuid(-1, uid) < 0) rb_sys_fail(0);
+	} else {
+	  if (uid == 0) { /* (r,e,s) == (root, root, x) */
+	    if (setreuid(-1, SAVED_USER_ID) < 0) rb_sys_fail(0);
+	    if (setreuid(SAVED_USER_ID, 0) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = 0; /* (r,e,s) == (x, root, root) */
+	    if (setreuid(uid, uid) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = uid;
+	  } else {
+	    if (setreuid(0, -1) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = 0;
+	    if (setreuid(uid, uid) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = uid;
+	  }
+	}
+      } else {
+	if (setreuid(uid, uid) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+      }
+#elif defined HAVE_SETRUID && defined HAVE_SETEUID
+      if (getuid() == uid) {
+	if (SAVED_USER_ID == uid) {
+	  if (seteuid(uid) < 0) rb_sys_fail(0);
+	} else {
+	  if (uid == 0) {
+	    if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = 0;
+	    if (setruid(0) < 0) rb_sys_fail(0);
+	  } else {
+	    if (setruid(0) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = 0;
+	    if (seteuid(uid) < 0) rb_sys_fail(0);
+	    if (setruid(uid) < 0) rb_sys_fail(0);
+	    SAVED_USER_ID = uid;
+	  }
+	}
+      } else {
+	if (seteuid(uid) < 0) rb_sys_fail(0);
+	if (setruid(uid) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+      }
+#else
+      rb_notimplement();
+#endif
+    } else { /* unprivileged user */
+#if defined(HAVE_SETRESUID)
+      if (setresuid((getuid() == uid)? -1: uid, 
+		    (geteuid() == uid)? -1: uid, 
+		    (SAVED_USER_ID == uid)? -1: uid) < 0) rb_sys_fail(0);
+      SAVED_USER_ID = uid;
+#elif defined HAVE_SETREUID
+      if (SAVED_USER_ID == uid) {
+	if (setreuid((getuid() == uid)? -1: uid, 
+		     (geteuid() == uid)? -1: uid) < 0) rb_sys_fail(0);
+      } else if (getuid() != uid) {
+	if (setreuid(uid, (geteuid() == uid)? -1: uid) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+      } else if (/* getuid() == uid && */ geteuid() != uid) {
+	if (setreuid(geteuid(), uid) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+	if (setreuid(uid, -1) < 0) rb_sys_fail(0);
+      } else { /* getuid() == uid && geteuid() == uid */
+	if (setreuid(-1, SAVED_USER_ID) < 0) rb_sys_fail(0);
+	if (setreuid(SAVED_USER_ID, uid) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+	if (setreuid(uid, -1) < 0) rb_sys_fail(0);
+      }
+#elif defined HAVE_SETRUID && defined HAVE_SETEUID
+      if (SAVED_USER_ID == uid) {
+	if (geteuid() != uid && seteuid(uid) < 0) rb_sys_fail(0);
+	if (getuid() != uid && setruid(uid) < 0) rb_sys_fail(0);
+      } else if (/* SAVED_USER_ID != uid && */ geteuid() == uid) {
+	if (getuid() != uid) {
+	  if (setruid(uid) < 0) rb_sys_fail(0);
+	  SAVED_USER_ID = uid;
+	} else {
+	  if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0);
+	  SAVED_USER_ID = uid;
+	  if (setruid(uid) < 0) rb_sys_fail(0);
+	}
+      } else if (/* geteuid() != uid && */ getuid() == uid) {
+	if (seteuid(uid) < 0) rb_sys_fail(0);
+	if (setruid(SAVED_USER_ID) < 0) rb_sys_fail(0);
+	SAVED_USER_ID = uid;
+	if (setruid(uid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#elif defined HAVE_SETEUID
+      if (getuid() == uid && SAVED_USER_ID == uid) {
+	if (seteuid(uid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#elif defined HAVE_SETUID
+      if (getuid() == uid && SAVED_USER_ID == uid) {
+	if (setuid(uid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#else
+      rb_notimplement();
+#endif
+    }
+    return INT2FIX(uid);
+}
+
+static VALUE
+p_sys_setgid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETGID
+    if (setgid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setrgid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETRGID
+    if (setrgid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setegid(obj, id)
+    VALUE obj, id;
+{
+#if defined HAVE_SETEGID
+    if (setegid(NUM2INT(id)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setregid(obj, rid, eid)
+    VALUE obj, rid, eid;
+{
+#if defined HAVE_SETREGID
+    if (setregid(NUM2INT(rid),NUM2INT(eid)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
+static VALUE
+p_sys_setresgid(obj, rid, eid, sid)
+    VALUE obj, rid, eid, sid;
+{
+#if defined HAVE_SETRESGID
+    if (setresgid(NUM2INT(rid),NUM2INT(eid),NUM2INT(sid)) != 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return Qnil;
+}
+
 static VALUE
 proc_getgid(obj)
     VALUE obj;
@@ -1208,9 +1461,9 @@
     if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0);
 #elif defined HAVE_SETREGID
     if (setregid(gid, -1) < 0) rb_sys_fail(0);
-#elif defined HAS_SETRGID
+#elif defined HAVE_SETRGID
     if (setrgid((GIDTYPE)gid) < 0) rb_sys_fail(0);
-#else
+#elif defined HAVE_SETGID
     {
 	if (getegid() == gid) {
 	    if (setgid(gid) < 0) rb_sys_fail(0);
@@ -1219,6 +1472,8 @@
 	    rb_notimplement();
 	}
     }
+#else
+    rb_notimplement();
 #endif
     return INT2FIX(gid);
 }
@@ -1302,6 +1557,21 @@
 }
 
 static VALUE
+proc_initgroups(obj, uname, base_grp)
+     VALUE obj, uname, base_grp;
+{
+#ifdef HAVE_INITGROUPS
+    if (initgroups(StringValuePtr(uname), (gid_t)NUM2INT(base_grp)) != 0) {
+	rb_sys_fail(0);
+    }
+    return proc_getgroups(obj);
+#else
+    rb_notimplement();
+    return Qnil;
+#endif
+}
+
+static VALUE
 proc_getmaxgroups(obj)
     VALUE obj;
 {
@@ -1322,6 +1592,138 @@
     return INT2FIX(maxgroups);
 }
 
+static int SAVED_GROUP_ID;
+
+static VALUE
+p_gid_set_to(obj, id)
+    VALUE obj, id;
+{
+    extern int errno;
+    int gid;
+
+    gid = NUM2INT(id);
+
+    if (geteuid() == 0) { /* root-user */
+#if defined(HAVE_SETRESGID)
+      if (setresgid(gid, gid, gid) < 0) rb_sys_fail(0);
+      SAVED_GROUP_ID = gid;
+#elif defined HAVE_SETGID
+      if (setgid(gid) < 0) rb_sys_fail(0);
+      SAVED_GROUP_ID = gid;
+#elif defined HAVE_SETREGID
+      if (getgid() == gid) {
+	if (SAVED_GROUP_ID == gid) {
+	  if (setregid(-1, gid) < 0) rb_sys_fail(0);
+	} else {
+	  if (gid == 0) { /* (r,e,s) == (root, y, x) */
+	    if (setregid(-1, SAVED_GROUP_ID) < 0) rb_sys_fail(0);
+	    if (setregid(SAVED_GROUP_ID, 0) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = 0; /* (r,e,s) == (x, root, root) */
+	    if (setregid(gid, gid) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = gid;
+	  } else { /* (r,e,s) == (z, y, x) */
+	    if (setregid(0, 0) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = 0;
+	    if (setregid(gid, gid) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = gid;
+	  }
+	}
+      } else {
+	if (setregid(gid, gid) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+      }
+#elif defined HAVE_SETRGID && defined HAVE_SETEGID
+      if (getgid() == gid) {
+	if (SAVED_GROUP_ID == gid) {
+	  if (setegid(gid) < 0) rb_sys_fail(0);
+	} else {
+	  if (gid == 0) {
+	    if (setegid(gid) < 0) rb_sys_fail(0);
+	    if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = 0;
+	    if (setrgid(0) < 0) rb_sys_fail(0);
+	  } else {
+	    if (setrgid(0) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = 0;
+	    if (setegid(gid) < 0) rb_sys_fail(0);
+	    if (setrgid(gid) < 0) rb_sys_fail(0);
+	    SAVED_GROUP_ID = gid;
+	  }
+	}
+      } else {
+	if (setegid(gid) < 0) rb_sys_fail(0);
+	if (setrgid(gid) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+      }
+#else
+      rb_notimplement();
+#endif
+    } else { /* unprivileged user */
+#if defined(HAVE_SETRESGID)
+      if (setresgid((getgid() == gid)? -1: gid, 
+		    (getegid() == gid)? -1: gid, 
+		    (SAVED_GROUP_ID == gid)? -1: gid) < 0) rb_sys_fail(0);
+      SAVED_GROUP_ID = gid;
+#elif defined HAVE_SETREGID
+      if (SAVED_GROUP_ID == gid) {
+	if (setregid((getgid() == gid)? -1: gid, 
+		     (getegid() == gid)? -1: gid) < 0) rb_sys_fail(0);
+      } else if (getgid() != gid) {
+	if (setregid(gid, (getegid() == gid)? -1: gid) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+      } else if (/* getgid() == gid && */ getegid() != gid) {
+	if (setregid(getegid(), gid) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+	if (setregid(gid, -1) < 0) rb_sys_fail(0);
+      } else { /* getgid() == gid && getegid() == gid */
+	if (setregid(-1, SAVED_GROUP_ID) < 0) rb_sys_fail(0);
+	if (setregid(SAVED_GROUP_ID, gid) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+	if (setregid(gid, -1) < 0) rb_sys_fail(0);
+      }
+#elif defined HAVE_SETRGID && defined HAVE_SETEGID
+      if (SAVED_GROUP_ID == gid) {
+	if (getegid() != gid && setegid(gid) < 0) rb_sys_fail(0);
+	if (getgid() != gid && setrgid(gid) < 0) rb_sys_fail(0);
+      } else if (/* SAVED_GROUP_ID != gid && */ getegid() == gid) {
+	if (getgid() != gid) {
+	  if (setrgid(gid) < 0) rb_sys_fail(0);
+	  SAVED_GROUP_ID = gid;
+	} else {
+	  if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0);
+	  SAVED_GROUP_ID = gid;
+	  if (setrgid(gid) < 0) rb_sys_fail(0);
+	}
+      } else if (/* getegid() != gid && */ getgid() == gid) {
+	if (setegid(gid) < 0) rb_sys_fail(0);
+	if (setrgid(SAVED_GROUP_ID) < 0) rb_sys_fail(0);
+	SAVED_GROUP_ID = gid;
+	if (setrgid(gid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#elif defined HAVE_SETEGID
+      if (getgid() == gid && SAVED_GROUP_ID == gid) {
+	if (setegid(gid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#elif defined HAVE_SETGID
+      if (getgid() == gid && SAVED_GROUP_ID == gid) {
+	if (setgid(gid) < 0) rb_sys_fail(0);
+      } else {
+	errno = EPERM;
+	rb_sys_fail(0);
+      }
+#else
+      rb_notimplement();
+#endif
+    }
+    return INT2FIX(gid);
+}
+
 static VALUE
 proc_geteuid(obj)
     VALUE obj;
@@ -1340,7 +1742,7 @@
     if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0);
 #elif defined HAVE_SETEUID
     if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
-#else
+#elif defined HAVE_SETUID
     euid = NUM2INT(euid);
     if (euid == getuid()) {
 	if (setuid(euid) < 0) rb_sys_fail(0);
@@ -1348,11 +1750,53 @@
     else {
 	rb_notimplement();
     }
+#else
+    rb_notimplement();
 #endif
     return euid;
 }
 
 static VALUE
+rb_seteuid_core(euid)
+    int euid;
+{
+    int uid;
+
+    uid = getuid();
+
+#if defined(HAVE_SETRESUID) && !defined(__CHECKER__)
+    if (uid != euid) {
+      if (setresuid(-1,euid,euid) < 0) rb_sys_fail(0);
+      SAVED_USER_ID = euid;
+    } else {
+      if (setresuid(-1,euid,-1) < 0) rb_sys_fail(0);
+    }
+#elif defined HAVE_SETREUID && !defined(__OpenBSD__)
+    if (setreuid(-1, euid) < 0) rb_sys_fail(0);
+    if (uid != euid) {
+      if (setreuid(euid,uid) < 0) rb_sys_fail(0);
+      if (setreuid(uid,euid) < 0) rb_sys_fail(0);
+      SAVED_USER_ID = euid;
+    }
+#elif defined HAVE_SETEUID
+    if (seteuid(euid) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETUID
+    if (geteuid() == 0) rb_sys_fail(0);
+    if (setuid(euid) < 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(euid);
+}
+
+static VALUE
+p_uid_set_eid(obj, id)
+    VALUE obj, id;
+{
+  return rb_seteuid_core(NUM2INT(id));
+}
+
+static VALUE
 proc_getegid(obj)
     VALUE obj;
 {
@@ -1372,7 +1816,7 @@
     if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0);
 #elif defined HAVE_SETEGID
     if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
-#else
+#elif defined HAVE_SETGID
     egid = NUM2INT(egid);
     if (egid == getgid()) {
 	if (setgid(egid) < 0) rb_sys_fail(0);
@@ -1380,10 +1824,224 @@
     else {
 	rb_notimplement();
     }
+#else
+    rb_notimplement();
 #endif
     return egid;
 }
 
+static VALUE
+rb_setegid_core(egid)
+    int egid;
+{
+    int gid;
+
+    gid = getgid();
+
+#if defined(HAVE_SETRESGID) && !defined(__CHECKER__)
+    if (gid != egid) {
+      if (setresgid(-1,egid,egid) < 0) rb_sys_fail(0);
+      SAVED_GROUP_ID = egid;
+    } else {
+      if (setresgid(-1,egid,-1) < 0) rb_sys_fail(0);
+    }
+#elif defined HAVE_SETREGID && !defined(__OpenBSD__)
+    if (setregid(-1, egid) < 0) rb_sys_fail(0);
+    if (gid != egid) {
+      if (setregid(egid,gid) < 0) rb_sys_fail(0);
+      if (setregid(gid,egid) < 0) rb_sys_fail(0);
+      SAVED_GROUP_ID = egid;
+    }
+#elif defined HAVE_SETEGID
+    if (setegid(egid) < 0) rb_sys_fail(0);
+#elif defined HAVE_SETGID
+    if (getegid() == 0) rb_sys_fail(0);
+    if (setgid(egid) < 0) rb_sys_fail(0);
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(egid);
+}
+
+static VALUE
+p_gid_set_eid(obj, id)
+    VALUE obj, id;
+{
+  return rb_setegid_core(NUM2INT(id));
+}
+
+static VALUE
+p_uid_exchangeable()
+{
+#if defined(HAVE_SETRESUID) &&  !defined(__CHECKER__)
+  return Qtrue;
+#elif defined HAVE_SETREUID && !defined(__OpenBSD__)
+  return Qtrue;
+#else
+  return Qfalse;
+#endif
+}
+
+static VALUE
+p_uid_exchange(obj)
+    VALUE obj;
+{
+    int uid, euid;
+
+    uid = getuid();
+    euid = geteuid();
+
+#if defined(HAVE_SETRESUID) &&  !defined(__CHECKER__)
+    if (setresuid(euid, uid, uid) < 0) rb_sys_fail(0);
+    SAVED_USER_ID = uid;
+#elif defined HAVE_SETREUID && !defined(__OpenBSD__)
+    if (setreuid(euid,uid) < 0) rb_sys_fail(0);
+    SAVED_USER_ID = uid;
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(uid);
+}
+
+static VALUE
+p_gid_exchangeable()
+{
+#if defined(HAVE_SETRESGID) &&  !defined(__CHECKER__)
+  return Qtrue;
+#elif defined HAVE_SETREGID && !defined(__OpenBSD__)
+  return Qtrue;
+#else
+  return Qfalse;
+#endif
+}
+
+static VALUE
+p_gid_exchange(obj)
+    VALUE obj;
+{
+    int gid, egid;
+
+    gid = getgid();
+    egid = getegid();
+
+#if defined(HAVE_SETRESGID) &&  !defined(__CHECKER__)
+    if (setresgid(egid, gid, gid) < 0) rb_sys_fail(0);
+    SAVED_GROUP_ID = gid;
+#elif defined HAVE_SETREGID && !defined(__OpenBSD__)
+    if (setregid(egid,gid) < 0) rb_sys_fail(0);
+    SAVED_GROUP_ID = gid;
+#else
+    rb_notimplement();
+#endif
+    return INT2FIX(gid);
+}
+
+static VALUE
+p_uid_has_saved_id()
+{
+#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || _POSIX_SAVED_IDS
+  return Qtrue;
+#else
+  return Qfalse;
+#endif
+}
+
+static VALUE
+p_uid_switch_auth(obj)
+    VALUE obj;
+{
+    extern int errno;
+    int uid, euid;
+
+    uid = getuid();
+    euid = geteuid();
+
+#if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || _POSIX_SAVED_IDS
+    if (uid != euid) {
+      proc_seteuid(obj, INT2FIX(uid));
+      if (rb_block_given_p()) {
+	return rb_ensure(rb_yield, Qnil, rb_seteuid_core, SAVED_USER_ID);
+      } else {
+	return INT2FIX(euid);
+      }
+    } else if (euid != SAVED_USER_ID) {
+      proc_seteuid(obj, INT2FIX(SAVED_USER_ID));
+      if (rb_block_given_p()) {
+	return rb_ensure(rb_yield, Qnil, rb_seteuid_core, euid);
+      } else {
+	return INT2FIX(uid);
+      }
+    } else {
+      errno = EPERM;
+      rb_sys_fail(0);
+    }
+#else
+    if (uid == euid) {
+      errno = EPERM;
+      rb_sys_fail(0);
+    }
+    proc_swap_uid(obj);
+    if (rb_block_given_p()) {
+      return rb_ensure(rb_yield, Qnil, proc_swap_uid, obj);
+    } else {
+      return INT2FIX(euid);
+    }
+#endif
+}
+
+static VALUE
+p_gid_has_saved_id()
+{
+#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || _POSIX_SAVED_IDS
+  return Qtrue;
+#else
+  return Qfalse;
+#endif
+}
+
+static VALUE
+p_gid_switch_auth(obj)
+    VALUE obj;
+{
+    extern int errno;
+    int gid, egid;
+
+    gid = getgid();
+    egid = getegid();
+
+#if defined(HAVE_SETRESGID) || defined(HAVE_SETEGID) || _POSIX_SAVED_IDS
+    if (gid != egid) {
+      proc_setegid(obj, INT2FIX(gid));
+      if (rb_block_given_p()) {
+	return rb_ensure(rb_yield, Qnil, proc_setegid, INT2FIX(SAVED_GROUP_ID));
+      } else {
+	return INT2FIX(egid);
+      }
+    } else if (egid != SAVED_GROUP_ID) {
+      proc_setegid(obj, INT2FIX(SAVED_GROUP_ID));
+      if (rb_block_given_p()) {
+	return rb_ensure(rb_yield, Qnil, proc_setegid, INT2FIX(egid));
+      } else {
+	return INT2FIX(gid);
+      }
+    } else {
+      errno = EPERM;
+      rb_sys_fail(0);
+    }
+#else
+    if (gid == egid) {
+      errno = EPERM;
+      rb_sys_fail(0);
+    }
+    proc_swap_gid(obj);
+    if (rb_block_given_p()) {
+      return rb_ensure(rb_yield, Qnil, proc_swap_gid, obj);
+    } else {
+      return INT2FIX(egid);
+    }
+#endif
+}
+
 VALUE
 rb_proc_times(obj)
     VALUE obj;
@@ -1411,6 +2069,9 @@
 }
 
 VALUE rb_mProcess;
+VALUE rb_mProcUID;
+VALUE rb_mProcGID;
+VALUE rb_mProcID_Syscall;
 
 void
 Init_process()
@@ -1499,6 +2160,7 @@
     rb_define_module_function(rb_mProcess, "euid=", proc_seteuid, 1);
     rb_define_module_function(rb_mProcess, "egid", proc_getegid, 0);
     rb_define_module_function(rb_mProcess, "egid=", proc_setegid, 1);
+    rb_define_module_function(rb_mProcess, "initgroups", proc_initgroups, 2);
     rb_define_module_function(rb_mProcess, "groups", proc_getgroups, 0);
     rb_define_module_function(rb_mProcess, "groups=", proc_setgroups, 1);
     rb_define_module_function(rb_mProcess, "maxgroups", proc_getmaxgroups, 0);
@@ -1509,4 +2171,53 @@
 #if defined(HAVE_TIMES) || defined(_WIN32)
     S_Tms = rb_struct_define("Tms", "utime", "stime", "cutime", "cstime", 0);
 #endif
+
+    SAVED_USER_ID = geteuid();
+    SAVED_GROUP_ID = getegid();
+
+    rb_mProcUID = rb_define_module_under(rb_mProcess, "UserID");
+    rb_mProcGID = rb_define_module_under(rb_mProcess, "GroupID");
+
+    rb_define_module_function(rb_mProcUID, "rid", proc_getuid, 0);
+    rb_define_module_function(rb_mProcGID, "rid", proc_getgid, 0);
+    rb_define_module_function(rb_mProcUID, "eid", proc_geteuid, 0);
+    rb_define_module_function(rb_mProcGID, "eid", proc_getegid, 0);
+    rb_define_module_function(rb_mProcUID, "to", p_uid_set_to, 1);
+    rb_define_module_function(rb_mProcGID, "to", p_gid_set_to, 1);
+    rb_define_module_function(rb_mProcUID, "eid=", p_uid_set_eid, 1);
+    rb_define_module_function(rb_mProcGID, "eid=", p_gid_set_eid, 1);
+    rb_define_module_function(rb_mProcUID, "ex_reid", p_uid_exchange, 0);
+    rb_define_module_function(rb_mProcGID, "ex_reid", p_gid_exchange, 0);
+    rb_define_module_function(rb_mProcUID, "ex_reid?", p_uid_exchangeable, 0);
+    rb_define_module_function(rb_mProcGID, "ex_reid?", p_gid_exchangeable, 0);
+    rb_define_module_function(rb_mProcUID, "has_sid?", p_uid_has_saved_id, 0);
+    rb_define_module_function(rb_mProcGID, "has_sid?", p_gid_has_saved_id, 0);
+    rb_define_module_function(rb_mProcUID, "switch", p_uid_switch_auth, 0);
+    rb_define_module_function(rb_mProcGID, "switch", p_uid_switch_auth, 0);
+
+    rb_mProcID_Syscall = rb_define_module_under(rb_mProcess, "ID_Syscall");
+
+    rb_define_module_function(rb_mProcID_Syscall, "getuid", proc_getuid, 0);
+    rb_define_module_function(rb_mProcID_Syscall, "geteuid", proc_geteuid, 0);
+    rb_define_module_function(rb_mProcID_Syscall, "getgid", proc_getgid, 0);
+    rb_define_module_function(rb_mProcID_Syscall, "getegid", proc_getegid, 0);
+
+    rb_define_module_function(rb_mProcID_Syscall, "setuid", p_sys_setuid, 1);
+    rb_define_module_function(rb_mProcID_Syscall, "setgid", p_sys_setgid, 1);
+
+    rb_define_module_function(rb_mProcID_Syscall, "setruid", p_sys_setruid, 1);
+    rb_define_module_function(rb_mProcID_Syscall, "setrgid", p_sys_setrgid, 1);
+
+    rb_define_module_function(rb_mProcID_Syscall, "seteuid", p_sys_seteuid, 1);
+    rb_define_module_function(rb_mProcID_Syscall, "setegid", p_sys_setegid, 1);
+
+    rb_define_module_function(rb_mProcID_Syscall, "setreuid", 
+			      p_sys_setreuid, 2);
+    rb_define_module_function(rb_mProcID_Syscall, "setregid", 
+			      p_sys_setregid, 2);
+
+    rb_define_module_function(rb_mProcID_Syscall, "setresuid", 
+			      p_sys_setresuid, 3);
+    rb_define_module_function(rb_mProcID_Syscall, "setresgid", 
+			      p_sys_setresgid, 3);
 }


-- 
                                  Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

In This Thread

Prev Next