Up to%uA0size%uA0supplementary group IDs (of the calling process) are returned in%uA0list. It is unspecified whether the effective group ID of the calling process is included in the returned list. (Thus, an application should also call%uA0getegid(2) and add or remove the resulting value.) If%uA0size%uA0is zero,%uA0list%uA0is not modified, but the total number of supplementary group IDs for the process is returned.
setgroups()
%uA0
Sets the supplementary group IDs for the process. Appropriate privileges (Linux: the%uA0CAP_SETGIDꃊpability) are required.
返回值
标签
描述
getgroups()
%uA0
On success, the number of supplementary group IDs is returned. On error, -1 is returned, and%uA0errno%uA0is set appropriately.
setgroups()
%uA0
On success, zero is returned. On error, -1 is returned, and%uA0errnois set appropriately.
错误
标签
描述
EFAULT
list%uA0has an invalid address.
EINVAL
For%uA0setgroups(),%uA0size%uA0is greater than%uA0NGROUPS%uA0(32 for Linux 2.0.32). For%uA0getgroups(),%uA0size%uA0is less than the number of supplementary group IDs, but is not zero.
EPERM
The calling process has insufficient privilege to call%uA0setgroups().
注意
A process can have up to at least NGROUPS_MAX supplementary group IDs in addition to the effective group ID. The set of supplementary group IDs is inherited from the parent process and may be changed using%uA0setgroups(). The maximum number of supplementary group IDs can be found using%uA0sysconf(3):
long ngroups_max
ngroups_max = sysconf(_SC_NGROUPS_MAX)
The maximal return value of%uA0getgroups() cannot be larger than one more than the value obtained this way.
The prototype for%uA0setgroups() is only available if%uA0_BSD_SOURCE%uA0is defined.
遵循于
SVr4, 4.3BSD. The%uA0getgroups() function is in POSIX.1-2001. Since%uA0setgroups() requires privilege, it is not covered by POSIX.1-2001.