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 #include <sys/types.h>
21 int ngroups
= getgroups(0,&grp
);
23 if (sizeof(gid_t
) == sizeof(int)) {
24 fprintf(stderr
,"gid_t and int are the same size\n");
31 igroups
= (int *)malloc(sizeof(int)*ngroups
);
33 for (i
=0;i
<ngroups
;i
++)
34 igroups
[i
] = 0x42424242;
36 ngroups
= getgroups(ngroups
,(gid_t
*)igroups
);
38 if (igroups
[0] == 0x42424242)
42 printf("WARNING: can't determine getgroups return type\n");
46 cgroups
= (char *)igroups
;
49 cgroups
[2] == 0x42 && cgroups
[3] == 0x42) {
50 fprintf(stderr
,"getgroups returns gid_t\n");
54 for (i
=0;i
<ngroups
;i
++) {
55 if (igroups
[i
] == 0x42424242) {
56 fprintf(stderr
,"getgroups returns gid_t\n");