1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 //go:build (dragonfly || freebsd || hurd || (!android && linux) || netbsd || openbsd || (solaris && !illumos)) && cgo && !osusergo
14 //extern-sysinfo getgrouplist
15 func getGroupList(name
*byte, userGID syscall
.Gid_t
, gids
*syscall
.Gid_t
, n
*int32) int32
17 // groupRetry retries getGroupList with much larger size for n. The result is
19 func groupRetry(username
string, name
[]byte, userGID syscall
.Gid_t
, gids
*[]syscall
.Gid_t
, n
*int32) error
{
20 // More than initial buffer, but now n contains the correct size.
22 return fmt
.Errorf("user: %q is a member of more than %d groups", username
, maxGroups
)
24 *gids
= make([]syscall
.Gid_t
, *n
)
25 rv
:= getGroupList(&name
[0], userGID
, &(*gids
)[0], n
)
27 return fmt
.Errorf("user: list groups for %s failed", username
)