Method: Etc.getgrgid
- Defined in:
- etc.c
.getgrgid(*args) ⇒ Object
getgrgid(group_id) -> Etc::Group
Returns information about the group with specified integer group_id, as found in /etc/group.
The information is returned as a Group struct.
See the unix manpage for getgrgid(3) for more detail.
Example:
Etc.getgrgid(100) #=> #<struct Etc::Group name=“users”, passwd=“x”, gid=100, mem=[“meta”, “root”]>
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
# File 'etc.c', line 478
static VALUE
etc_getgrgid(int argc, VALUE *argv, VALUE obj)
{
#ifdef HAVE_GETGRENT
VALUE id;
gid_t gid;
struct group *grp;
if (rb_scan_args(argc, argv, "01", &id) == 1) {
gid = NUM2GIDT(id);
}
else {
gid = getgid();
}
grp = getgrgid(gid);
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", (int)gid);
return setup_group(grp);
#else
return Qnil;
#endif
}
|