Method: Process.groups
- Defined in:
- process.c
.groups ⇒ Array
Get an Array of the group IDs in the supplemental group access list for this process.
Process.groups #=> [27, 6, 10, 11]
Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system:
-
the result is sorted
-
the result includes effective GIDs
-
the result does not include duplicated GIDs
You can make sure to get a sorted unique GID list of the current process by this expression:
Process.groups.uniq.sort
6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 |
# File 'process.c', line 6810 static VALUE proc_getgroups(VALUE obj) { VALUE ary, tmp; int i, ngroups; rb_gid_t *groups; ngroups = getgroups(0, NULL); if (ngroups == -1) rb_sys_fail(0); groups = ALLOCV_N(rb_gid_t, tmp, ngroups); ngroups = getgroups(ngroups, groups); if (ngroups == -1) rb_sys_fail(0); ary = rb_ary_new(); for (i = 0; i < ngroups; i++) rb_ary_push(ary, GIDT2NUM(groups[i])); ALLOCV_END(tmp); return ary; } |