1 /* this tests whether getgroups actually returns lists of integers
2 rather than gid_t. The test only works if the user running
3 the test is in at least 1 group
5 The test is designed to check for those broken OSes that define
6 getgroups() as returning an array of gid_t but actually return a
7 array of ints! Ultrix is one culprit
10 #if defined(HAVE_UNISTD_H)
14 #include <sys/types.h>
25 int ngroups = getgroups(0,&grp);
27 if (sizeof(gid_t) == sizeof(int)) {
28 fprintf(stderr,"gid_t and int are the same size\n");
35 igroups = (int *)malloc(sizeof(int)*ngroups);
37 for (i=0;i<ngroups;i++)
38 igroups[i] = 0x42424242;
40 ngroups = getgroups(ngroups,(gid_t *)igroups);
42 if (igroups[0] == 0x42424242)
46 printf("WARNING: can't determine getgroups return type\n");
50 cgroups = (char *)igroups;
53 cgroups[2] == 0x42 && cgroups[3] == 0x42) {
54 fprintf(stderr,"getgroups returns gid_t\n");
58 for (i=0;i<ngroups;i++) {
59 if (igroups[i] == 0x42424242) {
60 fprintf(stderr,"getgroups returns gid_t\n");