]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/initgroups.c
2 #include "compat/initgroups.h"
20 int initgroups(const char *name
, gid_t basegid
)
24 #define NGROUPS_MAX 16
27 gid_t groups
[NGROUPS_MAX
];
33 groups
[index
++] = basegid
;
35 while (index
< NGROUPS_MAX
&& ((g
= getgrent()) != NULL
)) {
36 if (g
->gr_gid
!= basegid
) {
39 for (names
= g
->gr_mem
; *names
!= NULL
; ++names
) {
41 if (!strcmp(*names
, name
))
42 groups
[index
++] = g
->gr_gid
;
50 return setgroups(index
, groups
);
56 #endif /* def HAVE_SETGROUPS */