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