brintos

brintos / llvm-project-archived public Read only

0
0
Text · 565 B · 4639a92 Raw
33 lines · cpp
1// RUN: %clangxx -O0 -g %s -o %t && %run %t2 3// XFAIL: target={{.*netbsd.*}} && msan4 5#include <stdlib.h>6#include <unistd.h>7#include <grp.h>8 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