| 265 | |
| 266 | #ifndef HAVE_INITGROUPS |
| 267 | int initgroups(const char *name, gid_t basegid) |
| 268 | { |
| 269 | #if defined(_OSD_POSIX) || defined(OS2) || defined(WIN32) || defined(NETWARE) |
| 270 | return 0; |
| 271 | #else |
| 272 | gid_t groups[NGROUPS_MAX]; |
| 273 | struct group *g; |
| 274 | int index = 0; |
| 275 | |
| 276 | setgrent(); |
| 277 | |
| 278 | groups[index++] = basegid; |
| 279 | |
| 280 | while (index < NGROUPS_MAX && ((g = getgrent()) != NULL)) { |
| 281 | if (g->gr_gid != basegid) { |
| 282 | char **names; |
| 283 | |
| 284 | for (names = g->gr_mem; *names != NULL; ++names) { |
| 285 | if (!strcmp(*names, name)) |
| 286 | groups[index++] = g->gr_gid; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | endgrent(); |
| 292 | |
| 293 | return setgroups(index, groups); |
| 294 | #endif |
| 295 | } |
| 296 | #endif /* def HAVE_INITGROUPS */ |
| 297 | |
| 298 | /* standard mpm configuration handling */ |
no outgoing calls
no test coverage detected