1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2 3 // XFAIL: netbsd && msan 4 5 #include <stdlib.h> 6 #include <unistd.h> 7 #include <grp.h> 8 main(void)9int main(void) { 10 gid_t *groups; 11 gid_t nobody; 12 int ngroups; 13 int maxgrp; 14 15 maxgrp = sysconf(_SC_NGROUPS_MAX); 16 groups = (gid_t *)malloc(maxgrp * sizeof(gid_t)); 17 if (!groups) 18 exit(1); 19 20 if (gid_from_group("nobody", &nobody) == -1) 21 exit(1); 22 23 if (getgroupmembership("nobody", nobody, groups, maxgrp, &ngroups)) 24 exit(1); 25 26 if (groups && ngroups) { 27 free(groups); 28 exit(0); 29 } 30 31 return -1; 32 } 33