File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1014,6 +1014,14 @@ pub fn setgroups(groups: &[Gid]) -> Result<()> {
1014
1014
/// groups that `user` is a member of. The additional group `group` is also
1015
1015
/// added to the list.
1016
1016
///
1017
+ /// *Note:* Although the `getgrouplist()` call does not return any specific
1018
+ /// errors on any known platforms, this implementation will return a system
1019
+ /// error of `EINVAL` if the number of groups to be fetched exceeds the
1020
+ /// `NGROUPS_MAX` sysconf value. This mimics the behaviour of `getgroups()`
1021
+ /// and `setgroups()`. Additionally, while some implementations will return a
1022
+ /// partial list of groups when `NGROUPS_MAX` is exceeded, this implementation
1023
+ /// will only ever return the complete list or else an error.
1024
+ ///
1017
1025
/// [Further reading](http://man7.org/linux/man-pages/man3/getgrouplist.3.html)
1018
1026
pub fn getgrouplist ( user : & CString , group : Gid ) -> Result < Vec < Gid > > {
1019
1027
let ngroups_max = match sysconf ( SysconfVar :: NGROUPS_MAX ) {
@@ -1051,7 +1059,6 @@ pub fn getgrouplist(user: &CString, group: Gid) -> Result<Vec<Gid>> {
1051
1059
let cap = groups. capacity ( ) ;
1052
1060
if cap >= ngroups_max as usize {
1053
1061
// We already have the largest capacity we can, give up
1054
- // FIXME: What error should be returned?
1055
1062
return Err ( Error :: invalid_argument ( ) )
1056
1063
}
1057
1064
You can’t perform that action at this time.
0 commit comments