mirror of
https://sourceware.org/git/glibc.git
synced 2025-05-28 16:21:30 +03:00
Add initgroups lookup support to getent
This commit is contained in:
parent
c41af17eed
commit
82e9a1f7df
@ -1,5 +1,8 @@
|
|||||||
2011-06-15 Ulrich Drepper <drepper@gmail.com>
|
2011-06-15 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
* nss/getent.c: Add support for initgroups lookups through getgrouplist
|
||||||
|
interface.
|
||||||
|
|
||||||
* grp/initgroups.c (__nss_initgroups_database): Renamed and exported.
|
* grp/initgroups.c (__nss_initgroups_database): Renamed and exported.
|
||||||
(internal_getgrouplist): Adjust to name change.
|
(internal_getgrouplist): Adjust to name change.
|
||||||
Update use_initgroups_entry if this is not the first call.
|
Update use_initgroups_entry if this is not the first call.
|
||||||
|
33
nss/getent.c
33
nss/getent.c
@ -501,6 +501,38 @@ netgroup_keys (int number, char *key[])
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is for initgroups */
|
||||||
|
static int
|
||||||
|
initgroups_keys (int number, char *key[])
|
||||||
|
{
|
||||||
|
int ngrps = 100;
|
||||||
|
size_t grpslen = ngrps * sizeof (gid_t);
|
||||||
|
gid_t *grps = alloca (grpslen);
|
||||||
|
|
||||||
|
for (int i = 0; i < number; ++i)
|
||||||
|
{
|
||||||
|
int no = ngrps;
|
||||||
|
int n;
|
||||||
|
while ((n = getgrouplist (key[i], -1, grps, &no)) == -1
|
||||||
|
&& no > ngrps)
|
||||||
|
{
|
||||||
|
grps = extend_alloca (grps, grpslen, no * sizeof (gid_t));
|
||||||
|
ngrps = no;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n == -1)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
printf ("%-21s", key[i]);
|
||||||
|
for (int j = 0; j < n; ++j)
|
||||||
|
if (grps[j] != -1)
|
||||||
|
printf (" %ld", (long int) grps[j]);
|
||||||
|
putchar_unlocked ('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* This is for networks */
|
/* This is for networks */
|
||||||
static void
|
static void
|
||||||
print_networks (struct netent *net)
|
print_networks (struct netent *net)
|
||||||
@ -829,6 +861,7 @@ D(ethers)
|
|||||||
D(group)
|
D(group)
|
||||||
D(gshadow)
|
D(gshadow)
|
||||||
D(hosts)
|
D(hosts)
|
||||||
|
D(initgroups)
|
||||||
D(netgroup)
|
D(netgroup)
|
||||||
D(networks)
|
D(networks)
|
||||||
D(passwd)
|
D(passwd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user