Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. int read_supplementary_groups(char *user)
  2. {
  3.     int ngroups = 16;
  4.     gid_t groups = (gid_t *)malloc(ngroups*sizeof(gid_t))
  5.     struct passwd pw = getpwnam(user);
  6.     if(getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) < 0){
  7.         groups = (gid_t *)realloc(nrougps*sizeof(gid_t));
  8.         getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
  9.     }
  10.     return groups;
  11. }
  12.  
  13. int main(int argc, char **argv)
  14. {
  15.     read_supplementary_groups(getenv("USER"));
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement