Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int read_supplementary_groups(char *user)
- {
- int ngroups = 16;
- gid_t groups = (gid_t *)malloc(ngroups*sizeof(gid_t))
- struct passwd pw = getpwnam(user);
- if(getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups) < 0){
- groups = (gid_t *)realloc(nrougps*sizeof(gid_t));
- getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
- }
- return groups;
- }
- int main(int argc, char **argv)
- {
- read_supplementary_groups(getenv("USER"));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement