Home | History | Annotate | Download | only in user
      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.
      4 
      5 package user
      6 
      7 /*
      8 #include <unistd.h>
      9 #include <sys/types.h>
     10 #include <stdlib.h>
     11 
     12 static int mygetgrouplist(const char* user, gid_t group, gid_t* groups, int* ngroups) {
     13 	int* buf = malloc(*ngroups * sizeof(int));
     14 	int rv = getgrouplist(user, (int) group, buf, ngroups);
     15 	int i;
     16 	if (rv == 0) {
     17 		for (i = 0; i < *ngroups; i++) {
     18 			groups[i] = (gid_t) buf[i];
     19 		}
     20 	}
     21 	free(buf);
     22 	return rv;
     23 }
     24 */
     25 import "C"
     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