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