Module: Process::Sys

Defined in:
process.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.egidFixnum .Process::GID.eidFixnum .Process::Sys.geteidFixnum

Returns the effective group ID for this process. Not available on all platforms.

Process.egid   #=> 500

Overloads:



6240
6241
6242
6243
6244
6245
6246
# File 'process.c', line 6240

static VALUE
proc_getegid(VALUE obj)
{
    rb_gid_t egid = getegid();

    return GIDT2NUM(egid);
}

.euidFixnum .Process::UID.eidFixnum .Process::Sys.geteuidFixnum

Returns the effective user ID for this process.

Process.euid   #=> 501

Overloads:



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);
}

.gidFixnum .Process::GID.ridFixnum .Process::Sys.getgidFixnum

Returns the (real) group ID for this process.

Process.gid   #=> 500

Overloads:



5561
5562
5563
5564
5565
5566
# File 'process.c', line 5561

static VALUE
proc_getgid(VALUE obj)
{
    rb_gid_t gid = getgid();
    return GIDT2NUM(gid);
}

.uidFixnum .Process::UID.ridFixnum .Process::Sys.getuidFixnum

Returns the (real) user ID of this process.

Process.uid   #=> 501

Overloads:



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::Sys.issetugidBoolean

Returns true if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution.

Returns:

  • (Boolean)


5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
# File 'process.c', line 5534

static VALUE
p_sys_issetugid(VALUE obj)
{
    rb_secure(2);
    if (issetugid()) {
	return Qtrue;
    }
    else {
	return Qfalse;
    }
}

.Process::Sys.setegid(group) ⇒ nil

Set the effective group ID of the calling process to group. Not available on all platforms.

Returns:

  • (nil)


5451
5452
5453
5454
5455
5456
5457
# File 'process.c', line 5451

static VALUE
p_sys_setegid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setegid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.seteuid(user) ⇒ nil

Set the effective user ID of the calling process to user. Not available on all platforms.

Returns:

  • (nil)


5067
5068
5069
5070
5071
5072
5073
# File 'process.c', line 5067

