1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* ISC license. */
#include <stddef.h>
#include <errno.h>
#include <skalibs/stralloc.h>
#include <nsss/config.h>
#include <nsss/grp-unix.h>
#include <nsss/nsss-switch.h>
#include <nsss/grp-all.h>
#include "nsss-internal.h"
int nsss_all_getgrouplist (char const *user, gid_t gid, gid_t *gids, int *ngids)
{
stralloc sa = STRALLOC_ZERO ;
int e = errno ;
size_t r = 0 ;
size_t n ;
nsss_switch_t a = NSSS_SWITCH_ZERO ;
if (*ngids < 0) return (errno = EINVAL, -1) ;
n = *ngids ;
if (!nsss_switch_start(&a, NSSS_SWITCH_GRP, NSSS_NSSSD_PATH, 0, 0)) goto fallback ;
if (!nsss_switch_grp_getlist(&a, user, gids, n, &r, &sa, 0, 0))
{
nsss_switch_end(&a, NSSS_SWITCH_GRP) ;
return -1 ;
}
nsss_switch_end(&a, NSSS_SWITCH_GRP) ;
return nsss_grouplist_adjust(n, r, gid, gids, ngids, e) ;
fallback:
errno = e ;
return nsss_unix_getgrouplist(user, gid, gids, ngids) ;
}
|