mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 11:30:30 +00:00
lib: add getgrouplist() for Solaris
Of course Solaris doesn't have getgrouplist()... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
6d75781681
commit
4a9ea50e1b
@ -830,7 +830,7 @@ AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
|
|||||||
strtol strtoul strlcat strlcpy \
|
strtol strtoul strlcat strlcpy \
|
||||||
daemon snprintf vsnprintf \
|
daemon snprintf vsnprintf \
|
||||||
if_nametoindex if_indextoname getifaddrs \
|
if_nametoindex if_indextoname getifaddrs \
|
||||||
uname fcntl])
|
uname fcntl getgrouplist])
|
||||||
|
|
||||||
dnl ------------------------------------
|
dnl ------------------------------------
|
||||||
dnl Determine routing get and set method
|
dnl Determine routing get and set method
|
||||||
|
35
lib/privs.c
35
lib/privs.c
@ -622,6 +622,41 @@ zprivs_state_null (void)
|
|||||||
return zprivs_null_state;
|
return zprivs_null_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_GETGROUPLIST
|
||||||
|
/* Solaris 11 has no getgrouplist() */
|
||||||
|
static int
|
||||||
|
getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups)
|
||||||
|
{
|
||||||
|
struct group *grp;
|
||||||
|
size_t usridx;
|
||||||
|
int pos = 0, ret;
|
||||||
|
|
||||||
|
if (pos < *ngroups)
|
||||||
|
groups[pos] = group;
|
||||||
|
pos++;
|
||||||
|
|
||||||
|
setgrent();
|
||||||
|
while ((grp = getgrent()))
|
||||||
|
{
|
||||||
|
if (grp->gr_gid == group)
|
||||||
|
continue;
|
||||||
|
for (usridx = 0; grp->gr_mem[usridx] != NULL; usridx++)
|
||||||
|
if (!strcmp (grp->gr_mem[usridx], user))
|
||||||
|
{
|
||||||
|
if (pos < *ngroups)
|
||||||
|
groups[pos] = grp->gr_gid;
|
||||||
|
pos++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endgrent();
|
||||||
|
|
||||||
|
ret = (pos <= *ngroups) ? pos : -1;
|
||||||
|
*ngroups = pos;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GETGROUPLIST */
|
||||||
|
|
||||||
void
|
void
|
||||||
zprivs_init(struct zebra_privs_t *zprivs)
|
zprivs_init(struct zebra_privs_t *zprivs)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user