Lines 23-28
Link Here
|
23 |
#include <stdlib.h> |
23 |
#include <stdlib.h> |
24 |
#include <string.h> |
24 |
#include <string.h> |
25 |
#include <unistd.h> |
25 |
#include <unistd.h> |
|
|
26 |
#include <sys/param.h> |
26 |
#include <sys/types.h> |
27 |
#include <sys/types.h> |
27 |
#include <nsswitch.h> |
28 |
#include <nsswitch.h> |
28 |
|
29 |
|
Lines 207-212
getgrouplist (const char *user, gid_t gr
Link Here
|
207 |
return -1; |
208 |
return -1; |
208 |
|
209 |
|
209 |
result = internal_getgrouplist (user, group, &size, &newgroups, -1); |
210 |
result = internal_getgrouplist (user, group, &size, &newgroups, -1); |
|
|
211 |
|
212 |
memcpy (groups, newgroups, MIN (*ngroups, result) * sizeof (gid_t)); |
213 |
|
210 |
if (result > *ngroups) |
214 |
if (result > *ngroups) |
211 |
{ |
215 |
{ |
212 |
*ngroups = result; |
216 |
*ngroups = result; |
Lines 215-222
getgrouplist (const char *user, gid_t gr
Link Here
|
215 |
else |
219 |
else |
216 |
*ngroups = result; |
220 |
*ngroups = result; |
217 |
|
221 |
|
218 |
memcpy (groups, newgroups, *ngroups * sizeof (gid_t)); |
|
|
219 |
|
220 |
free (newgroups); |
222 |
free (newgroups); |
221 |
return result; |
223 |
return result; |
222 |
} |
224 |
} |
223 |
int ngroups = 2, old_ngroups; |
225 |
int ngroups = 2, old_ngroups; |
224 |
gid_t *groups = (gid_t *) malloc ((ngroups + 1) * sizeof (gid_t)); |
226 |
gid_t *groups = (gid_t *) malloc ((ngroups + 1) * sizeof (gid_t)); |
225 |
if (groups == NULL) |
227 |
if (groups == NULL) |
226 |
abort (); |
228 |
abort (); |
227 |
groups[ngroups] = (gid_t) 0xdeadbeef; |
229 |
groups[ngroups] = (gid_t) 0xdeadbeef; |
228 |
old_ngroups = ngroups; |
230 |
old_ngroups = ngroups; |
229 |
if (getgrouplist ("bin", 0, groups, &ngroups) < 0) |
231 |
if (getgrouplist ("bin", 0, groups, &ngroups) < 0) |
230 |
{ |
232 |
{ |
231 |
if (groups[old_ngroups] != (gid_t) 0xdeadbeef) |
233 |
if (groups[old_ngroups] != (gid_t) 0xdeadbeef) |
232 |
groups = realloc (groups, (ngroups + 1) * sizeof (gid_t)); |
234 |
groups = realloc (groups, (ngroups + 1) * sizeof (gid_t)); |
233 |
if (groups == NULL) |
235 |
if (groups == NULL) |
234 |
groups[ngroups] = (gid_t) 0xdeadbeef; |
236 |
groups[ngroups] = (gid_t) 0xdeadbeef; |
235 |
old_ngroups = ngroups; |
237 |
old_ngroups = ngroups; |
236 |
if (getgrouplist ("bin", 0, groups, &ngroups) < 0) |
238 |
if (getgrouplist ("bin", 0, groups, &ngroups) < 0) |
237 |
if (groups[old_ngroups] != (gid_t) 0xdeadbeef) |
239 |
if (groups[old_ngroups] != (gid_t) 0xdeadbeef) |
238 |
} |
240 |
} |
239 |
else |
241 |
else |
240 |
abort (); |
242 |
abort (); |
241 |
exit (0); |
243 |
exit (0); |