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 #if defined(HAVE_STDLIB_H)
18 #include <sys/types.h>
29 int ngroups = getgroups(0,&grp);
31 if (sizeof(gid_t) == sizeof(int)) {
32 fprintf(stderr,"gid_t and int are the same size\n");
39 igroups = (int *)malloc(sizeof(int)*ngroups);
41 for (i=0;i<ngroups;i++)
42 igroups[i] = 0x42424242;
44 ngroups = getgroups(ngroups,(gid_t *)igroups);
46 if (igroups[0] == 0x42424242)
50 printf("WARNING: can't determine getgroups return type\n");
54 cgroups = (char *)igroups;
57 cgroups[2] == 0x42 && cgroups[3] == 0x42) {
58 fprintf(stderr,"getgroups returns gid_t\n");
62 for (i=0;i<ngroups;i++) {
63 if (igroups[i] == 0x42424242) {
64 fprintf(stderr,"getgroups returns gid_t\n");