Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Process::UID.re_exchange
() -> ::Integer
Process::UID.re_exchange → integer
process.c
View on GitHub ↗
static VALUE
p_uid_exchange(VALUE obj)
{
rb_uid_t uid;
#if defined(HAVE_SETRESUID) || (defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID))
rb_uid_t euid;
#endif
check_uid_switch();
uid = getuid();
#if defined(HAVE_SETRESUID) || (defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID))
euid = geteuid();
#endif
#if defined(HAVE_SETRESUID)
if (setresuid(euid, uid, uid) < 0) rb_sys_fail(0);
SAVED_USER_ID = uid;
#elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID)
if (setreuid(euid,uid) < 0) rb_sys_fail(0);
SAVED_USER_ID = uid;
#else
rb_notimplement();
#endif
return UIDT2NUM(uid);
}
Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms.
Example
[Process.uid, Process.euid] #=> [0, 31] Process::UID.re_exchange #=> 0 [Process.uid, Process.euid] #=> [31, 0]
See also
.grant_privilege
.re_exchangeable?
.from_name
.rid
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0