00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #if defined(HAVE_UNISTD_H)
00011 #include <unistd.h>
00012 #endif
00013
00014 #include <sys/types.h>
00015 #include <stdio.h>
00016 #include <unistd.h>
00017 #include <grp.h>
00018
00019 main()
00020 {
00021 int i;
00022 int *igroups;
00023 char *cgroups;
00024 int grp = 0;
00025 int ngroups = getgroups(0,&grp);
00026
00027 if (sizeof(gid_t) == sizeof(int)) {
00028 fprintf(stderr,"gid_t and int are the same size\n");
00029 exit(1);
00030 }
00031
00032 if (ngroups <= 0)
00033 ngroups = 32;
00034
00035 igroups = (int *)malloc(sizeof(int)*ngroups);
00036
00037 for (i=0;i<ngroups;i++)
00038 igroups[i] = 0x42424242;
00039
00040 ngroups = getgroups(ngroups,(gid_t *)igroups);
00041
00042 if (igroups[0] == 0x42424242)
00043 ngroups = 0;
00044
00045 if (ngroups == 0) {
00046 printf("WARNING: can't determine getgroups return type\n");
00047 exit(1);
00048 }
00049
00050 cgroups = (char *)igroups;
00051
00052 if (ngroups == 1 &&
00053 cgroups[2] == 0x42 && cgroups[3] == 0x42) {
00054 fprintf(stderr,"getgroups returns gid_t\n");
00055 exit(1);
00056 }
00057
00058 for (i=0;i<ngroups;i++) {
00059 if (igroups[i] == 0x42424242) {
00060 fprintf(stderr,"getgroups returns gid_t\n");
00061 exit(1);
00062 }
00063 }
00064
00065 exit(0);
00066 }