Source file
src/os/user/getgrouplist_darwin.go
Documentation: os/user
1
2
3
4
5
6
7
8 package user
9
10
28 import "C"
29 import (
30 "fmt"
31 "unsafe"
32 )
33
34 func getGroupList(name *C.char, userGID C.gid_t, gids *C.gid_t, n *C.int) C.int {
35 return C.mygetgrouplist(name, userGID, gids, n)
36 }
37
38
39
40 func groupRetry(username string, name []byte, userGID C.gid_t, gids *[]C.gid_t, n *C.int) error {
41 *n = C.int(256 * 2)
42 for {
43 *gids = make([]C.gid_t, *n)
44 rv := getGroupList((*C.char)(unsafe.Pointer(&name[0])), userGID, &(*gids)[0], n)
45 if rv >= 0 {
46
47 break
48 }
49 if *n > maxGroups {
50 return fmt.Errorf("user: %q is a member of more than %d groups", username, maxGroups)
51 }
52 *n = *n * C.int(2)
53 }
54 return nil
55 }
56
View as plain text