Module: Process::UID
- Defined in:
- process.c
Class Method Summary collapse
-
.Process::UID.change_privilege(user) ⇒ Fixnum
Change the current process’s real and effective user ID to that specified by user.
-
.eid ⇒ Object
Returns the effective user ID for this process.
-
.Process::UID.from_name(name) ⇒ Object
Get the user ID by the name.
-
.grant_privilege(id) ⇒ Object
Set the effective user ID, and if possible, the saved user ID of the process to the given user.
-
.Process::UID.re_exchange ⇒ Fixnum
Exchange real and effective user IDs and return the new effective user ID.
-
.Process::UID.re_exchangeable? ⇒ Boolean
Returns
trueif the real and effective user IDs of a process may be exchanged on the current platform. -
.rid ⇒ Object
Returns the (real) user ID of this process.
-
.Process::UID.sid_available? ⇒ Boolean
Returns
trueif the current platform has saved user ID functionality. - .switch ⇒ Object
Instance Method Summary collapse
-
#Process::UID.change_privilege(user) ⇒ Fixnum
private
Change the current process’s real and effective user ID to that specified by user.
-
#eid ⇒ Object
private
Returns the effective user ID for this process.
-
#Process::UID.from_name(name) ⇒ Object
private
Get the user ID by the name.
-
#grant_privilege(id) ⇒ Object
private
Set the effective user ID, and if possible, the saved user ID of the process to the given user.
-
#Process::UID.re_exchange ⇒ Fixnum
private
Exchange real and effective user IDs and return the new effective user ID.
-
#Process::UID.re_exchangeable? ⇒ Boolean
private
Returns
trueif the real and effective user IDs of a process may be exchanged on the current platform. -
#rid ⇒ Object
private
Returns the (real) user ID of this process.
-
#Process::UID.sid_available? ⇒ Boolean
private
Returns
trueif the current platform has saved user ID functionality. - #switch ⇒ Object private
Class Method Details
.Process::UID.change_privilege(user) ⇒ Fixnum
Change the current process’s real and effective user ID to that specified by user. Returns the new user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0]
Process::UID.change_privilege(31) #=> 31
[Process.uid, Process.euid] #=> [31, 31]
5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 |
# File 'process.c', line 5237 static VALUE p_uid_change_privilege(VALUE obj, VALUE id) { rb_uid_t uid; check_uid_switch(); uid = OBJ2UID(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) && !defined(OBSOLETE_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 (void)uid; rb_notimplement(); #endif } else { /* unprivileged user */ #if defined(HAVE_SETRESUID) if (setresuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid, (SAVED_USER_ID == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) if (SAVED_USER_ID == uid) { if (setreuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); } else if (getuid() != uid) { if (setreuid(uid, (geteuid() == uid)? (rb_uid_t)-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_44BSD_SETUID if (getuid() == uid) { /* (r,e,s)==(uid,?,?) ==> (uid,uid,uid) */ if (setuid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } 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 id; } |
.euid ⇒ Fixnum .Process::UID.eid ⇒ Fixnum .Process::Sys.geteuid ⇒ Fixnum
Returns the effective user ID for this process.
Process.euid #=> 501
6116 6117 6118 6119 6120 6121 |
# File 'process.c', line 6116 static VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); } |
.Process::UID.from_name(name) ⇒ Object
Get the user ID by the name. If the user is not found, ArgumentError will be raised.
Process::UID.from_name("root") #=> 0
Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError)
4927 4928 4929 4930 4931 |
# File 'process.c', line 4927 static VALUE p_uid_from_name(VALUE self, VALUE id) { return UIDT2NUM(OBJ2UID(id)); } |
.Process::UID.grant_privilege(user) ⇒ Fixnum .Process::UID.eid=(user) ⇒ Fixnum
Set the effective user ID, and if possible, the saved user ID of the process to the given user. Returns the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0]
Process::UID.grant_privilege(31) #=> 31
[Process.uid, Process.euid] #=> [0, 31]
6220 6221 6222 6223 6224 6225 |
# File 'process.c', line 6220 static VALUE p_uid_grant_privilege(VALUE obj, VALUE id) { rb_seteuid_core(OBJ2UID(id)); return id; } |
.Process::UID.re_exchange ⇒ Fixnum
Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 31]
Process::UID.re_exchange #=> 0
[Process.uid, Process.euid] #=> [31, 0]
6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 |
# File 'process.c', line 6392 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); } |
.Process::UID.re_exchangeable? ⇒ Boolean
Returns true if the real and effective user IDs of a process may be exchanged on the current platform.
6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 |
# File 'process.c', line 6367 static VALUE p_uid_exchangeable(void) { #if defined(HAVE_SETRESUID) return Qtrue; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) return Qtrue; #else return Qfalse; #endif } |
.uid ⇒ Fixnum .Process::UID.rid ⇒ Fixnum .Process::Sys.getuid ⇒ Fixnum
Returns the (real) user ID of this process.
Process.uid #=> 501
5149 5150 5151 5152 5153 5154 |
# File 'process.c', line 5149 static VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); } |
.Process::UID.sid_available? ⇒ Boolean
Returns true if the current platform has saved user ID functionality.
6492 6493 6494 6495 6496 6497 6498 6499 6500 |
# File 'process.c', line 6492 static VALUE p_uid_have_saved_id(void) { #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif } |
.switch ⇒ Object
6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 |
# File 'process.c', line 6571 static VALUE p_uid_switch(VALUE obj) { rb_uid_t uid, euid; check_uid_switch(); uid = getuid(); euid = geteuid(); if (uid == euid) { errno = EPERM; rb_sys_fail(0); } p_uid_exchange(obj); if (rb_block_given_p()) { under_uid_switch = 1; return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, obj); } else { return UIDT2NUM(euid); } } |
Instance Method Details
#Process::UID.change_privilege(user) ⇒ Fixnum (private)
Change the current process’s real and effective user ID to that specified by user. Returns the new user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0]
Process::UID.change_privilege(31) #=> 31
[Process.uid, Process.euid] #=> [31, 31]
5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 |
# File 'process.c', line 5237 static VALUE p_uid_change_privilege(VALUE obj, VALUE id) { rb_uid_t uid; check_uid_switch(); uid = OBJ2UID(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) && !defined(OBSOLETE_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 (void)uid; rb_notimplement(); #endif } else { /* unprivileged user */ #if defined(HAVE_SETRESUID) if (setresuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid, (SAVED_USER_ID == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) if (SAVED_USER_ID == uid) { if (setreuid((getuid() == uid)? (rb_uid_t)-1: uid, (geteuid() == uid)? (rb_uid_t)-1: uid) < 0) rb_sys_fail(0); } else if (getuid() != uid) { if (setreuid(uid, (geteuid() == uid)? (rb_uid_t)-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_44BSD_SETUID if (getuid() == uid) { /* (r,e,s)==(uid,?,?) ==> (uid,uid,uid) */ if (setuid(uid) < 0) rb_sys_fail(0); SAVED_USER_ID = uid; } 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 id; } |
#euid ⇒ Fixnum (private) #Process::UID.eid ⇒ Fixnum (private) #Process::Sys.geteuid ⇒ Fixnum (private)
Returns the effective user ID for this process.
Process.euid #=> 501
6116 6117 6118 6119 6120 6121 |
# File 'process.c', line 6116 static VALUE proc_geteuid(VALUE obj) { rb_uid_t euid = geteuid(); return UIDT2NUM(euid); } |
#Process::UID.from_name(name) ⇒ Object (private)
Get the user ID by the name. If the user is not found, ArgumentError will be raised.
Process::UID.from_name("root") #=> 0
Process::UID.from_name("nosuchuser") #=> can't find user for nosuchuser (ArgumentError)
4927 4928 4929 4930 4931 |
# File 'process.c', line 4927 static VALUE p_uid_from_name(VALUE self, VALUE id) { return UIDT2NUM(OBJ2UID(id)); } |
#Process::UID.grant_privilege(user) ⇒ Fixnum (private) #Process::UID.eid=(user) ⇒ Fixnum (private)
Set the effective user ID, and if possible, the saved user ID of the process to the given user. Returns the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 0]
Process::UID.grant_privilege(31) #=> 31
[Process.uid, Process.euid] #=> [0, 31]
6220 6221 6222 6223 6224 6225 |
# File 'process.c', line 6220 static VALUE p_uid_grant_privilege(VALUE obj, VALUE id) { rb_seteuid_core(OBJ2UID(id)); return id; } |
#Process::UID.re_exchange ⇒ Fixnum (private)
Exchange real and effective user IDs and return the new effective user ID. Not available on all platforms.
[Process.uid, Process.euid] #=> [0, 31]
Process::UID.re_exchange #=> 0
[Process.uid, Process.euid] #=> [31, 0]
6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 |
# File 'process.c', line 6392 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); } |
#Process::UID.re_exchangeable? ⇒ Boolean (private)
Returns true if the real and effective user IDs of a process may be exchanged on the current platform.
6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 |
# File 'process.c', line 6367 static VALUE p_uid_exchangeable(void) { #if defined(HAVE_SETRESUID) return Qtrue; #elif defined(HAVE_SETREUID) && !defined(OBSOLETE_SETREUID) return Qtrue; #else return Qfalse; #endif } |
#uid ⇒ Fixnum (private) #Process::UID.rid ⇒ Fixnum (private) #Process::Sys.getuid ⇒ Fixnum (private)
Returns the (real) user ID of this process.
Process.uid #=> 501
5149 5150 5151 5152 5153 5154 |
# File 'process.c', line 5149 static VALUE proc_getuid(VALUE obj) { rb_uid_t uid = getuid(); return UIDT2NUM(uid); } |
#Process::UID.sid_available? ⇒ Boolean (private)
Returns true if the current platform has saved user ID functionality.
6492 6493 6494 6495 6496 6497 6498 6499 6500 |
# File 'process.c', line 6492 static VALUE p_uid_have_saved_id(void) { #if defined(HAVE_SETRESUID) || defined(HAVE_SETEUID) || defined(_POSIX_SAVED_IDS) return Qtrue; #else return Qfalse; #endif } |
#switch ⇒ Object (private)
6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 |
# File 'process.c', line 6571 static VALUE p_uid_switch(VALUE obj) { rb_uid_t uid, euid; check_uid_switch(); uid = getuid(); euid = geteuid(); if (uid == euid) { errno = EPERM; rb_sys_fail(0); } p_uid_exchange(obj); if (rb_block_given_p()) { under_uid_switch = 1; return rb_ensure(rb_yield, Qnil, p_uid_sw_ensure, obj); } else { return UIDT2NUM(euid); } } |