static VALUE
p_sys_seteuid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (seteuid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setgid(group) ⇒ nil

Set the group ID of the current process to group. Not available on all platforms.

Returns:

  • (nil)


5407
5408
5409
5410
5411
5412
5413
# File 'process.c', line 5407

static VALUE
p_sys_setgid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setgid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setregid(rid, eid) ⇒ nil

Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
# File 'process.c', line 5475

static VALUE
p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
{
    rb_gid_t rgid, egid;
    PREPARE_GETGRNAM;
    check_gid_switch();
    rgid = OBJ2GID(rid);
    egid = OBJ2GID(eid);
    FINISH_GETGRNAM;
    if (setregid(rgid, egid) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setresgid(rid, eid, sid) ⇒ nil

Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
# File 'process.c', line 5503

static VALUE
p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{
    rb_gid_t rgid, egid, sgid;
    PREPARE_GETGRNAM;
    check_gid_switch();
    rgid = OBJ2GID(rid);
    egid = OBJ2GID(eid);
    sgid = OBJ2GID(sid);
    FINISH_GETGRNAM;
    if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setresuid(rid, eid, sid) ⇒ nil

Sets the (user) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
# File 'process.c', line 5120

static VALUE
p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{
    rb_uid_t ruid, euid, suid;
    PREPARE_GETPWNAM;
    check_uid_switch();
    ruid = OBJ2UID1(rid);
    euid = OBJ2UID1(eid);
    suid = OBJ2UID1(sid);
    FINISH_GETPWNAM;
    if (setresuid(ruid, euid, suid) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setreuid(rid, eid) ⇒ nil

Sets the (user) real and/or effective user IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
# File 'process.c', line 5091

static VALUE
p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
{
    rb_uid_t ruid, euid;
    PREPARE_GETPWNAM;
    check_uid_switch();
    ruid = OBJ2UID1(rid);
    euid = OBJ2UID1(eid);
    FINISH_GETPWNAM;
    if (setreuid(ruid, euid) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setrgid(group) ⇒ nil

Set the real group ID of the calling process to group. Not available on all platforms.

Returns:

  • (nil)


5429
5430
5431
5432
5433
5434
5435
# File 'process.c', line 5429

static VALUE
p_sys_setrgid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setrgid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setruid(user) ⇒ nil

Set the real user ID of the calling process to user. Not available on all platforms.

Returns:

  • (nil)


5045
5046
5047
5048
5049
5050
5051
# File 'process.c', line 5045

static VALUE
p_sys_setruid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (setruid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

.Process::Sys.setuid(user) ⇒ nil

Set the user ID of the current process to user. Not available on all platforms.

Returns:

  • (nil)


5023
5024
5025
5026
5027
5028
5029
# File 'process.c', line 5023

static VALUE
p_sys_setuid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (setuid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

Instance Method Details

#egidFixnum (private) #Process::GID.eidFixnum (private) #Process::Sys.geteidFixnum (private)

Returns the effective group ID for this process. Not available on all platforms.

Process.egid   #=> 500

Returns:



6240
6241
6242
6243
6244
6245
6246
# File 'process.c', line 6240

static VALUE
proc_getegid(VALUE obj)
{
    rb_gid_t egid = getegid();

    return GIDT2NUM(egid);
}

#euidFixnum (private) #Process::UID.eidFixnum (private) #Process::Sys.geteuidFixnum (private)

Returns the effective user ID for this process.

Process.euid   #=> 501

Returns:



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);
}

#gidFixnum (private) #Process::GID.ridFixnum (private) #Process::Sys.getgidFixnum (private)

Returns the (real) group ID for this process.

Process.gid   #=> 500

Returns:



5561
5562
5563
5564
5565
5566
# File 'process.c', line 5561

static VALUE
proc_getgid(VALUE obj)
{
    rb_gid_t gid = getgid();
    return GIDT2NUM(gid);
}

#uidFixnum (private) #Process::UID.ridFixnum (private) #Process::Sys.getuidFixnum (private)

Returns the (real) user ID of this process.

Process.uid   #=> 501

Returns:



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::Sys.issetugidBoolean (private)

Returns true if the process was created as a result of an execve(2) system call which had either of the setuid or setgid bits set (and extra privileges were given as a result) or if it has changed any of its real, effective or saved user or group IDs since it began execution.

Returns:

  • (Boolean)


5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
# File 'process.c', line 5534

static VALUE
p_sys_issetugid(VALUE obj)
{
    rb_secure(2);
    if (issetugid()) {
	return Qtrue;
    }
    else {
	return Qfalse;
    }
}

#Process::Sys.setegid(group) ⇒ nil (private)

Set the effective group ID of the calling process to group. Not available on all platforms.

Returns:

  • (nil)


5451
5452
5453
5454
5455
5456
5457
# File 'process.c', line 5451

static VALUE
p_sys_setegid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setegid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.seteuid(user) ⇒ nil (private)

Set the effective user ID of the calling process to user. Not available on all platforms.

Returns:

  • (nil)


5067
5068
5069
5070
5071
5072
5073
# File 'process.c', line 5067

static VALUE
p_sys_seteuid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (seteuid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setgid(group) ⇒ nil (private)

Set the group ID of the current process to group. Not available on all platforms.

Returns:

  • (nil)


5407
5408
5409
5410
5411
5412
5413
# File 'process.c', line 5407

static VALUE
p_sys_setgid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setgid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setregid(rid, eid) ⇒ nil (private)

Sets the (group) real and/or effective group IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
# File 'process.c', line 5475

static VALUE
p_sys_setregid(VALUE obj, VALUE rid, VALUE eid)
{
    rb_gid_t rgid, egid;
    PREPARE_GETGRNAM;
    check_gid_switch();
    rgid = OBJ2GID(rid);
    egid = OBJ2GID(eid);
    FINISH_GETGRNAM;
    if (setregid(rgid, egid) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setresgid(rid, eid, sid) ⇒ nil (private)

Sets the (group) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
# File 'process.c', line 5503

static VALUE
p_sys_setresgid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{
    rb_gid_t rgid, egid, sgid;
    PREPARE_GETGRNAM;
    check_gid_switch();
    rgid = OBJ2GID(rid);
    egid = OBJ2GID(eid);
    sgid = OBJ2GID(sid);
    FINISH_GETGRNAM;
    if (setresgid(rgid, egid, sgid) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setresuid(rid, eid, sid) ⇒ nil (private)

Sets the (user) real, effective, and saved user IDs of the current process to rid, eid, and sid respectively. A value of -1 for any value means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
# File 'process.c', line 5120

static VALUE
p_sys_setresuid(VALUE obj, VALUE rid, VALUE eid, VALUE sid)
{
    rb_uid_t ruid, euid, suid;
    PREPARE_GETPWNAM;
    check_uid_switch();
    ruid = OBJ2UID1(rid);
    euid = OBJ2UID1(eid);
    suid = OBJ2UID1(sid);
    FINISH_GETPWNAM;
    if (setresuid(ruid, euid, suid) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setreuid(rid, eid) ⇒ nil (private)

Sets the (user) real and/or effective user IDs of the current process to rid and eid, respectively. A value of -1 for either means to leave that ID unchanged. Not available on all platforms.

Returns:

  • (nil)


5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
# File 'process.c', line 5091

static VALUE
p_sys_setreuid(VALUE obj, VALUE rid, VALUE eid)
{
    rb_uid_t ruid, euid;
    PREPARE_GETPWNAM;
    check_uid_switch();
    ruid = OBJ2UID1(rid);
    euid = OBJ2UID1(eid);
    FINISH_GETPWNAM;
    if (setreuid(ruid, euid) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setrgid(group) ⇒ nil (private)

Set the real group ID of the calling process to group. Not available on all platforms.

Returns:

  • (nil)


5429
5430
5431
5432
5433
5434
5435
# File 'process.c', line 5429

static VALUE
p_sys_setrgid(VALUE obj, VALUE id)
{
    check_gid_switch();
    if (setrgid(OBJ2GID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setruid(user) ⇒ nil (private)

Set the real user ID of the calling process to user. Not available on all platforms.

Returns:

  • (nil)


5045
5046
5047
5048
5049
5050
5051
# File 'process.c', line 5045

static VALUE
p_sys_setruid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (setruid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}

#Process::Sys.setuid(user) ⇒ nil (private)

Set the user ID of the current process to user. Not available on all platforms.

Returns:

  • (nil)


5023
5024
5025
5026
5027
5028
5029
# File 'process.c', line 5023

static VALUE
p_sys_setuid(VALUE obj, VALUE id)
{
    check_uid_switch();
    if (setuid(OBJ2UID(id)) != 0) rb_sys_fail(0);
    return Qnil;
}