* process.c (proc_seteuid): separate an internal wrapper function
from the method implementation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
214fd6ce77
commit
6cedbce87d
@ -1,3 +1,8 @@
|
|||||||
|
Fri Nov 11 18:41:57 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* process.c (proc_seteuid): separate an internal wrapper function
|
||||||
|
from the method implementation.
|
||||||
|
|
||||||
Fri Nov 11 17:21:15 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Nov 11 17:21:15 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (have_library, find_library, have_func): allow
|
* lib/mkmf.rb (have_library, find_library, have_func): allow
|
||||||
|
38
process.c
38
process.c
@ -5065,22 +5065,9 @@ proc_geteuid(VALUE obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID) || defined(_POSIX_SAVED_IDS)
|
#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID) || defined(_POSIX_SAVED_IDS)
|
||||||
/*
|
static void
|
||||||
* call-seq:
|
proc_seteuid(rb_uid_t uid)
|
||||||
* Process.euid= integer
|
|
||||||
*
|
|
||||||
* Sets the effective user ID for this process. Not available on all
|
|
||||||
* platforms.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
proc_seteuid(VALUE obj, VALUE euid)
|
|
||||||
{
|
{
|
||||||
rb_uid_t uid;
|
|
||||||
|
|
||||||
check_uid_switch();
|
|
||||||
|
|
||||||
uid = NUM2UIDT(euid);
|
|
||||||
#if defined(HAVE_SETRESUID)
|
#if defined(HAVE_SETRESUID)
|
||||||
if (setresuid(-1, uid, -1) < 0) rb_sys_fail(0);
|
if (setresuid(-1, uid, -1) < 0) rb_sys_fail(0);
|
||||||
#elif defined HAVE_SETREUID
|
#elif defined HAVE_SETREUID
|
||||||
@ -5097,12 +5084,25 @@ proc_seteuid(VALUE obj, VALUE euid)
|
|||||||
#else
|
#else
|
||||||
rb_notimplement();
|
rb_notimplement();
|
||||||
#endif
|
#endif
|
||||||
return euid;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_SETRESUID) || defined(HAVE_SETREUID) || defined(HAVE_SETEUID) || defined(HAVE_SETUID)
|
#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
|
#else
|
||||||
#define proc_seteuid_m rb_f_notimplement
|
#define proc_seteuid_m rb_f_notimplement
|
||||||
#endif
|
#endif
|
||||||
@ -5453,7 +5453,7 @@ p_uid_switch(VALUE obj)
|
|||||||
euid = geteuid();
|
euid = geteuid();
|
||||||
|
|
||||||
if (uid != euid) {
|
if (uid != euid) {
|
||||||
proc_seteuid(obj, UIDT2NUM(uid));
|
proc_seteuid(uid);
|
||||||
if (rb_block_given_p()) {
|
if (rb_block_given_p()) {
|
||||||
under_uid_switch = 1;
|
under_uid_switch = 1;
|
||||||
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, SAVED_USER_ID);
|
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, SAVED_USER_ID);
|
||||||
@ -5461,7 +5461,7 @@ p_uid_switch(VALUE obj)
|
|||||||
return UIDT2NUM(euid);
|
return UIDT2NUM(euid);
|
||||||
}
|
}
|
||||||
} else if (euid != SAVED_USER_ID) {
|
} else if (euid != SAVED_USER_ID) {
|
||||||
proc_seteuid(obj, UIDT2NUM(SAVED_USER_ID));
|
proc_seteuid(SAVED_USER_ID);
|
||||||
if (rb_block_given_p()) {
|
if (rb_block_given_p()) {
|
||||||
under_uid_switch = 1;
|
under_uid_switch = 1;
|
||||||
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, euid);
|
return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, euid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user