1
/* Copyright (C) 1989,91,93,1996-2006,2008,2010 Free Software Foundation, Inc.
1
/* Copyright (C) 1989,1991,1993,1996-2006,2008,2010,2011
2
Free Software Foundation, Inc.
2
3
This file is part of the GNU C Library.
4
5
The GNU C Library is free software; you can redistribute it and/or
43
44
extern void *__nss_lookup_function (service_user *ni, const char *fct_name);
45
46
extern service_user *__nss_group_database attribute_hidden;
47
service_user *__nss_initgroups_database;
48
static bool use_initgroups_entry;
48
51
#include "compat-initgroups.c"
71
service_user *nip = NULL;
72
initgroups_dyn_function fct;
73
74
enum nss_status status = NSS_STATUS_UNAVAIL;
75
/* Start is one, because we have the first group as parameter. */
78
77
/* Never store more than the starting *SIZE number of elements. */
79
78
assert (*size > 0);
80
79
(*groupsp)[0] = group;
80
/* Start is one, because we have the first group as parameter. */
82
if (__nss_group_database != NULL)
83
if (__nss_initgroups_database == NULL)
85
nip = __nss_group_database;
85
if (__nss_database_lookup ("initgroups", NULL, "",
86
&__nss_initgroups_database) < 0)
88
if (__nss_group_database == NULL)
89
no_more = __nss_database_lookup ("group", NULL, "compat files",
90
&__nss_group_database);
92
__nss_initgroups_database = __nss_group_database;
95
use_initgroups_entry = true;
88
no_more = __nss_database_lookup ("group", NULL,
89
"compat [NOTFOUND=return] files", &nip);
98
/* __nss_initgroups_database might have been set through
99
__nss_configure_lookup in which case use_initgroups_entry was
101
use_initgroups_entry = __nss_initgroups_database != __nss_group_database;
103
service_user *nip = __nss_initgroups_database;
93
106
long int prev_start = start;
95
fct = __nss_lookup_function (nip, "initgroups_dyn");
108
initgroups_dyn_function fct = __nss_lookup_function (nip,
98
111
status = compat_call (nip, user, group, &start, size, groupsp,
120
133
if (NSS_STATUS_TRYAGAIN > status || status > NSS_STATUS_RETURN)
121
134
__libc_fatal ("illegal status in internal_getgrouplist");
123
if (status != NSS_STATUS_SUCCESS
136
/* For compatibility reason we will continue to look for more
137
entries using the next service even though data has already
138
been found if the nsswitch.conf file contained only a 'groups'
139
line and no 'initgroups' line. If the latter is available
140
we always respect the status. This means that the default
141
for successful lookups is to return. */
142
if ((use_initgroups_entry || status != NSS_STATUS_SUCCESS)
124
143
&& nss_next_action (nip, status) == NSS_ACTION_RETURN)