Source file
src/os/user/getgrouplist_unix.go
1
2
3
4
5
6
7 package user
8
9
18 import "C"
19 import (
20 "fmt"
21 "unsafe"
22 )
23
24 func getGroupList(name *C.char, userGID C.gid_t, gids *C.gid_t, n *C.int) C.int {
25 return C.mygetgrouplist(name, userGID, gids, n)
26 }
27
28
29
30 func groupRetry(username string, name []byte, userGID C.gid_t, gids *[]C.gid_t, n *C.int) error {
31
32 if *n > maxGroups {
33 return fmt.Errorf("user: %q is a member of more than %d groups", username, maxGroups)
34 }
35 *gids = make([]C.gid_t, *n)
36 rv := getGroupList((*C.char)(unsafe.Pointer(&name[0])), userGID, &(*gids)[0], n)
37 if rv == -1 {
38 return fmt.Errorf("user: list groups for %s failed", username)
39 }
40 return nil
41 }
42
View as plain text