1 | // RUN: %clangxx -O0 -g %s -o %t && %run %t |
---|---|
2 | |
3 | // XFAIL: target={{.*netbsd.*}} && msan |
4 | |
5 | #include <stdlib.h> |
6 | #include <unistd.h> |
7 | #include <grp.h> |
8 | |
9 | int 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(size: maxgrp * sizeof(gid_t)); |
17 | if (!groups) |
18 | exit(status: 1); |
19 | |
20 | if (gid_from_group("nobody", &nobody) == -1) |
21 | exit(status: 1); |
22 | |
23 | if (getgroupmembership("nobody", nobody, groups, maxgrp, &ngroups)) |
24 | exit(status: 1); |
25 | |
26 | if (groups && ngroups) { |
27 | free(ptr: groups); |
28 | exit(status: 0); |
29 | } |
30 | |
31 | return -1; |
32 | } |
33 |