[前][次][番号順一覧][スレッド一覧]

ruby-changes:21658

From: nobu <ko1@a...>
Date: Fri, 11 Nov 2011 18:42:21 +0900 (JST)
Subject: [ruby-changes:21658] nobu:r33707 (trunk): * process.c (proc_seteuid): separate an internal wrapper function

nobu	2011-11-11 18:42:02 +0900 (Fri, 11 Nov 2011)

  New Revision: 33707

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33707

  Log:
    * process.c (proc_seteuid): separate an internal wrapper function
      from the method implementation.

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33706)
+++ ChangeLog	(revision 33707)
@@ -1,3 +1,8 @@
+Fri Nov 11 18:41:57 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (proc_seteuid): separate an internal wrapper function
+	  from the method implementation.
+
 Fri Nov 11 17:21:15 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (have_library, find_library, have_func): allow
Index: process.c
===================================================================
--- process.c	(revision 33706)
+++ process.c	(revision 33707)
@@ -5065,22 +5065,9 @@
 }
 
 #if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID) || defined(_POSIX_SAVED_IDS)
-/*
- *  call-seq:
- *     Process.euid= integer
- *
- *  Sets the effective user ID for this process. Not available on all
- *  platforms.
- */
-
-static VALUE
-proc_seteuid(VALUE obj, VALUE euid)
+static void
+proc_seteuid(rb_uid_t uid)
 {
-    rb_uid_t uid;
-
-    check_uid_switch();
-
-    uid = NUM2UIDT(euid);
 #if defined(HAVE_SETRESUID)
     if (setresuid(-1, uid, -1) < 0) rb_sys_fail(0);
 #elif defined HAVE_SETREUID
@@ -5097,12 +5084,25 @@
 #else
     rb_notimplement();
 #endif
-    return euid;
 }
 #endif
 
 #if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID)
-#define proc_seteuid_m proc_seteuid
+/*
+ *  call-seq:
+ *     Process.euid= integer
+ *
+ *  Sets the effective user ID for this process. Not available on all
+ *  platforms.
+ */
+
+static VALUE
+proc_seteuid_m(VALUE euid)
+{
+    check_uid_switch();
+    proc_seteuid(NUM2UIDT(euid));
+    return euid;
+}
 #else
 #define proc_seteuid_m rb_f_notimplement
 #endif
@@ -5453,7 +5453,7 @@
     euid = geteuid();
 
     if (uid != euid) {
-	proc_seteuid(obj, UIDT2NUM(uid));
+	proc_seteuid(uid);
 	if (rb_block_given_p()) {
 	    under_uid_switch = 1;
 	    return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, SAVED_USER_ID);
@@ -5461,7 +5461,7 @@
 	    return UIDT2NUM(euid);
 	}
     } else if (euid != SAVED_USER_ID) {
-	proc_seteuid(obj, UIDT2NUM(SAVED_USER_ID));
+	proc_seteuid(SAVED_USER_ID);
 	if (rb_block_given_p()) {
 	    under_uid_switch = 1;
 	    return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, euid);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]