From ef2e26c91b80556af033d3335e55f5dfa6fff31d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Aug 2003 01:53:07 +0000 Subject: first public release of samba4 code (This used to be commit b0510b5428b3461aeb9bbe3cc95f62fc73e2b97f) --- source4/tests/getgroups.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 source4/tests/getgroups.c (limited to 'source4/tests/getgroups.c') diff --git a/source4/tests/getgroups.c b/source4/tests/getgroups.c new file mode 100644 index 0000000000..343fd5a184 --- /dev/null +++ b/source4/tests/getgroups.c @@ -0,0 +1,66 @@ +/* this tests whether getgroups actually returns lists of integers + rather than gid_t. The test only works if the user running + the test is in at least 1 group + + The test is designed to check for those broken OSes that define + getgroups() as returning an array of gid_t but actually return a + array of ints! Ultrix is one culprit + */ + +#if defined(HAVE_UNISTD_H) +#include +#endif + +#include +#include +#include +#include + +main() +{ + int i; + int *igroups; + char *cgroups; + int grp = 0; + int ngroups = getgroups(0,&grp); + + if (sizeof(gid_t) == sizeof(int)) { + fprintf(stderr,"gid_t and int are the same size\n"); + exit(1); + } + + if (ngroups <= 0) + ngroups = 32; + + igroups = (int *)malloc(sizeof(int)*ngroups); + + for (i=0;i