1 // RUN: %clangxx -O0 -g %s -o %t && %run %t 2 // 3 // REQUIRES: linux, freebsd, netbsd 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 14 ngroups = sysconf(_SC_NGROUPS_MAX); 15 groups = (gid_t *)malloc(ngroups * sizeof(gid_t)); 16 if (!groups) 17 exit(1); 18 19 if (gid_from_group("nobody", &nobody) == -1) 20 exit(1); 21 22 if (getgrouplist("nobody", nobody, groups, &ngroups)) 23 exit(1); 24 25 if (groups && ngroups) { 26 free(groups); 27 exit(0); 28 } 29 30 return -1; 31 } 32