]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/initgroups.c
dfd0007022daa4d543c2f29b4f24cc6aa9c572d6
2 * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 #include "compat/initgroups.h"
28 int initgroups(const char *name
, gid_t basegid
)
32 #define NGROUPS_MAX 16
35 gid_t groups
[NGROUPS_MAX
];
41 groups
[index
++] = basegid
;
43 while (index
< NGROUPS_MAX
&& ((g
= getgrent()) != NULL
)) {
44 if (g
->gr_gid
!= basegid
) {
47 for (names
= g
->gr_mem
; *names
!= NULL
; ++names
) {
49 if (!strcmp(*names
, name
))
50 groups
[index
++] = g
->gr_gid
;
58 return setgroups(index
, groups
);
64 #endif /* def HAVE_SETGROUPS */